# rbsuhail/appoint-care architecture

> Architecture diagram of the GitHub repository rbsuhail/appoint-care, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rbsuhail/appoint-care
- Repository: https://github.com/rbsuhail/appoint-care

## Overview

1. **Overall shape**
   - AppointCare is a classic **MERN-style split architecture**: a **Vite/React client** in `client/` and a **Node/Express API** at the repo root.
   - The backend talks to **MongoDB through Mongoose**, and the frontend consumes the API for login, booking, doctor management, and admin operations.

2. **Frontend application shell**
   - The client entrypoint is `client/src/main.jsx`, which mounts `App.jsx`.
   - `Layout.jsx` provides the shared application frame, while `Spinner.jsx` is used for loading states.
   - Styling is a mix of `index.css` and `theme.js`, with **Ant Design** used for UI components.

3. **Client routing and access control**
   - The app separates public and authenticated areas using `PublicRoute.jsx` and `ProtectedRoute.jsx`.
   - This suggests route-level enforcement for roles such as **patient/user**, **doctor**, and **admin**, with the frontend deciding which pages are reachable after auth.

4. **Frontend feature areas**
   - Patient-facing pages include `HomePage`, `BookingPage`, `Appointments`, `NotificationPage`, `Login`, and `Register`.
   - Doctor-facing pages live under `pages/doctor/` and include `Profile` and `DoctorAppointments`.
   - Admin pages live under `pages/admin/` and include `Doctors` and `Users`.
   - `ApplyDoctor.jsx` appears to support a user applying to become a doctor.

5. **Frontend state management**
   - Redux is used for global state via `client/src/redux/store.js`.
   - `userSlice.js` likely stores authentication/session and current user profile data.
   - `alertSlice.js` handles app-wide notifications or flash messages.
   - This implies the client keeps auth and alert state centrally, while page components focus on view logic.

6. **Frontend data/modeling**
   - `DoctorCard.jsx` is a reusable display component for doctor listings or search results.
   - `menuData.js` likely drives navigation menus, probably varying by role.
   - The presence of `BookingPage` and doctor cards indicates the UI is organized around selecting doctors and booking available slots.

7. **Backend API structure**
   - The server entrypoint is `server.js`, which likely wires Express middleware, routes, and the database connection.
   - API endpoints are split by domain in `routes/userRoutes.js`, `routes/doctorRoutes.js`, and `routes/adminRoutes.js`.
   - Controllers mirror that split in `controllers/userCtrl.js`, `doctorCtrl.js`, and `adminCtrl.js`, keeping HTTP routing separate from business logic.

8. **Backend business domains**
   - The main backend domains are **users**, **doctors**, and **appointments**.
   - `models/userModels.js`, `doctorModel.js`, and `appointmentModel.js` define the persisted entities.
   - From the file names, appointments are probably the core transactional object linking a patient, a doctor, and a time slot.

9. **Security and authorization**
   - `middlewares/authMiddleware.js` is the key gatekeeper for protected API routes.
   - This likely verifies authentication and enforces role-based access for doctor/admin operations.
   - The frontend `ProtectedRoute`/`PublicRoute` components and backend auth middleware work together as layered access control.

10. **Database and persistence**
   - `config/db.js` centralizes the MongoDB connection setup.
   - Mongoose models define the schema boundary between application logic and persistence.
   - This means the backend is stateful through MongoDB, while the frontend remains a consumer of API responses.

11. **Request/data flow**
   - A typical flow is: client page → Redux/UI action → API request → Express route → controller → Mongoose model → MongoDB → response back to client.
   - Booking and appointment management are likely the most important end-to-end flows, because they touch both doctor availability and user scheduling.

12. **Operational/tooling boundaries**
   - The client is built with **Vite**; the repo also includes separate `package.json` files for the root and client, indicating distinct runtime/build concerns.
   - The README mentions **Concurrently** and **Nodemon**, so development likely runs frontend and backend together with hot reload on the server side.
   - No external services are visible in the tree beyond MongoDB, so the architecture appears self-contained around the API/database boundary.

Main entry points: [`client/src/App.jsx`](https://github.com/rbsuhail/appoint-care/blob/main/client/src/App.jsx) (App shell), [`client/src/redux/store.js`](https://github.com/rbsuhail/appoint-care/blob/main/client/src/redux/store.js) (Redux store), [`routes/userRoutes.js`](https://github.com/rbsuhail/appoint-care/blob/main/routes/userRoutes.js) (API routes), [`client/src/pages/BookingPage.jsx`](https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/BookingPage.jsx) (Booking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_main(("App entry<br/>Vite React entry<br/>[main.jsx]"))
  node_client_app["App shell<br/>React shell<br/>[App.jsx]"]
  node_client_layout["Layout<br/>UI frame<br/>[Layout.jsx]"]
  node_client_routes{{"Route guards<br/>access control<br/>[PublicRoute.jsx]"}}
  node_client_state[("Redux store<br/>global state<br/>[store.js]")]
  node_client_user_slice["User state<br/>auth/session state<br/>[userSlice.js]"]
  node_client_alert_slice["Alerts<br/>ui notifications<br/>[alertSlice.js]"]
  node_client_home["Home<br/>patient page<br/>[HomePage.jsx]"]
  node_client_booking["Booking<br/>patient flow<br/>[BookingPage.jsx]"]
  node_client_appointments["Appointments<br/>patient page<br/>[Appointments.jsx]"]
  node_client_auth["Login & register<br/>auth pages<br/>[Login.jsx]"]
  node_client_doctor_area["Doctor area<br/>doctor pages<br/>[Profile.jsx]"]
  node_client_admin_area["Admin area<br/>admin pages<br/>[Doctors.jsx]"]
  node_client_doctor_card["Doctor card<br/>reusable component<br/>[DoctorCard.jsx]"]
  node_client_menu["Menu data<br/>navigation config<br/>[menuData.js]"]
end

subgraph group_backend["Backend"]
  node_server_entry(("Server<br/>Express entry<br/>[server.js]"))
  node_api_routes["API routes<br/>route layer<br/>[userRoutes.js]"]
  node_api_ctrls["Controllers<br/>business logic<br/>[userCtrl.js]"]
  node_auth_mw{{"Auth middleware<br/>security<br/>[authMiddleware.js]"}}
  node_domain_models[("Domain models<br/>mongoose models<br/>[userModels.js]")]
  node_db_config["Mongo config<br/>database config<br/>[db.js]"]
end

node_client_main -->|"boots"| node_client_app
node_client_app -->|"uses"| node_client_layout
node_client_app -->|"protects"| node_client_routes
node_client_app -->|"connects"| node_client_state
node_client_state -->|"contains"| node_client_user_slice
node_client_state -->|"contains"| node_client_alert_slice
node_client_app -->|"shows"| node_client_home
node_client_app -->|"shows"| node_client_booking
node_client_app -->|"shows"| node_client_appointments
node_client_app -->|"shows"| node_client_auth
node_client_app -->|"shows"| node_client_doctor_area
node_client_app -->|"shows"| node_client_admin_area
node_client_booking -->|"renders"| node_client_doctor_card
node_client_app -->|"drives"| node_client_menu
node_server_entry -->|"mounts"| node_api_routes
node_api_routes -->|"delegates"| node_api_ctrls
node_api_routes -->|"guards"| node_auth_mw
node_api_ctrls -->|"reads/writes"| node_domain_models
node_domain_models -->|"connects via"| node_db_config
node_client_state -.->|"feeds"| node_client_booking
node_client_app -.->|"calls API"| node_server_entry
node_auth_mw -.->|"mirrors"| node_client_routes

click node_client_main "https://github.com/rbsuhail/appoint-care/blob/main/client/src/main.jsx"
click node_client_app "https://github.com/rbsuhail/appoint-care/blob/main/client/src/App.jsx"
click node_client_layout "https://github.com/rbsuhail/appoint-care/blob/main/client/src/components/Layout.jsx"
click node_client_routes "https://github.com/rbsuhail/appoint-care/blob/main/client/src/components/PublicRoute.jsx"
click node_client_state "https://github.com/rbsuhail/appoint-care/blob/main/client/src/redux/store.js"
click node_client_user_slice "https://github.com/rbsuhail/appoint-care/blob/main/client/src/redux/features/userSlice.js"
click node_client_alert_slice "https://github.com/rbsuhail/appoint-care/blob/main/client/src/redux/features/alertSlice.js"
click node_client_home "https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/HomePage.jsx"
click node_client_booking "https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/BookingPage.jsx"
click node_client_appointments "https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/Appointments.jsx"
click node_client_auth "https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/Login.jsx"
click node_client_doctor_area "https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/doctor/Profile.jsx"
click node_client_admin_area "https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/admin/Doctors.jsx"
click node_client_doctor_card "https://github.com/rbsuhail/appoint-care/blob/main/client/src/components/DoctorCard.jsx"
click node_client_menu "https://github.com/rbsuhail/appoint-care/blob/main/client/src/data/menuData.js"
click node_server_entry "https://github.com/rbsuhail/appoint-care/blob/main/server.js"
click node_api_routes "https://github.com/rbsuhail/appoint-care/blob/main/routes/userRoutes.js"
click node_api_ctrls "https://github.com/rbsuhail/appoint-care/blob/main/controllers/userCtrl.js"
click node_auth_mw "https://github.com/rbsuhail/appoint-care/blob/main/middlewares/authMiddleware.js"
click node_domain_models "https://github.com/rbsuhail/appoint-care/blob/main/models/userModels.js"
click node_db_config "https://github.com/rbsuhail/appoint-care/blob/main/config/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_main,node_client_app,node_client_layout,node_client_routes,node_client_state,node_client_user_slice,node_client_alert_slice,node_client_home,node_client_booking,node_client_appointments,node_client_auth,node_client_doctor_area,node_client_admin_area,node_client_doctor_card,node_client_menu toneBlue
class node_server_entry,node_api_routes,node_api_ctrls,node_auth_mw,node_domain_models,node_db_config toneAmber
```

## Components

### Client

Vite/React frontend and UI state

- [App entry](https://github.com/rbsuhail/appoint-care/blob/main/client/src/main.jsx): Vite React entry · Mounts the client app and boots the UI · `client/src/main.jsx`
- [App shell](https://github.com/rbsuhail/appoint-care/blob/main/client/src/App.jsx): React shell · Top-level app composition and routing hub · `client/src/App.jsx`
- [Layout](https://github.com/rbsuhail/appoint-care/blob/main/client/src/components/Layout.jsx): UI frame · Shared application chrome and page framing · `client/src/components/Layout.jsx`
- [Route guards](https://github.com/rbsuhail/appoint-care/blob/main/client/src/components/PublicRoute.jsx): access control · Separates public and protected client areas · `client/src/components/PublicRoute.jsx`
- [Redux store](https://github.com/rbsuhail/appoint-care/blob/main/client/src/redux/store.js): global state · Central client state container · `client/src/redux/store.js`
- [User state](https://github.com/rbsuhail/appoint-care/blob/main/client/src/redux/features/userSlice.js): auth/session state · Stores current user and authentication context · `client/src/redux/features/userSlice.js`
- [Alerts](https://github.com/rbsuhail/appoint-care/blob/main/client/src/redux/features/alertSlice.js): ui notifications · Global flash and alert message state · `client/src/redux/features/alertSlice.js`
- [Home](https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/HomePage.jsx): patient page · Public landing and discovery page · `client/src/pages/HomePage.jsx`
- [Booking](https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/BookingPage.jsx): patient flow · Selects doctors and schedules appointments · `client/src/pages/BookingPage.jsx`
- [Appointments](https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/Appointments.jsx): patient page · Shows booked appointments and status · `client/src/pages/Appointments.jsx`
- [Login & register](https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/Login.jsx): auth pages · User authentication and onboarding pages · `client/src/pages/Login.jsx`
- [Doctor area](https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/doctor/Profile.jsx): doctor pages · Doctor profile and appointment management views · `client/src/pages/doctor/Profile.jsx`
- [Admin area](https://github.com/rbsuhail/appoint-care/blob/main/client/src/pages/admin/Doctors.jsx): admin pages · Doctor and user administration views · `client/src/pages/admin/Doctors.jsx`
- [Doctor card](https://github.com/rbsuhail/appoint-care/blob/main/client/src/components/DoctorCard.jsx): reusable component · Displays doctor summaries in lists and search results · `client/src/components/DoctorCard.jsx`
- [Menu data](https://github.com/rbsuhail/appoint-care/blob/main/client/src/data/menuData.js): navigation config · Drives role-aware navigation and menus · `client/src/data/menuData.js`

### Backend

Express API, domain logic, and persistence

- [Server](https://github.com/rbsuhail/appoint-care/blob/main/server.js): Express entry · Starts the API server and wires middleware and routes · `server.js`
- [API routes](https://github.com/rbsuhail/appoint-care/blob/main/routes/userRoutes.js): route layer · Domain route modules for users, doctors, and admins · `routes/userRoutes.js`
- [Controllers](https://github.com/rbsuhail/appoint-care/blob/main/controllers/userCtrl.js): business logic · HTTP handlers split by domain · `controllers/userCtrl.js`
- [Auth middleware](https://github.com/rbsuhail/appoint-care/blob/main/middlewares/authMiddleware.js): security · Protects routes and enforces role-based access · `middlewares/authMiddleware.js`
- [Domain models](https://github.com/rbsuhail/appoint-care/blob/main/models/userModels.js): mongoose models · User, doctor, and appointment persistence schemas · `models/userModels.js`
- [Mongo config](https://github.com/rbsuhail/appoint-care/blob/main/config/db.js): database config · MongoDB connection setup · `config/db.js`

## Connections

- App entry → App shell: boots · Client entry mounts the application shell
- App shell → Layout: uses · App composes the shared page frame
- App shell → Route guards: protects · Routes split public and authenticated areas
- App shell → Redux store: connects · App reads from the shared Redux store
- Redux store → User state: contains · Store includes authentication and profile state
- Redux store → Alerts: contains · Store includes app-wide alert state
- App shell → Home: shows · Public entry includes the home page
- App shell → Booking: shows · Authenticated users can reach booking flows
- App shell → Appointments: shows · Users view their appointment history and status
- App shell → Login & register: shows · Authentication pages handle login and registration
- App shell → Doctor area: shows · Doctor-specific views live in the protected area
- App shell → Admin area: shows · Admin-specific views live in the protected area
- Booking → Doctor card: renders · Booking and discovery flows reuse doctor cards
- App shell → Menu data: drives · Navigation varies by role and session state
- Server → API routes: mounts · Server registers domain route modules
- API routes → Controllers: delegates · Routes hand off request handling to controllers
- API routes → Auth middleware: guards · Protected endpoints are wrapped with auth checks
- Controllers → Domain models: reads/writes · Controllers operate on persisted domain entities
- Domain models → Mongo config: connects via · Models depend on the MongoDB connection
- Redux store → Booking: feeds · Auth and session state support booking actions
- App shell → Server: calls API · Frontend pages request data and submit actions to the backend
- Auth middleware → Route guards: mirrors · Backend authorization complements client-side route guards
