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.