How vk8459698/hmis works
Main Components
• Frontend (React + Vite SPA)
• Backend/API (Node.js + Express)
• Database (MongoDB)
• Authentication & Authorization (JWT via authMiddleware)
• External Services (e.g., email/notification gateways, analytics)
Relationships & Data Flows
• Browser clients (doctors, nurses, patients, admin, pharmacist, receptionist) load the React SPA via HTTP(S) from Vite’s dev/prod server.
• Frontend issues REST calls (GET/POST/PUT/DELETE) to the Express API over /api/* endpoints.
• Express routes delegate to controllers → business logic → Mongoose models → MongoDB.
• Controllers use authMiddleware to enforce JWT-based access control per role.
• Notification events (e.g., appointment reminders, lab results) are published to an external email/SMS gateway.
• Analytics module aggregates logs from the logs collection and feeds into analytics dashboards.
Architectural Patterns & Design Principles
• Backend follows MVC-like pattern:
– Routes define endpoints (in backend/routes/*.js)
– Controllers handle request/response logic (in backend/controllers/*.js)
– Models define schemas and DB access (in backend/models/*.js)
• Validation layer sits between routes & controllers (backend/validators/*.js).
• Cross-cutting concern: authMiddleware.js protects secured routes.
• Frontend is a component-based SPA:
– Pages organized by user role under src/pages
– Shared UI (Navbar, Sidebar, ProtectedRoute) in src/components
– State & side-effects managed via React Context (AuthContext.jsx) and custom hooks (useTest.js).
– HTTP calls centralized via axiosInstance.js.
Technologies & Frameworks to Annotate
• Frontend: React, Vite, JSX/TS, React Router, CSS modules
• Backend: Node.js, Express.js, Mongoose, JWT, Dotenv
• Database: MongoDB (hosted or local)
• Build & Deployment: npm run dev (backend), npm run dev (frontend)
– MongoDB (with key collections)
– External Gateways (Notifications, Analytics)
• Notes on Authentication (JWT flow: login → token → protected routes)
• Deployment endpoints (frontend at localhost:5173, backend at localhost:5000)