Skip to content

Vedant24v/MedTrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MedTrace: Pharma Batch Record Tracker

πŸ“‹ Project Overview

MedTrace Systems - An Electronic Batch Record (EBR) system for pharmaceutical manufacturing. This is a portfolio project demonstrating a simplified Manufacturing Execution System (MES) used in pharma to track batch production from start to finish with full traceability and compliance.

What is MES?

A Manufacturing Execution System is a real-time production monitoring system that captures and reports all activities on the production floor. In pharmaceuticals, MES ensures:

  • GMP Compliance (Good Manufacturing Practices)
  • Traceability - Track every batch from raw materials to finished product
  • Quality Assurance - Verify each step meets specifications
  • Audit Trail - Digital signatures and timestamps on all actions

What is EBR?

An Electronic Batch Record is the digital equivalent of a paper batch record. It documents every step of a batch's production journey, including:

  • Operator actions and observations
  • Digital signatures and timestamps
  • Quality measurements and deviations
  • Approvals and final sign-off

🎯 Features

1. Authentication System

  • User registration and login with email + password
  • JWT-based authentication (15-min access tokens, 7-day refresh tokens)
  • Role-based access control (Operator vs Admin)
  • Secure httpOnly cookies for token storage

2. Recipe Management (Admin Only)

  • Create recipes with multiple steps
  • Each step includes: name, instruction, expected value, unit, signature requirement
  • Activate/deactivate recipes
  • Pre-seeded with 3 sample recipes: Paracetamol, Amoxicillin, Ibuprofen

3. Batch Execution (Operator)

  • Start a batch from an active recipe
  • Sequential step-by-step execution (no skipping)
  • Auto-generated Batch IDs (format: BAT-YYYYMMDD-XXXX)
  • Record actual values for each step
  • Digital e-signature for critical steps
  • Auto-save progress to prevent data loss
  • Visual progress bar with completion percentage

4. Batch Review & Approval (Admin)

  • View all pending batches on dashboard
  • Review step records and operator data
  • Approve or reject batches with comments
  • Rejection sends batch back for review

5. EBR PDF Export

  • Generate professional PDF batch records for approved batches
  • Includes: batch info, all steps with actual values, e-signatures, approval details
  • GMP compliance disclaimer
  • Download from batch detail page

6. Dashboards

  • Admin Dashboard: KPIs (total batches, pending, approved today, active recipes), chart of batches per product (30-day), recent batches table
  • Operator Dashboard: Quick-start new batch, my batch history with resume buttons

πŸ› οΈ Tech Stack

Layer Technology
Frontend React 18 + Vite + Tailwind CSS
Backend Node.js + Express.js
Database MongoDB with Mongoose
Authentication JWT (access + refresh tokens)
PDF Generation pdfkit
Charts Recharts
HTTP Client Axios
Notifications React Hot Toast
Icons Lucide React
Deployment Vercel (Frontend), Render (Backend), MongoDB Atlas (DB)

πŸ“ Project Structure

pharma-batch-tracker/
β”œβ”€β”€ client/                        # React + Vite Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ UI.jsx             # Reusable UI components (Button, Input, Card, etc.)
β”‚   β”‚   β”‚   β”œβ”€β”€ Stepper.jsx        # Batch execution stepper
β”‚   β”‚   β”‚   └── BatchComponents.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ RegisterPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ OperatorDashboard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ RecipeManagementPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ BatchExecutionPage.jsx
β”‚   β”‚   β”‚   └── AdminBatchesPage.jsx
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   β”œβ”€β”€ useAuth.js
β”‚   β”‚   β”‚   └── useBatch.js
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── api.js             # Axios instance + API endpoints
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   └── helpers.js
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ main.jsx
β”‚   β”‚   └── index.css
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   β”œβ”€β”€ vercel.json
β”‚   β”œβ”€β”€ .env.example
β”‚   └── index.html
β”‚
β”œβ”€β”€ server/                        # Express Backend
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   β”œβ”€β”€ Recipe.js
β”‚   β”‚   └── Batch.js
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ authController.js
β”‚   β”‚   β”œβ”€β”€ recipeController.js
β”‚   β”‚   └── batchController.js
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js
β”‚   β”‚   β”œβ”€β”€ recipeRoutes.js
β”‚   β”‚   └── batchRoutes.js
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ authenticateToken.js
β”‚   β”‚   β”œβ”€β”€ roleCheck.js
β”‚   β”‚   └── errorHandler.js
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ logger.js
β”‚   β”‚   β”œβ”€β”€ batchIdGenerator.js
β”‚   β”‚   β”œβ”€β”€ pdfGenerator.js
β”‚   β”‚   └── seeder.js
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ index.js
β”‚   β”œβ”€β”€ .env.example
β”‚   └── .gitignore
β”‚
└── README.md

πŸ“Š API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • POST /api/auth/refresh - Refresh access token
  • POST /api/auth/logout - Logout
  • GET /api/auth/me - Get current user

Recipes (Admin Only)

  • POST /api/recipes - Create recipe
  • GET /api/recipes - Get all recipes
  • GET /api/recipes/:id - Get recipe by ID
  • PUT /api/recipes/:id - Update recipe
  • PATCH /api/recipes/:id/deactivate - Deactivate recipe

Batches

  • POST /api/batches - Start new batch (Operator)
  • GET /api/batches/:id - Get batch details
  • POST /api/batches/:id/step - Complete batch step (Operator)
  • GET /api/batches/my-batches - Get operator's batches
  • GET /api/batches - Get all batches (Admin only)
  • POST /api/batches/:id/approve - Approve batch (Admin)
  • POST /api/batches/:id/reject - Reject batch (Admin)
  • GET /api/batches/:id/download - Download EBR PDF
  • GET /api/batches/stats/dashboard - Dashboard stats (Admin)

πŸ” Security Features

  • βœ… Password hashing with bcrypt
  • βœ… JWT access + refresh token pattern
  • βœ… httpOnly, secure, sameSite cookies
  • βœ… Role-based access control (RBAC)
  • βœ… CORS protection
  • βœ… Input validation on client and server
  • βœ… Error handling without leaking sensitive info
  • βœ… MongoDB injection prevention (Mongoose)

πŸ“ Sample Recipes (Pre-seeded)

1. Paracetamol 500mg Tablet (100 kg batches)

  • Weighing β†’ Granulation β†’ Drying β†’ Milling β†’ Blending β†’ Compression β†’ Coating β†’ QC Inspection

2. Amoxicillin 250mg Capsule (50 kg batches)

  • Material Verification β†’ Blending β†’ Capsule Filling β†’ Polishing β†’ Weight Check β†’ Visual Inspection

3. Ibuprofen 400mg Tablet (75 kg batches)

  • Dispensing β†’ Wet Granulation β†’ Fluid Bed Drying β†’ Sizing β†’ Lubrication β†’ Tablet Compression β†’ Film Coating

πŸ“š Code Quality

  • βœ… Async/await throughout (no callbacks)
  • βœ… Consistent error handling with try/catch
  • βœ… Comments on complex logic
  • βœ… Modular component structure
  • βœ… DRY principles (Don't Repeat Yourself)
  • βœ… HTTP status codes used correctly
  • βœ… Input validation on both client and server

🀝 Contributing

This is a portfolio project. Modifications and improvements are encouraged!


πŸ“„ License

Author: Vedant24v

This project is created as a portfolio demonstration for pharmaceutical manufacturing execution systems and electronic batch records.


✨ Features Roadmap

  • Mobile app (React Native)
  • Advanced analytics and reporting
  • Batch deviation management
  • Equipment integration (IoT sensors)
  • Automated alerts for out-of-spec values
  • Multi-language support
  • Two-factor authentication (2FA)

πŸ“§ Contact

For questions or suggestions, please reach out to the project author.


Note: This is a simplified EBR system for educational/portfolio purposes. A production system would require additional features like audit trails, compliance validation, and integration with enterprise systems.

About

MedTrace Systems - An Electronic Batch Record (EBR) system for pharmaceutical manufacturing. This is a portfolio project demonstrating a simplified Manufacturing Execution System (MES) used in pharma to track batch production from start to finish with full traceability and compliance.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors