# arihantjain-17/doc-appointment architecture

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

- Interactive diagram: https://gitdiagram.com/arihantjain-17/doc-appointment
- Repository: https://github.com/arihantjain-17/doc-appointment

## Overview

##### Project type and purpose
- This is a full-stack appointment-booking application for doctors and patients.
- The Frontend is a React (Vite) single-page app for users/doctors to browse, sign up/in, view profiles, and schedule appointments.
- The Backend is a Node.js/Express REST API that handles authentication, doctor data, and appointment persistence, with file uploads (via Multer) and a database connection.

##### File structure
- Top level:
- BackEnd/ – Express app (controllers, routes, models, middleware, config)
- Frontend/ – Vite-powered React app (components, pages, assets, public)
- BackEnd follows an MVC pattern:
- config/ – database.js (DB connection), multer.js (file upload setup)
- models/ – User, appointment, doctordata
- controller/ – business logic (authController, doctorController, appointment)
- rotues/ – REST endpoints (/auth, /doctor, /appointment)
- middleware/ – authMiddleware (JWT checking)
- uploads/ – directory where Multer stores files
- Frontend separation:
- public/index.html, vite.config.js
- src/pages – top-level page components (Login, Signup, Homepage, DoctorProfile, etc.)
- src/components – reusable UI components (Navbar, DocCard, Calendar, TimePicker)
- src/data – placeholder/mock data
- README gives local run instructions (npm run dev in Frontend, node index.js in BackEnd).

a. Client (Browser/SPA)
b. Vite Dev Server (or Static Host in production)
c. Node.js/Express API Server
d. Database (e.g., MongoDB/MySQL – as configured in config/database.js)
e. File Storage (uploads folder on server, or S3 in production)
f. External Services (if any – email/SMS notifications, though not in code now)

##### Relationships and data flow
- User’s browser loads the React SPA from the Vite server/host.
- SPA sends HTTP(S) requests (GET/POST/PUT/DELETE) to Express endpoints:
- /auth/* for login/signup
- /doctor/* for doctor profiles and data
- /appointment/* for scheduling and fetching appointments
- Express middleware authenticates JWT tokens on protected routes.
- Controllers perform CRUD by calling Models, which interact with the database driver.
- Multer middleware processes file uploads (doctor profile pictures), storing them under uploads/.
- Database persists users, doctors, and appointment records.

##### Architectural patterns and design principles
- Layered/MVC pattern on the backend (Routes → Middleware → Controllers → Models → DB)
- Component-based architecture on the frontend (Pages → UI Components → Assets)
- Separation of concerns: authentication, business logic, data access, presentation.
- Stateless RESTful API; JWT for stateless auth.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Presentation Layer)"
        direction TB
        VITE["Vite Dev Server"]:::frontend
        SPA["React SPA"]:::frontend
        subgraph "Pages"
            direction TB
            HP["Homepage.jsx"]:::frontend
            LP["Landingpage.jsx"]:::frontend
            Login["LoginPage.jsx"]:::frontend
            Signup["SignupPage.jsx"]:::frontend
            DocProf["DoctorProfile.jsx"]:::frontend
            DocLogin["DoctorLoginPage.jsx"]:::frontend
            DocSignup["DoctorSignupPage.jsx"]:::frontend
            UserProf["Userprofile.jsx"]:::frontend
            DocPage["Docpage.jsx"]:::frontend
        end
        subgraph "Components"
            direction TB
            Nav["Navbar.jsx"]:::frontend
            Card["DocCard.jsx"]:::frontend
            Search["SearchBar.jsx"]:::frontend
            Side["Sidebar.jsx"]:::frontend
            Cal["Calendar.jsx"]:::frontend
            CalBody["CalendarBody.jsx"]:::frontend
            TP["TimePickerPopup.jsx"]:::frontend
            UPW["UserProfile.jsx"]:::frontend
        end
        Assets["Assets & Data"]:::frontend
        Public["index.html"]:::frontend
        VITE -->|Serves SPA| SPA
        SPA -->|Renders Pages| HP & LP & Login & Signup & DocProf & DocLogin & DocSignup & UserProf & DocPage
        SPA -->|Uses Components| Nav & Card & Search & Side & Cal & CalBody & TP & UPW
        SPA -->|"GET index.html"| Public
        SPA -->|"Static assets & data"| Assets
    end

    %% Backend Layer
    subgraph "Backend (Business Logic Layer)"
        direction TB
        Entry["index.js"]:::backendLogic
        subgraph "Config"
            DBConfig["database.js"]:::backendLogic
            MulterConf["multer.js"]:::backendLogic
            Env[".env"]:::backendLogic
        end
        subgraph "Routes"
            AuthRoute["/auth"]:::backendLogic
            DocRoute["/doctor"]:::backendLogic
            AppRoute["/appointment"]:::backendLogic
        end
        subgraph "Middleware"
            AuthMW["authMiddleware.js"]:::backendLogic
        end
        subgraph "Controllers"
            AuthCtrl["authController.js"]:::backendLogic
            DocCtrl["doctorController.js"]:::backendLogic
            DocDataCtrl["doctordata.js"]:::backendLogic
            AppCtrl["appointment.js"]:::backendLogic
        end
        subgraph "Models"
            UserModel["User.js"]:::data
            DocDataModel["doctordata.js"]:::data
            AppModel["appointment.js"]:::data
        end
        Uploads["uploads/"]:::storage

        Entry -->|Loads config| DBConfig & MulterConf & Env
        Entry -->|Defines routes| AuthRoute & DocRoute & AppRoute
        AuthRoute -->|Uses middleware| AuthMW
        DocRoute -->|Uses middleware| AuthMW
        AppRoute -->|Uses middleware| AuthMW
        AuthRoute -->|Calls| AuthCtrl
        DocRoute -->|Calls| DocCtrl & DocDataCtrl
        AppRoute -->|Calls| AppCtrl
        AuthCtrl -->|CRUD| UserModel
        DocCtrl -->|CRUD| DocDataModel
        DocDataCtrl -->|CRUD| DocDataModel
        AppCtrl -->|CRUD| AppModel
        DocCtrl -->|Uploads files| MulterConf & Uploads
        Models -->|Persist| DB[(Database)]:::data
    end

    %% Interactions
    Browser["User Browser"]:::frontend
    Browser -->|HTTP GET| VITE
    SPA -->|HTTPS/JSON| AuthRoute
    SPA -->|HTTPS/JSON| DocRoute
    SPA -->|HTTPS/JSON| AppRoute

    Entry -->|Connects| DB
    Entry -->|Stores/Retrieves files| Uploads

    %% Legend
    classDef frontend fill:#D0E8FF,stroke:#000,stroke-width:1px;
    classDef backendLogic fill:#D4F5D4,stroke:#000,stroke-width:1px;
    classDef data fill:#FFD4A3,stroke:#000,stroke-width:1px;
    classDef storage fill:#E0E0E0,stroke:#000,stroke-width:1px;

    %% Click Events Frontend
    click SPA "https://github.com/arihantjain-17/doc-appointment/tree/main/Frontend/src"
    click VITE "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/vite.config.js"
    click Public "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/index.html"
    click HP "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/Homepage.jsx"
    click LP "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/Landingpage.jsx"
    click Login "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/LoginPage.jsx"
    click Signup "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/SignupPage.jsx"
    click DocProf "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/DoctorProfile.jsx"
    click DocLogin "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/DoctorLoginPage.jsx"
    click DocSignup "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/DoctorSignupPage.jsx"
    click UserProf "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/Userprofile.jsx"
    click DocPage "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/pages/Docpage.jsx"
    click Nav "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/Landingpage/Navbar.jsx"
    click Card "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/Landingpage/DocCard.jsx"
    click Search "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/Landingpage/SearchBar.jsx"
    click Side "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/Landingpage/Sidebar.jsx"
    click Cal "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/DoctorPage/Calendar.jsx"
    click CalBody "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/DoctorPage/CalendarBody.jsx"
    click TP "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/DoctorPage/TimePickerPopup.jsx"
    click UPW "https://github.com/arihantjain-17/doc-appointment/blob/main/Frontend/src/components/UserPage/UserProfile.jsx"
    click Assets "https://github.com/arihantjain-17/doc-appointment/tree/main/Frontend/src/assets"
    click Assets "https://github.com/arihantjain-17/doc-appointment/tree/main/Frontend/src/data"

    %% Click Events Backend
    click Entry "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/index.js"
    click Env "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/.env"
    click DBConfig "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/config/database.js"
    click MulterConf "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/config/multer.js"
    click AuthRoute "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/rotues/auth.js"
    click AuthCtrl "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/controller/authController.js"
    click AuthMW "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/middleware/authMiddleware.js"
    click UserModel "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/models/User.js"
    click DocRoute "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/rotues/doctor.js"
    click DocCtrl "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/controller/doctorController.js"
    click DocDataCtrl "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/controller/doctordata.js"
    click DocDataModel "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/models/doctordata.js"
    click AppRoute "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/rotues/appointment.js"
    click AppCtrl "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/controller/appointment.js"
    click AppModel "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/models/appointment.js"
    click Uploads "https://github.com/arihantjain-17/doc-appointment/tree/main/BackEnd/uploads"
    click DB "https://github.com/arihantjain-17/doc-appointment/blob/main/BackEnd/config/database.js"
```
