# garv-arora/mdlz_cil_tracker_webapp architecture

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

- Interactive diagram: https://gitdiagram.com/garv-arora/mdlz_cil_tracker_webapp
- Repository: https://github.com/garv-arora/mdlz_cil_tracker_webapp

## Overview

##### Project type and purpose
- This is a small full-stack web application (“CIL Tracker”) built with Python/Flask, using server-side templating for the UI, an SQLite database for storage, and static assets (CSS/JS/images). It is intended for deployment behind a production web server or reverse proxy and optionally containerized via Docker.

##### File structure
- Top-level files:
- Dockerfile – container build instructions
- render.yaml – deployment manifest (likely for a PaaS or container orchestrator)
- app.py – Flask application entry point
- database.py – database setup and cleanup logic
- requirements.txt – Python dependencies
- instance/ – holds the SQLite database file (cil_tracker.db)
- templates/ – Jinja2 HTML templates (index.html, etc.)
- static/ – static assets (css/style.css, js/main.js, images/)
- README.md – describes features, deployment steps, configuration, and security considerations.

##### README for additional insights
- The application tracks cleaning/inspection/lubrication sessions, logs start/stop times, enforces 30-day retention, and supports export to CSV/Excel.
- It can run with the built-in Waitress server or Gunicorn, reads configuration from environment variables (host, port, DB path, Flask environment), and is designed to be placed behind Nginx/Apache with HTTPS.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infrastructure Layer
    subgraph "Infrastructure / Deployment"
        Proxy["Nginx / Load Balancer"]:::infra
        PaaS["Deployment Manifest (render.yaml)"]:::infra
        click PaaS "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/render.yaml"
        DockerfileNode["Dockerfile"]:::infra
        click DockerfileNode "https://github.com/garv-arora/mdlz_cil_tracker_webapp/tree/main/Dockerfile"
    end

    %% Container Boundary
    subgraph "Docker Container / VM"
        direction TB
        Env["Environment Variables"]:::config

        WSGI["WSGI Server (Waitress/Gunicorn)"]:::backend

        App["Flask App (app.py)"]:::backend
        click App "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/app.py"

        Config["12-Factor Config"]:::config

        DBModule["Database Module (database.py)"]:::backend
        click DBModule "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/database.py"

        Export["Export Service (CSV/Excel)"]:::backend

        Cleanup["Data Retention Cleanup"]:::backend

        subgraph "Templates & Static Assets"
            direction TB
            Templates["HTML Templates"]:::views
            click Templates "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/templates/index.html"
            CSS["CSS (style.css)"]:::static
            click CSS "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/static/css/style.css"
            JS["JavaScript (main.js)"]:::static
            click JS "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/static/js/main.js"
            Images["Images"]:::static
            click Images "https://github.com/garv-arora/mdlz_cil_tracker_webapp/tree/main/static/images"
        end
    end

    %% Data Store
    DBFile["SQLite DB File"]:::db
    click DBFile "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/instance/cil_tracker.db"

    %% External
    Browser["User Browser"]:::frontend

    %% Relationships
    Browser -->|"HTTP(S) GET/POST"| Proxy
    Proxy -->|"Forward request"| WSGI
    WSGI -->|"Invoke app.py"| App
    Env -->|load| App
    Env -->|load| WSGI
    App -->|"SQL read/write"| DBModule
    DBModule -->|"manages"| DBFile
    DBModule -->|"scheduled purge"| Cleanup
    App -->|"render"| Templates
    App -->|"serve"| CSS
    App -->|"serve"| JS
    App -->|"serve"| Images
    App -->|"Generate CSV/Excel"| Export
    Export -->|stream| Browser

    %% Config & Dependencies
    Config --> App
    PaaS --> DockerfileNode
    DockerfileNode --> App
    DockerfileNode --> DBFile
    DockerfileNode --> WSGI

    requirements["Python Dependencies (requirements.txt)"]:::infra
    click requirements "https://github.com/garv-arora/mdlz_cil_tracker_webapp/blob/main/requirements.txt"
    requirements --> DockerfileNode

    %% Styles
    classDef frontend fill:#b3e6b3,stroke:#2d862d,color:#000
    classDef infra fill:#d9d9d9,stroke:#666,color:#000
    classDef backend fill:#aed6f1,stroke:#21618c,color:#000
    classDef db fill:#f9e79f,stroke:#b9770e,color:#000
    classDef static fill:#e8daef,stroke:#5b2c6f,color:#000
    classDef views fill:#fadbd8,stroke:#922b21,color:#000
    classDef config fill:#f5cba7,stroke:#a04000,color:#000
```
