How abhishek9680/digital-healthcare-system works
Project type and purpose
• Full-stack healthcare appointment system.
• React SPA with separate dashboards for patients and doctors.
• Express API server implementing MVC (router → controller → model).
• MongoDB Atlas as the database, JWT for stateless authentication.
File structure
• Top-level “frontend/” directory: Vite-powered React app, pages, components, API utility, styles.
• Top-level “backend/” directory: Express entry point (index.js), config (db.js), router, controllers, models, auth middleware.
• Separation of concerns:
• frontend handles UI, routing, API calls
• backend exposes REST endpoints, business logic, data persistence
• models define Mongoose schemas for Patient, Doctor, Appointment
Key README insights
• Role-based flows: register/login for doctor and patient, protected dashboards.
• Tech stack: React, Node.js, Express, MongoDB, Tailwind CSS, daisyUI.
• Runtime: local dev via Vite (port 5173) and Express (port 3000), environment variables for DB URI and JWT secret.
Main components & their interactions
a. Client (Browser/Electron wrapper)
• React UI
• Uses AppRoutes, ProtectedRoute, Navbar, page components
• Calls backend via API functions in src/api.js
b. API Gateway (Express server)
• Routes defined in router/doctorRoute.js and patientRoute.js
• Auth middleware (authMiddleware.js) verifies JWT
• Controllers (doctorController, patientController) implement business logic
c. Persistence Layer
• MongoDB (hosted on Atlas)
• Mongoose models: Doctor, Patient, Appointment
d. External Services
• MongoDB Atlas cluster
• JWT issuer/validator (using JWT_SECRET)
Data flow example:
1. User (Doctor/Patient) fills login form →
2. Frontend (src/api.js) issues POST /login →
3. Express router → authMiddleware (for protected routes) → controller →
4. Mongoose model queries/inserts into MongoDB →
5. Backend returns JSON + JWT →
6. Frontend stores JWT, updates UI (dashboard).
Architectural patterns & principles
• Layered architecture (Presentation → API layer → Business logic → Data access)
• MVC on backend:
• Router maps endpoints → Controller applies logic → Model handles DB
• Component-based UI on frontend
• Stateless authentication with JWT
• Role-based access control enforced via ProtectedRoute component and authMiddleware
• Client: User Roles → Browser/Electron → React Components → API Utility
• Server: Express Entry Point → Routers → Auth Middleware → Controllers → Models
• Database: MongoDB Atlas
• Environment variables feeding into the backend (e.g., MONGO_URI, JWT_SECRET).
• Protected routes and JWT validation path.
• Keep it at a single canvas but scalable: group components logically.