How imohit1o1/medi-hub works
Project type and purpose
• This is a full-stack MERN (MongoDB, Express, React, Node.js) hospital management system called MediHub.
• It provides three user interfaces:
• A public‐facing React frontend for patients/visitors
• A React-based admin dashboard for healthcare staff
• A Node/Express REST API backend connected to MongoDB
• Key features: appointment scheduling, user authentication (JWT), file management (Cloudinary), payments, analytics.
File structure
• Top level:
• frontend/ – patient-facing SPA
• dashboard/ – admin SPA
• backend/ – Express API
• backend/src follows an MVC structure:
• controllers/ – business logic per resource (user, appointment, medicine, etc.)
• models/ – Mongoose schemas
• routes/ – Express routers mapping endpoints to controllers
• middlewares/ – auth, file upload (multer), error/async wrappers
• db/ – MongoDB connection
• utilis/ – helpers (ApiError, ApiResponse, JWT token, Cloudinary)
• frontend and dashboard both use:
• src/components, src/pages – UI composition
• src/Context – React Context for global state
• src/axios – HTTP client config
• Deployment/config files: .env.example, package.json, Vite config, ESLint, Prettier.
Extract README insights
• Confirms MERN stack, JWT auth, Cloudinary integration, analytics dashboard.
• Mentions separate frontend, backend, dashboard directories.
a. Main components
1. Public React Frontend (frontend/)
2. Admin React Dashboard (dashboard/)
3. Express REST API (backend/app.js → backend/src/routes & controllers)
4. MongoDB Database
5. External Services:
– Cloudinary for file storage
– JWT Authentication Provider (built-in)
– Payment Gateway (stripe/third-party) if integrated
b. Relationships & interactions
– Both frontends make HTTP(S) calls to the API’s endpoints (e.g., /api/user, /api/appointment).
– On login/signup, API issues JWT tokens, frontends store them and send in Authorization headers.
– API performs CRUD on MongoDB collections via Mongoose models.
– For image/document upload, API routes call Cloudinary util to store assets and return URLs.
– Payment endpoints interact with a third-party payment processor.
– Admin dashboard pulls analytics data from API (aggregate appointment/patient stats).
c. Architectural patterns
– Backend: MVC (Models, Views=Controllers, Routes), layered architecture (controllers → services/utilis → database).
– Frontend: Component-based React, Context API for global state (auth, cart).
– Separation of concerns: UI vs business logic vs data store.
d. Key technologies
– React.js + Vite + TailwindCSS on both frontends
– Axios for HTTP client
– Node.js + Express on backend
– MongoDB with Mongoose ODM
– Multer for file parsing, Cloudinary SDK for storage
– JWT for stateless auth
Detail
• Call out shared Context providers in frontends (AuthContext, CartContext).
• Rate-limiting, validation, error-handling middlewares.
• Development vs production config (ENV variables, .env.example).