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.
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
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
- 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
- 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
- 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
- View all pending batches on dashboard
- Review step records and operator data
- Approve or reject batches with comments
- Rejection sends batch back for review
- 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
- 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
| 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) |
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
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/refresh- Refresh access tokenPOST /api/auth/logout- LogoutGET /api/auth/me- Get current user
POST /api/recipes- Create recipeGET /api/recipes- Get all recipesGET /api/recipes/:id- Get recipe by IDPUT /api/recipes/:id- Update recipePATCH /api/recipes/:id/deactivate- Deactivate recipe
POST /api/batches- Start new batch (Operator)GET /api/batches/:id- Get batch detailsPOST /api/batches/:id/step- Complete batch step (Operator)GET /api/batches/my-batches- Get operator's batchesGET /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 PDFGET /api/batches/stats/dashboard- Dashboard stats (Admin)
- ✅ 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)
- Weighing → Granulation → Drying → Milling → Blending → Compression → Coating → QC Inspection
- Material Verification → Blending → Capsule Filling → Polishing → Weight Check → Visual Inspection
- Dispensing → Wet Granulation → Fluid Bed Drying → Sizing → Lubrication → Tablet Compression → Film Coating
- ✅ 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
This is a portfolio project. Modifications and improvements are encouraged!
Author: Vedant24v
This project is created as a portfolio demonstration for pharmaceutical manufacturing execution systems and electronic batch records.
- 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)
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.