How sparshgarg31/mediclinic works
Project type and purpose
• This is a full-stack MERN (MongoDB, Express, React, Node.js) application called “MediClinic.”
• Purpose: allow patients to register/login, browse doctor profiles, book or cancel appointments, and post reviews; doctors register/login, create and manage their profiles (experience, education), and view appointments and reviews in a dashboard.
File structure
A. Top-level directories/files:
• client/ → React single-page application
• config/keys.js → environment/configuration (DB URI, secrets)
• middleware/ → Express middleware for auth (authDoctor.js, authUser.js)
• models/ → Mongoose schemas (Doctor, Profile, User)
• routes/api/ → Express REST endpoints (authDoctor, authUser, appointment, doctors, profile, users)
• server.js → Node/Express server entry point
B. Client subtree (client/src):
• actions/ & reducers/ → Redux actions + reducers (authDoctor, authUser, appointment, profile, review, alert)
• components/ → React components organized by feature (auth, dashboard, profile management, booking, layout, routing, user views)
• store.js → Redux store setup
• utils/setAuthToken.js → helper to set JWT header
• public/ → static HTML, manifest, robots.txt
README insights
• Mentions MERN stack, runs with npm run dev in root to concurrently start Express (server) and React (client).
• Core features: doctor auth, user auth, profile CRUD, appointment booking/canceling, review posting/deleting, dashboard views.
a. Main components to include
1. React Frontend (client):
• Components (Auth, Booking Form, Dashboard, Profile, Reviews)
• Redux Store (Actions & Reducers)
2. Node/Express Backend (server):
• Route Handlers (REST API endpoints under routes/api/)
• Middleware (authDoctor, authUser, error handling)
• Controllers (business logic invoked by route handlers)
3. MongoDB (database):
• Collections: Users, Doctors, Profiles, Appointments, Reviews
4. External/Infrastructure
• JWT Authentication (token issued on login, stored in client local storage)
• Configuration Service (config/keys.js reads secrets)
b. Relationships and interactions
• Frontend → Backend: HTTP(S) requests to REST endpoints (e.g., POST /api/authUser, GET /api/doctors, POST /api/appointment)
• Backend → DB: Mongoose queries for CRUD operations on collections
• Frontend: React components dispatch Redux actions → triggers axios/fetch calls to API
• Middleware sits on the request path in the backend to validate JWT for protected routes (doctor vs. user)
• Data flow: User inputs → React forms → dispatch Redux action → API call → DB → response → Redux reducer updates store → UI rerenders
c. Architectural patterns & design principles
• Client side: Flux/Redux pattern (unidirectional data flow)
• Server side: MVC-like layering (Routes → Controllers/Services → Models)
• Separation of concerns:
• UI layer (React components)
• State management (Redux)
• API layer (Express routes + middleware)
• Data layer (Mongoose models + MongoDB)
• Authentication/Authorization via JWT and role-based middleware
d. Key technologies/frameworks
• React, Redux, React Router
• Express.js, Node.js
• MongoDB with Mongoose ODM
• JWT for auth, axios/fetch for HTTP client calls
• Concurrent run script (npm run dev) using nodemon and concurrently