# genzz-dev/quickclinic architecture

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

- Interactive diagram: https://gitdiagram.com/genzz-dev/quickclinic
- Repository: https://github.com/genzz-dev/quickclinic

## Overview

##### Project Type & Purpose
- This is a full-stack MERN application called QuickClinic that streamlines clinic workflows for three user roles (Admin, Doctor, Patient).
- Frontend: React + Vite + TailwindCSS.
- Backend: Node.js + Express + MongoDB.
- Key features: role-based dashboards, JWT auth, Google Maps integration, geolocation, appointment booking, prescription tracking.

##### High-Level File Structure Analysis
- Top level:
- client/ → Vite-powered React UI (components/, pages/, routes/, service/, context/)
- server/ → Express API (Controllers/, Routes/, Middleware/, models/, services/, config/)
- This separation indicates a classic client ↔ REST API ↔ database architecture.
- Backend follows an MVC-style organization (Controllers → Services → Models) and middleware for auth, uploads, etc.

a. Main Components
- User Clients (Web Browser)
- Frontend App (React + Vite + Tailwind)
- API Gateway (Express Server)
- Business Logic Layer (Controllers & Services)
- Data Layer (MongoDB via Mongoose Models)
- External Services:
– Google Maps API
– IP Geolocation Service
– Email/OTP Service
– Cloudinary or file‐upload service
b. Relationships & Data Flows
1. Browser ↔ Frontend Routes & Components
2. Frontend (service/*) → HTTP(S) calls to Express endpoints with JWT
3. Express Middleware → Authentication & Role-Based Guards
4. Controllers invoke Services → talk to MongoDB (CRUD) and external APIs
5. Services → optional side-effects (send email/OTP, upload files, geocode address)
c. Architectural Patterns
- Client-Server (separate repo for client & server)
- MVC on backend (Controllers → Services → Models)
- Component-based UI with Context for auth state
- Route guards enforce RBAC
- Token-based stateless auth (JWT)
d. Key Technologies
- React, Vite, TailwindCSS
- Express, Mongoose, MongoDB
- JWT (access + refresh)
- Google Maps, IP Geolocation, Email/OTP, Cloudinary

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Web Browser"]:::external
        ReactUI["React UI"]:::frontend
        Components["Components"]:::frontend
        Pages["Pages"]:::frontend
        Routing["Routing & Guards"]:::frontend
        ServicesFE["API Services"]:::frontend
        AuthCtx["Auth Context"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Express["Express Server"]:::backend
        MiddlewareAuth["Auth Middleware"]:::backend
        MiddlewareUpload["Upload Middleware"]:::backend
        Routes["API Routes"]:::backend
        Controllers["Controllers"]:::backend
        ServicesBE["Services"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        MongoDB["MongoDB"]:::database
        Models["Mongoose Models"]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Google["Google Maps API"]:::external
        GeoIP["IP Geolocation"]:::external
        EmailOTP["Email/OTP Service"]:::external
        Cloud["Cloudinary"]:::external
    end

    %% Connections
    Browser -->|"loads"| ReactUI
    ReactUI -->|"uses"| Components
    ReactUI -->|"uses"| Pages
    ReactUI -->|"navigates"| Routing
    Routing -->|"calls"| ServicesFE
    ServicesFE -->|"HTTP"| Express
    Express -->|"validates"| MiddlewareAuth
    MiddlewareAuth -->|"uploads"| MiddlewareUpload
    Express -->|"/api/*"| Routes
    Routes -->|"invoke"| Controllers
    Controllers -->|"business logic"| ServicesBE
    ServicesBE -->|"reads/writes"| Models
    Models -->|"persist"| MongoDB
    ServicesBE -->|"geocode"| Google
    ServicesBE -->|"lookup"| GeoIP
    ServicesBE -->|"send OTP/email"| EmailOTP
    ServicesBE -->|"upload files"| Cloud

    %% Click Events
    click ReactUI "https://github.com/genzz-dev/quickclinic/tree/main/client/src"
    click Components "https://github.com/genzz-dev/quickclinic/tree/main/client/src/components"
    click Pages "https://github.com/genzz-dev/quickclinic/tree/main/client/src/pages"
    click Routing "https://github.com/genzz-dev/quickclinic/tree/main/client/src/routes"
    click Routing "https://github.com/genzz-dev/quickclinic/tree/main/client/src/routes/guards"
    click ServicesFE "https://github.com/genzz-dev/quickclinic/tree/main/client/src/service"
    click AuthCtx "https://github.com/genzz-dev/quickclinic/blob/main/client/src/context/authContext.jsx"
    click Express "https://github.com/genzz-dev/quickclinic/blob/main/server/index.js"
    click Routes "https://github.com/genzz-dev/quickclinic/tree/main/server/Routes"
    click MiddlewareAuth "https://github.com/genzz-dev/quickclinic/blob/main/server/Middleware/authMiddleware.js"
    click MiddlewareUpload "https://github.com/genzz-dev/quickclinic/blob/main/server/Middleware/upload.js"
    click Controllers "https://github.com/genzz-dev/quickclinic/tree/main/server/Controllers"
    click ServicesBE "https://github.com/genzz-dev/quickclinic/tree/main/server/services"
    click Models "https://github.com/genzz-dev/quickclinic/tree/main/server/models"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef backend  fill:#DFF5D0,stroke:#2EA043,color:#2EA043
    classDef database fill:#FFE4B5,stroke:#DB8E00,color:#DB8E00
    classDef external fill:#F3D0FF,stroke:#A259FF,color:#A259FF
    class Browser,Google,GeoIP,EmailOTP,Cloud external
    class ReactUI,Components,Pages,Routing,ServicesFE,AuthCtx frontend
    class Express,MiddlewareAuth,MiddlewareUpload,Routes,Controllers,ServicesBE backend
    class MongoDB,Models database
```
