# abubakar980/doctor-appointment-mern architecture

> Architecture diagram of the GitHub repository abubakar980/doctor-appointment-mern, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abubakar980/doctor-appointment-mern
- Repository: https://github.com/abubakar980/doctor-appointment-mern

## Overview

##### Project type and purpose
- This is a full-stack MERN application for managing doctor appointments. It consists of:
- A public/front-end React app for patients
- A separate admin React app for staff and doctors
- A Node.js/Express backend REST API
- A MongoDB database
- External services (Cloudinary for image uploads)

##### File structure
- Top-level “frontend” directory: patient-facing React app (pages for Home, Login, Appointments, Profile, etc.).
- Top-level “admin” directory: admin/doctor dashboard React app (pages for Dashboard, AddDoctors, Appointments, etc.).
- “backend” directory: Express server, controllers, routes, models, middleware, plus config for MongoDB and Cloudinary.
- Shared assets in “assets” folder (PDF, images, static JS).
- Configuration files: package.json, vite.config.js, eslint.config.js.

##### Elements
- User actions → API endpoints (e.g., GET /appointments, POST /login)
- API → Database (find, insert, update)
- API → Cloudinary (upload image)
- Green for frontends
- Blue for backend components
- Purple for database
- Orange for external services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontends"
        PatientFrontend["Patient Frontend"]:::frontend
        AdminFrontend["Admin Frontend"]:::frontend
    end

    %% Assets
    subgraph "Shared Assets"
        AssetsFrontend["Shared Frontend Assets"]:::frontend
        AssetsAdmin["Shared Admin Assets"]:::frontend
    end

    AssetsFrontend -->|serves static files| PatientFrontend
    AssetsAdmin -->|serves static files| AdminFrontend

    %% API Layer
    subgraph "API Server"
        Server["Express Server"]:::backend

        %% Routes
        subgraph "Routes"
            UserRoutes["userRoute"]:::backend
            DoctorRoutes["doctorRoute"]:::backend
            AdminRoutes["adminRoute"]:::backend
        end

        %% Middleware
        subgraph "Middleware"
            AuthUser["authUser Middleware"]:::backend
            AuthDoctor["authDoctor Middleware"]:::backend
            AuthAdmin["authAdmin Middleware"]:::backend
            Multer["Multer Middleware"]:::backend
        end

        %% Controllers
        subgraph "Controllers"
            UserCtrl["User Controller"]:::backend
            DoctorCtrl["Doctors Controller"]:::backend
            AdminCtrl["Admin Controller"]:::backend
        end

        %% Models
        subgraph "Models"
            UserModel["User Model"]:::backend
            DoctorModel["Doctor Model"]:::backend
            AppointmentModel["Appointment Model"]:::backend
        end

        %% Config
        subgraph "Configurations"
            MongoDBConfig["MongoDB Config"]:::backend
            CloudinaryConfig["Cloudinary Config"]:::backend
        end
    end

    %% Database and External
    MongoDB[(MongoDB Database)]:::database
    Cloudinary["Cloudinary Service"]:::external

    %% Connections
    PatientFrontend -->|HTTPS Requests| Server
    AdminFrontend -->|HTTPS Requests| Server

    Server --> UserRoutes
    Server --> DoctorRoutes
    Server --> AdminRoutes

    UserRoutes --> AuthUser
    DoctorRoutes --> AuthDoctor
    AdminRoutes --> AuthAdmin

    AuthUser --> UserCtrl
    AuthDoctor --> DoctorCtrl
    AuthAdmin --> AdminCtrl

    UserRoutes --> Multer
    DoctorRoutes --> Multer

    Multer --> CloudinaryConfig
    CloudinaryConfig --> Cloudinary

    UserCtrl --> UserModel
    DoctorCtrl --> DoctorModel
    AdminCtrl --> AppointmentModel

    UserModel --> MongoDB
    DoctorModel --> MongoDB
    AppointmentModel --> MongoDB
    MongoDBConfig --> MongoDB

    %% Click Events
    click PatientFrontend "https://github.com/abubakar980/doctor-appointment-mern/tree/main/frontend/"
    click AdminFrontend "https://github.com/abubakar980/doctor-appointment-mern/tree/main/admin/"
    click Server "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/server.js"
    click UserRoutes "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/routes/userRoute.js"
    click DoctorRoutes "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/routes/doctorRoute.js"
    click AdminRoutes "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/routes/adminRoute.js"
    click UserCtrl "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/controllers/userController.js"
    click DoctorCtrl "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/controllers/doctorsController.js"
    click AdminCtrl "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/controllers/adminController.js"
    click UserModel "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/models/userModel.js"
    click DoctorModel "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/models/doctorModel.js"
    click AppointmentModel "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/models/appointmentModel.js"
    click AuthUser "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/middlewares/authUser.js"
    click AuthDoctor "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/middlewares/authDoctor.js"
    click AuthAdmin "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/middlewares/authAdmin.js"
    click Multer "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/middlewares/multer.js"
    click MongoDBConfig "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/config/mongodb.js"
    click CloudinaryConfig "https://github.com/abubakar980/doctor-appointment-mern/blob/main/backend/config/cloudinary.js"
    click AssetsFrontend "https://github.com/abubakar980/doctor-appointment-mern/blob/main/assets/assets_frontend/assets.js"
    click AssetsAdmin "https://github.com/abubakar980/doctor-appointment-mern/blob/main/assets/assets_admin/assets.js"

    %% Styles
    classDef frontend fill:#a2f5a2,stroke:#333,stroke-width:1px
    classDef backend fill:#a2d1f5,stroke:#333,stroke-width:1px
    classDef database fill:#d1a2f5,stroke:#333,stroke-width:1px
    classDef external fill:#f5cba2,stroke:#333,stroke-width:1px
```
