How nuby911/inventory-klinik works
Klinik El Medika is an integrated clinic and pharmacy back-office: staff sign in, then administrators manage medicines and batches, doctors register patients and write e-prescriptions, and pharmacists prepare and dispense them. The client uses a shared API service; the server routes requests to domain controllers backed by SQLite. FEFO allocation supports dispensing, while Socket.io carries prescription and stock updates. The README documents these capabilities; unsampled route wiring and some client-to-server details are shown only where the indexed references or excerpts support them.
Main entry points: api.js API routes · database.js Clinic database · App.jsx Role-based app · prescriptionController.js E-prescriptions
Components 24
Staff application
- Role-based app
client/src/App.jsx - Staff sign-in
client/src/pages/auth/LoginPage.jsx - Doctor portal
client/src/pages/doctor/DoctorPortal.jsx - Pharmacy portal
client/src/pages/pharmacy/PharmacyPortal.jsx - Admin portal
client/src/pages/admin/AdminPortal.jsx - API client
client/src/services/api.js - Socket context
client/src/context/SocketContext.jsx
API and access
- Express and sockets
server/src/server.js - API routes
server/src/routes/api.js - Authentication
server/src/controllers/authController.js - Session and role checks
server/src/middlewares/authMiddleware.js - User management
server/src/controllers/userController.js
Clinical and inventory
- Medicine catalog
server/src/controllers/medicineController.js - Batch inventory
server/src/controllers/batchController.js - Patient records
server/src/controllers/patientController.js - E-prescriptions
server/src/controllers/prescriptionController.js - Unit conversion and FEFO
server/src/services/fefoService.js - Clinic database
server/src/config/database.js - Clinic rules and dates
server/src/utils/clinicHelpers.js
Reports and operations
- Reports and logistics
client/src/components/common/LogisticsReportView.jsx - Reports
server/src/controllers/reportController.js
Other components
- Clinic staff
- HTTP clients
- Live event clients
Connections 36
- Clinic staff → Role-based app: uses
- Role-based app → Staff sign-in: shows when signed out
client/src/App.jsx - Role-based app → Doctor portal: routes by role
client/src/App.jsx - Role-based app → Pharmacy portal: routes by role
client/src/App.jsx - Role-based app → Admin portal: routes by role
client/src/App.jsx - Doctor portal → API client: requests data
client/src/pages/doctor/DoctorPortal.jsx - Pharmacy portal → API client: requests data
client/src/pages/pharmacy/PharmacyPortal.jsx - Admin portal → API client: requests data
client/src/pages/admin/AdminPortal.jsx - Reports and logistics → API client: requests reports
client/src/components/common/LogisticsReportView.jsx - API client → HTTP clients: sends requests
client/src/services/api.js - HTTP clients → Express and sockets: reaches API
- Express and sockets → API routes: mounts routes
server/src/server.js - API routes → Authentication: dispatches
- API routes → Medicine catalog: dispatches
- API routes → Batch inventory: dispatches
- API routes → Patient records: dispatches
- API routes → E-prescriptions: dispatches
- API routes → User management: dispatches
- API routes → Reports: dispatches
- Medicine catalog → Clinic database: reads and writes
server/src/controllers/medicineController.js - Batch inventory → Clinic database: reads and writes
server/src/controllers/batchController.js - Patient records → Clinic database: reads and writes
server/src/controllers/patientController.js - E-prescriptions → Clinic database: reads and writes
server/src/controllers/prescriptionController.js - User management → Clinic database: reads and writes
server/src/controllers/userController.js - Reports → Clinic database: reads
server/src/controllers/reportController.js - Session and role checks → Clinic database: checks session
server/src/middlewares/authMiddleware.js - E-prescriptions → Unit conversion and FEFO: allocates stock
server/src/controllers/prescriptionController.js - Batch inventory → Unit conversion and FEFO: uses allocation rules
server/src/controllers/batchController.js - Medicine catalog → Unit conversion and FEFO: uses unit rules
server/src/controllers/medicineController.js - Unit conversion and FEFO → Clinic database: updates batches
server/src/services/fefoService.js - Unit conversion and FEFO → Clinic rules and dates: uses clinic dates
server/src/services/fefoService.js - E-prescriptions → Clinic rules and dates: uses clinic rules
server/src/controllers/prescriptionController.js - Reports → Clinic rules and dates: uses date ranges
server/src/controllers/reportController.js - E-prescriptions → Live event clients: emits prescription events
server/src/controllers/prescriptionController.js - Live event clients → Socket context: delivers live updates
- Socket context → Role-based app: provides socket state
client/src/App.jsx