# fardinkazi/healthbooker architecture

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

- Interactive diagram: https://gitdiagram.com/fardinkazi/healthbooker
- Repository: https://github.com/fardinkazi/healthbooker

## Overview

##### Project type and purpose
- HealthBooker is a full-stack healthcare booking platform.
- It provides a React-based single-page frontend for users and doctors, and an Express/Node.js REST API backend connected to MongoDB.
- Key features include user registration/login, doctor listing and applications, appointment booking and status tracking, notifications, and an admin dashboard.

##### File structure
- Top-level “client” folder holds the React app:
- src/components & src/pages for UI components and views
- src/redux for state management (Redux Toolkit)
- helper, middleware, images, styles
- Root contains the Node/Express API:
- server.js and .env for configuration
- routes/*.js define REST endpoints
- controllers/*.js implement business logic (MVC-style)
- models/*.js define Mongoose schemas
- middleware/auth.js for JWT auth
- db/conn.js for MongoDB connection
- Build and deployment artifacts (client/build) and package.json files confirm a standard build + serve workflow.

##### README for additional insights
- Technologies: React, Redux Toolkit, Node.js, Express, MongoDB
- Admin workflow requires toggling isAdmin in the database
- The app is hosted (e.g., Render), using environment variables for secrets and DB URL.

##### Detail
- Essential modules: frontend pages, API routes, controllers, models, and middleware
- How static assets (client/build) are served (via Express or a CDN)
- Environment configurations (.env) and where secrets live
- Don’t overthink—break the system into these components and show how data flows between them

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Browser"]:::external
        FrontendSPA["React SPA"]:::frontend
        ReduxStore["Redux Store"]:::frontend
        ApiHelper["API Call Helper"]:::frontend
        RouteMiddleware["Route Middleware"]:::frontend
        subgraph "React Components"
            Users["Users.jsx"]:::frontend
            DoctorApply["DoctorApply.jsx"]:::frontend
            DoctorCard["DoctorCard.jsx"]:::frontend
            BookAppointment["BookAppointment.jsx"]:::frontend
            AdminApplications["AdminApplications.jsx"]:::frontend
            AdminAppointments["AdminAppointments.jsx"]:::frontend
            AdminDoctors["AdminDoctors.jsx"]:::frontend
        end
        subgraph "Pages (Views)"
            Register["Register.jsx"]:::frontend
            Login["Login.jsx"]:::frontend
            Profile["Profile.jsx"]:::frontend
            ApplyDoctorPage["ApplyDoctor.jsx"]:::frontend
            DoctorsPage["Doctors.jsx"]:::frontend
            AppointmentsPage["Appointments.jsx"]:::frontend
            NotificationsPage["Notifications.jsx"]:::frontend
            DashboardPage["Dashboard.jsx"]:::frontend
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        Server["Express Server\n(server.js)"]:::backend
        EnvRoot[".env"]:::config
        AuthMiddleware["Auth Middleware"]:::middleware
        subgraph "Routes"
            UserRoutes["userRoutes.js"]:::backend
            DoctorRoutes["doctorRoutes.js"]:::backend
            AppointmentRoutes["appointRoutes.js"]:::backend
            NotificationRoutes["notificationRouter.js"]:::backend
        end
        subgraph "Controllers"
            UserController["userController.js"]:::backend
            DoctorController["doctorController.js"]:::backend
            AppointmentController["appointmentController.js"]:::backend
            NotificationController["notificationController.js"]:::backend
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        subgraph "Models"
            UserModel["userModel.js"]:::database
            DoctorModel["doctorModel.js"]:::database
            AppointmentModel["appointmentModel.js"]:::database
            NotificationModel["notificationModel.js"]:::database
        end
        DBConn["DB Connection\n(db/conn.js)"]:::config
        DB["MongoDB"]:::database
    end

    %% Connections
    Browser --> FrontendSPA
    FrontendSPA -->|uses| ReduxStore
    FrontendSPA -->|uses| ApiHelper
    FrontendSPA -->|uses| RouteMiddleware
    FrontendSPA -->|HTTP API calls| Server

    Server -->|loads| EnvRoot
    Server -->|uses| AuthMiddleware
    Server -->|registers| UserRoutes
    Server -->|registers| DoctorRoutes
    Server -->|registers| AppointmentRoutes
    Server -->|registers| NotificationRoutes

    UserRoutes -->|calls| UserController
    DoctorRoutes -->|calls| DoctorController
    AppointmentRoutes -->|calls| AppointmentController
    NotificationRoutes -->|calls| NotificationController

    UserController -->|queries| UserModel
    DoctorController -->|queries| DoctorModel
    AppointmentController -->|queries| AppointmentModel
    NotificationController -->|queries| NotificationModel

    Server -->|init| DBConn
    DBConn -->|connects to| DB

    %% Click Events
    click FrontendSPA "https://github.com/fardinkazi/healthbooker/tree/main/client/src"
    click Users "https://github.com/fardinkazi/healthbooker/blob/main/client/src/components/Users.jsx"
    click DoctorApply "https://github.com/fardinkazi/healthbooker/blob/main/client/src/components/DoctorApply.jsx"
    click DoctorCard "https://github.com/fardinkazi/healthbooker/blob/main/client/src/components/DoctorCard.jsx"
    click BookAppointment "https://github.com/fardinkazi/healthbooker/blob/main/client/src/components/BookAppointment.jsx"
    click AdminApplications "https://github.com/fardinkazi/healthbooker/blob/main/client/src/components/AdminApplications.jsx"
    click AdminAppointments "https://github.com/fardinkazi/healthbooker/blob/main/client/src/components/AdminAppointments.jsx"
    click AdminDoctors "https://github.com/fardinkazi/healthbooker/blob/main/client/src/components/AdminDoctors.jsx"
    click Register "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/Register.jsx"
    click Login "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/Login.jsx"
    click Profile "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/Profile.jsx"
    click ApplyDoctorPage "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/ApplyDoctor.jsx"
    click DoctorsPage "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/Doctors.jsx"
    click AppointmentsPage "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/Appointments.jsx"
    click NotificationsPage "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/Notifications.jsx"
    click DashboardPage "https://github.com/fardinkazi/healthbooker/blob/main/client/src/pages/Dashboard.jsx"
    click ReduxStore "https://github.com/fardinkazi/healthbooker/blob/main/client/src/redux/store.js"
    click ApiHelper "https://github.com/fardinkazi/healthbooker/blob/main/client/src/helper/apiCall.js"
    click RouteMiddleware "https://github.com/fardinkazi/healthbooker/blob/main/client/src/middleware/route.js"
    click Server "https://github.com/fardinkazi/healthbooker/blob/main/server.js"
    click EnvRoot "https://github.com/fardinkazi/healthbooker/blob/main/.env.example"
    click UserRoutes "https://github.com/fardinkazi/healthbooker/blob/main/routes/userRoutes.js"
    click DoctorRoutes "https://github.com/fardinkazi/healthbooker/blob/main/routes/doctorRoutes.js"
    click AppointmentRoutes "https://github.com/fardinkazi/healthbooker/blob/main/routes/appointRoutes.js"
    click NotificationRoutes "https://github.com/fardinkazi/healthbooker/blob/main/routes/notificationRouter.js"
    click UserController "https://github.com/fardinkazi/healthbooker/blob/main/controllers/userController.js"
    click DoctorController "https://github.com/fardinkazi/healthbooker/blob/main/controllers/doctorController.js"
    click AppointmentController "https://github.com/fardinkazi/healthbooker/blob/main/controllers/appointmentController.js"
    click NotificationController "https://github.com/fardinkazi/healthbooker/blob/main/controllers/notificationController.js"
    click UserModel "https://github.com/fardinkazi/healthbooker/blob/main/models/userModel.js"
    click DoctorModel "https://github.com/fardinkazi/healthbooker/blob/main/models/doctorModel.js"
    click AppointmentModel "https://github.com/fardinkazi/healthbooker/blob/main/models/appointmentModel.js"
    click NotificationModel "https://github.com/fardinkazi/healthbooker/blob/main/models/notificationModel.js"
    click DBConn "https://github.com/fardinkazi/healthbooker/blob/main/db/conn.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef database fill:#FFA500,stroke:#333,stroke-width:1px
    classDef middleware fill:#E6E6FA,stroke:#333,stroke-width:1px
    classDef config fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
