# codemanojhv/project architecture

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

- Interactive diagram: https://gitdiagram.com/codemanojhv/project
- Repository: https://github.com/codemanojhv/project

## Overview

##### Project Type and Purpose
- The system offers a user-facing interactive map (built in React) and a backend API (Node.js by default, with a Python alternative) that persists data in SQLite.

##### File Structure
- Top-level split:
- src/ – Frontend React + TypeScript code
- server/ – Primary Node.js backend (index.js + SQLite files)
- backend/ – Alternative Python backend (FastAPI or Flask style)
- public/static files: index.html, netlify.toml, etc.
- Frontend: components/, services/api.ts, constants, types.
- Node backend: single entry (server/index.js) connecting to server/database.sqlite.
- Python backend: routes/, services/, models/, database.py – follows an MVC-like pattern.
- Configuration: Vite, Tailwind, ESLint/Prettier, environment (.env.development/.production).

##### README
- Confirms that the frontend runs on Vite (http://localhost:5173) and the Node API on port 8000.
- Tech stack: React + Leaflet for maps, Node.js + SQLite, and an alternative Python implementation.
- Data flow: hospitals post real-time data → backend stores in SQLite → frontend consumes API to render heatmaps.

##### Main Components & Relationships
a. Frontend (React/Vite/Tailwind/Leaflet)
b. API Layer (Node.js Express)
c. Database (SQLite file)
d. Alternative Backend (Python)
e. External Data Sources (Hospitals, Map tile servers)
f. Dev tooling (Vite dev server, ESLint, Prettier)

Interactions:
- User’s browser ↔ Frontend (HTTP/WS for live updates)
- Frontend → API Layer (REST calls, e.g., /cases, /alerts, /cities)
- API Layer → SQLite (CRUD via ORM or direct queries)
- Optional: Hospitals → API Layer (data ingestion)
- Frontend → Leaflet tile servers (for map base layers)

##### Architectural Patterns & Principles
- Separation of concerns: UI layer vs. API layer vs. data layer
- MVC/MV* style in Python backend (models/services/routes)
- Controller-service pattern in both backends (routes/controllers delegate to services)
- Single-page app (SPA) in the frontend
- Monolithic backend (no microservices) but two interchangeable implementations

##### Must-Include Elements
- Component labels

##### Detail Level
- That the Node.js server uses routes (alerts, cases, cities) which call service classes, which in turn manipulate models and interact with the database.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    Hospitals["Hospitals"]:::ext
    TileServer["Leaflet Tile Server"]:::ext

    %% Frontend Layer
    subgraph "React App" 
        direction TB
        Browser["User Browser"]:::ui
        HTML["index.html"]:::ui
        ViteConfig["vite.config.ts"]:::ui
        TailwindConfig["tailwind.config.js"]:::ui
        PostCSSConfig["postcss.config.js"]:::ui
        MainTSX["src/main.tsx"]:::ui
        AppTSX["src/App.tsx"]:::ui
        ComponentsDir["src/components/"]:::ui
        APIClient["src/services/api.ts"]:::ui
        ConstantsDir["src/constants/"]:::ui
        TypesDir["src/types/"]:::ui
    end

    %% Node.js Backend
    subgraph "Node.js API" 
        direction TB
        ExpressServer["server/index.js"]:::api
        SQLiteDB["SQLite DB\n(server/database.sqlite)"]:::db
    end

    %% Python Backend (Alternative)
    subgraph "Python API (Optional)" 
        direction TB
        class PythonAPI alt
        PythonMain["backend/main.py"]:::alt
        PythonConfig["backend/config.py"]:::alt
        PythonDB["backend/database.py"]:::alt
        PyRoutes["backend/routes/"]:::alt
        PyServices["backend/services/"]:::alt
        PyModels["backend/models/"]:::alt
    end
    class PythonAPI alt

    %% Dev & Deployment Tooling
    subgraph "Dev & Deployment Config" 
        direction TB
        EnvDev[".env.development"]:::tool
        EnvProd[".env.production"]:::tool
        PM2["ecosystem.config.js"]:::tool
        Netlify["netlify.toml"]:::tool
        RenderYAML["render.yaml"]:::tool
        Vercel["vercel.json"]:::tool
        PackageJSON["package.json"]:::tool
        PackageLock["package-lock.json"]:::tool
        TSConfig["tsconfig.json"]:::tool
        TSConfigNode["tsconfig.node.json"]:::tool
        Prettier[".prettierrc"]:::tool
        GitIgnore[".gitignore"]:::tool
    end

    %% Connections
    Hospitals -->|POST data| ExpressServer
    Browser -->|loads| HTML
    Browser -->|runs SPA| MainTSX
    Browser -->|interacts| AppTSX
    AppTSX -->|imports| ComponentsDir
    AppTSX -->|calls API| APIClient
    APIClient -->|HTTP requests| ExpressServer
    ExpressServer -->|CRUD| SQLiteDB
    Browser -->|fetch tiles| TileServer
    %% Optional Python alternate
    APIClient -.->|alternate| PythonMain
    PythonMain -->|uses| PythonDB
    PythonMain -->|routes| PyRoutes
    PyRoutes -->|logic| PyServices
    PyServices -->|models| PyModels
    %% Dev tooling references
    HTML -->|config| ViteConfig
    ViteConfig -->|plugins| TailwindConfig
    ViteConfig -->|plugins| PostCSSConfig
    MainTSX -->|types| TypesDir
    ComponentsDir -->|constants| ConstantsDir

    %% Click Events
    click HTML "https://github.com/codemanojhv/project/blob/main/index.html"
    click ViteConfig "https://github.com/codemanojhv/project/blob/main/vite.config.ts"
    click TailwindConfig "https://github.com/codemanojhv/project/blob/main/tailwind.config.js"
    click PostCSSConfig "https://github.com/codemanojhv/project/blob/main/postcss.config.js"
    click MainTSX "https://github.com/codemanojhv/project/blob/main/src/main.tsx"
    click AppTSX "https://github.com/codemanojhv/project/blob/main/src/App.tsx"
    click ComponentsDir "https://github.com/codemanojhv/project/tree/main/src/components/"
    click APIClient "https://github.com/codemanojhv/project/blob/main/src/services/api.ts"
    click ConstantsDir "https://github.com/codemanojhv/project/blob/main/src/constants/diseases.ts"
    click TypesDir "https://github.com/codemanojhv/project/blob/main/src/types.ts"
    click ExpressServer "https://github.com/codemanojhv/project/blob/main/server/index.js"
    click SQLiteDB "https://github.com/codemanojhv/project/blob/main/server/database.sqlite"
    click PythonMain "https://github.com/codemanojhv/project/blob/main/backend/main.py"
    click PythonConfig "https://github.com/codemanojhv/project/blob/main/backend/config.py"
    click PythonDB "https://github.com/codemanojhv/project/blob/main/backend/database.py"
    click PyRoutes "https://github.com/codemanojhv/project/tree/main/backend/routes/"
    click PyServices "https://github.com/codemanojhv/project/tree/main/backend/services/"
    click PyModels "https://github.com/codemanojhv/project/tree/main/backend/models/"
    click EnvDev "https://github.com/codemanojhv/project/blob/main/.env.development"
    click EnvProd "https://github.com/codemanojhv/project/blob/main/.env.production"
    click PM2 "https://github.com/codemanojhv/project/blob/main/ecosystem.config.js"
    click Netlify "https://github.com/codemanojhv/project/blob/main/netlify.toml"
    click RenderYAML "https://github.com/codemanojhv/project/blob/main/render.yaml"
    click Vercel "https://github.com/codemanojhv/project/blob/main/vercel.json"
    click PackageJSON "https://github.com/codemanojhv/project/blob/main/package.json"
    click PackageLock "https://github.com/codemanojhv/project/blob/main/package-lock.json"
    click TSConfig "https://github.com/codemanojhv/project/blob/main/tsconfig.json"
    click TSConfigNode "https://github.com/codemanojhv/project/blob/main/tsconfig.node.json"
    click Prettier "https://github.com/codemanojhv/project/blob/main/.prettierrc"
    click GitIgnore "https://github.com/codemanojhv/project/blob/main/.gitignore"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#3498DB
    classDef api fill:#D5F5E3,stroke:#27AE60
    classDef db fill:#FDEBD0,stroke:#E67E22
    classDef ext fill:#E5E7E9,stroke:#7F8C8D
    classDef alt fill:#F5EEF8,stroke:#9B59B6,stroke-dasharray: 5 5
    classDef tool fill:#EBF5FB,stroke:#5DADE2
```
