A full-stack MERN (MongoDB, Express, React, Node.js) application for managing pharmaceutical inventory with role-based access control, stock hierarchy, pricing, and invoicing.
- Inventory Management: Track medicines with carton, box, and strip-level organization
- Supplier Management: Manage suppliers and purchase orders
- Pricing System: Cost price and selling price with automatic profit calculation
- Discount Tiers: Multiple discount levels per medicine
- Role-Based Access Control: Super Admin, Manager, Staff roles with granular permissions
- Alerts System: Low stock and expiry alerts
- Reports & Analytics: Comprehensive business insights
- Invoice Generation: Create and manage invoices
- Responsive UI: Works on desktop and mobile devices
.
├── backend/ # Node.js + Express API
│ ├── src/
│ │ ├── server.js # Main server entry point
│ │ ├── models/ # MongoDB schemas
│ │ ├── routes/ # API endpoints
│ │ ├── middleware/ # Auth and RBAC middleware
│ │ └── services/ # Business logic
│ └── package.json
├── src/ # React + TypeScript frontend
│ ├── components/ # React components
│ ├── contexts/ # Context API for state
│ ├── App.tsx
│ └── main.tsx
├── package.json # Frontend dependencies
└── vite.config.ts # Vite build config
- Node.js 16+ and npm
- MongoDB (local or MongoDB Atlas)
-
Clone the repository
git clone <your-repo-url> cd project
-
Install dependencies
# Frontend dependencies npm install # Backend dependencies cd backend npm install cd ..
-
Setup environment variables
Create
.envin backend folder:MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/medical-inventory JWT_SECRET=your-secure-secret-key PORT=5000 NODE_ENV=development
Create
.env.localin root folder:VITE_API_URL=http://localhost:5000
-
Run both servers
Terminal 1 - Backend:
cd backend npm run devTerminal 2 - Frontend:
npm run dev
-
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000/api
- Email: admin@example.com
- Password: admin123
- Push code to GitHub
- Connect repo to Vercel
- Set build command:
npm run build - Set output directory:
dist - Add environment variable:
VITE_API_URL=<your-backend-url>
- Push backend code to GitHub
- Connect repo to Render
- Set start command:
npm start - Add environment variables:
MONGODB_URI: MongoDB Atlas connection stringJWT_SECRET: Secure random stringNODE_ENV: production
- Create free cluster at https://mongodb.com/cloud/atlas
- Create database user
- Get connection string
- Use in backend
.envasMONGODB_URI
All endpoints require authentication via JWT token in Authorization header:
Authorization: Bearer <token>
POST /api/auth/login- User loginGET/POST /api/inventory/- Inventory itemsGET/POST /api/suppliers/- SuppliersGET/POST /api/purchase-orders/- Purchase ordersGET /api/alerts/- System alertsGET /api/reports/- Analytics data
See backend/API_DOCS.md for complete API reference.
Super Admin
- All permissions
- Can assign roles to users
Manager
- View/Manage inventory
- View/Manage suppliers
- View/Manage purchase orders
- Generate reports
Staff
- View inventory
- Create invoices
- View alerts
Frontend:
- React 18
- TypeScript
- Vite
- Tailwind CSS
Backend:
- Node.js
- Express
- MongoDB
- Mongoose
- JWT Authentication
- MEDICAL_INVENTORY_GUIDE.md - User guide
- QUICK_START.md - Quick start guide
- backend/API_DOCS.md - API documentation
Backend won't start:
- Verify MongoDB connection string
- Check if port 5000 is available
- Restart the server
API returns 404:
- Verify backend is running
- Check
VITE_API_URLin frontend - Check route registration in backend
Authentication fails:
- Verify JWT_SECRET matches between requests
- Check token expiration
- Clear browser cookies and try again
For issues or questions, please create an issue in the GitHub repository.
This project is open source and available under the MIT License.
Version: 1.0.0
Last Updated: June 2026