# armanshaikh-2001/nextincare architecture

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

- Interactive diagram: https://gitdiagram.com/armanshaikh-2001/nextincare
- Repository: https://github.com/armanshaikh-2001/nextincare

## Overview

##### Project type and purpose
- NextInCare is a browser-based clinic assistant web app. There is no traditional backend API or cloud database: all data lives in the browser (IndexedDB) and the app is served as static files (HTML/CSS/JS) from a simple static server.

##### File structure
- Top-level files:
- index.html, booking.html, queue.html – three entry points/pages
- css/ – styles.css (core styles), themes.css (light/dark themes)
- js/ – four ES modules:
- db.js – all IndexedDB interactions
- booking.js – logic for the appointment form
- queue.js – logic to fetch and render the live queue
- ui.js – theme toggle and general UI utilities
- assets/logo.svg – static asset
- No server-side code; deployment is “npx serve” or “live-server.”

##### README for additional insights
- Tech stack: HTML, CSS, JavaScript (ES Modules), IndexedDB, Static Server
- Data flow: patient fills form → auto-ID/time → saved to IndexedDB → slip displayed → queue board reads from IndexedDB
- Future: admin dashboard, PDF/print, PWA, etc.

##### Main components
a. Static File Server
- Serves HTML, CSS, JS, assets over HTTP(S)
b. Web Browser / Client
- UI Layer (HTML pages + CSS, themes)
- JS Module Layer: booking.js, queue.js, ui.js, db.js
- Local Storage: IndexedDB (“HealthHavenDB”)
c. User (Patient)
- Interacts via browser UI

##### Relationships and data flows
- Browser requests index.html/booking.html/queue.html from Static Server
- HTML loads CSS (styles.css, themes.css) and JS modules (ES import chain)
- booking.js → calls db.js → writes record to IndexedDB
- ui.js renders booking slip with appointment details
- queue.js periodically queries db.js → reads all upcoming appointments → renders live queue board
- ui.js handles theme toggles/user interactions (light/dark mode)

##### Architectural patterns and design principles
- Module separation: Data access (db.js) vs. business logic (booking.js, queue.js) vs. UI concerns (ui.js)
- Single-page modules per HTML entry point (lightweight MVC within each page)
- Client-side persistence via IndexedDB—no remote database or server-side logic

##### Technologies and frameworks
- HTML5, CSS3 (with theme switching)
- Vanilla JavaScript ES Modules
- IndexedDB API for local persistence
- serve / live-server for static hosting

- Clear, self-explanatory component labels

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static Server serving static files
    subgraph "Static Server"
        direction TB
        SS_Index["index.html"]:::static
        SS_Booking["booking.html"]:::static
        SS_Queue["queue.html"]:::static
        SS_Styles["css/styles.css"]:::static
        SS_Themes["css/themes.css"]:::static
        SS_Logo["assets/logo.svg"]:::static
        SS_DBJS["js/db.js"]:::static
        SS_BookingJS["js/booking.js"]:::static
        SS_QueueJS["js/queue.js"]:::static
        SS_UIJS["js/ui.js"]:::static
    end

    %% Browser runtime components
    subgraph "Web Browser" 
        direction TB
        UI["UI Layer<br/>(HTML + CSS + Logo)"]:::runtime
        subgraph "JS Modules"
            direction TB
            BookingJS["booking.js"]:::runtime
            QueueJS["queue.js"]:::runtime
            UIJS["ui.js"]:::runtime
            DBJS["db.js"]:::runtime
        end
        DB["HealthHavenDB<br/>(IndexedDB)"]:::storage
    end

    %% User
    User["Patient"]:::runtime

    %% Data flows
    User -->|"Fill booking form"| BookingJS
    BookingJS -->|"calls ui.js for slip"| UIJS
    BookingJS -->|"Write appointment"| DBJS
    DBJS -->|"Write"| DB
    QueueJS -->|"Read appointments"| DBJS
    DBJS -->|"Read"| DB
    QueueJS -->|"Update UI"| UIJS

    %% Static file serving and loading
    SS_Index -->|"Serve HTML"| UI
    SS_Booking -->|"Serve HTML"| UI
    SS_Queue -->|"Serve HTML"| UI
    SS_Styles -->|"Load CSS"| UI
    SS_Themes -->|"Load CSS"| UI
    SS_Logo -->|"Load Asset"| UI
    SS_DBJS -->|"Load Module"| DBJS
    SS_BookingJS -->|"Load Module"| BookingJS
    SS_QueueJS -->|"Load Module"| QueueJS
    SS_UIJS -->|"Load Module"| UIJS

    %% Module imports
    BookingJS -->|"import db.js"| DBJS
    BookingJS -->|"import ui.js"| UIJS
    QueueJS -->|"import db.js"| DBJS
    QueueJS -->|"import ui.js"| UIJS

    %% Click events for source files
    click SS_Index "https://github.com/armanshaikh-2001/nextincare/blob/main/index.html"
    click SS_Booking "https://github.com/armanshaikh-2001/nextincare/blob/main/booking.html"
    click SS_Queue "https://github.com/armanshaikh-2001/nextincare/blob/main/queue.html"
    click SS_Styles "https://github.com/armanshaikh-2001/nextincare/blob/main/css/styles.css"
    click SS_Themes "https://github.com/armanshaikh-2001/nextincare/blob/main/css/themes.css"
    click SS_Logo "https://github.com/armanshaikh-2001/nextincare/blob/main/assets/logo.svg"
    click SS_DBJS "https://github.com/armanshaikh-2001/nextincare/blob/main/js/db.js"
    click SS_BookingJS "https://github.com/armanshaikh-2001/nextincare/blob/main/js/booking.js"
    click SS_QueueJS "https://github.com/armanshaikh-2001/nextincare/blob/main/js/queue.js"
    click SS_UIJS "https://github.com/armanshaikh-2001/nextincare/blob/main/js/ui.js"

    %% Styles
    classDef static fill:#cce5ff,stroke:#0056b3,color:#0056b3;
    classDef runtime fill:#d4edda,stroke:#155724,color:#155724;
    classDef storage fill:#fff3cd,stroke:#856404,color:#856404;
```
