# swalih-vk/live-production-tracking-app architecture

> Architecture diagram of the GitHub repository swalih-vk/live-production-tracking-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/swalih-vk/live-production-tracking-app
- Repository: https://github.com/swalih-vk/live-production-tracking-app

## Overview

##### What this project is (type + purpose)
From the README and file tree, this is a **small Python application** whose purpose is **tracking “Live Production”**.

Indicators:
- `live_app.py` as the only code file strongly suggests a **single-entrypoint Python app** (likely a script or a lightweight web app).
- No `src/`, `tests/`, `frontend/`, `docker/`, or infra directories: architecture is likely **monolithic and minimal**.
- Two dependency manifests: `requirements.txt` (standard) and `requirements.text` (possibly a typo/duplicate). Dependencies will be the main clue to whether this is a CLI, Flask/FastAPI web server, Streamlit dashboard, etc.

##### Files
- **`live_app.py`**
- Runtime mode:
- Web server? (look for `Flask(...)`, `FastAPI()`, `uvicorn.run`, `streamlit`, `dash`, etc.)
- CLI? (look for `argparse`, `click`, a `main()` entrypoint)
- Desktop? (Tkinter/PyQt)
- I/O and integrations:
- Reads/writes files (CSV/Excel/JSON)?
- Database access (sqlite/postgres connectors)?
- External APIs (requests, websocket, MQTT, OPC-UA, etc.)?
- Real-time aspects (threads/asyncio/websockets)?
- Internal modules (even within one file):
- Data model / production entities
- Business logic (calculations, aggregation)
- Presentation layer (web routes/UI functions)
- Persistence layer (db/file functions)
- **`requirements.txt`** (and possibly `requirements.text`)
- Use it to infer major components:
- `flask`, `fastapi`, `django`, `streamlit`, `dash` → UI/API container
- `pandas` → data processing/reporting
- `sqlalchemy`, `psycopg2`, `sqlite3` → database/persistence
- `requests` → outbound API calls
- `websockets`, `paho-mqtt` → live data ingestion
- **`README.md`**
- It’s minimal; treat it as “purpose only,” not architecture.

*who* uses the app and *what* external systems it depends on.

App as a container (Python runtime) and any data stores / external services it connects to.

Since everything is likely in one file, break it into **logical components** (even if not separate modules). This is where you “separate the project into as many components as possible” while staying truthful.

##### Architectural patterns to highlight (likely patterns here)
Given the single-file structure, the pattern is likely:
- **Monolith / single-process app**
- Presentation (UI/API)
- Application/Domain logic
- Infrastructure (persistence/external integrations)

If the code uses callbacks/event loops:

- a real file (`live_app.py`) OR
- a clearly identifiable logical subsystem in that file (functions/classes) OR
- a confirmed dependency (from requirements/imports)
- a real call (db query, HTTP request, file read/write) OR
- a real runtime interaction (user input → state update)
- No unverified databases/services are depicted without “TBD/confirm” labels.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================
    %% System Context (C4 L1)
    %% =========================
    subgraph "System Context (C4 Level 1)"
        direction TB

        Operator["Production Operator / Supervisor\n(Primary User)"]:::actor
        Admin["Admin / Engineer\n(Config & Troubleshooting)\n(Optional)"]:::actor

        App["Live Production Tracking App\n(Python; single-entrypoint)"]:::app

        ExtClient["Client Interface\n(TBD: Browser / CLI / Desktop)"]:::external
        ExtData["Production Data Source\n(TBD: Machines/PLC/Sensors/Files/API)"]:::external
        ExtNotify["Notification / Messaging\n(TBD: Email/SMS/Slack)"]:::external

        Operator -->|"uses"| ExtClient
        Admin -->|"configures/operates"| ExtClient
        ExtClient -->|"invokes UI actions (TBD: HTTP/CLI/UI events)"| App

        ExtData -->|"live signals / inputs (TBD: polling/stream)"| App
        App -->|"alerts/notifications (optional)"| ExtNotify
    end

    %% =========================
    %% Container View (C4 L2)
    %% =========================
    subgraph "Container View (C4 Level 2)"
        direction TB

        PyRuntime["Python Runtime\n(executes live_app.py)"]:::app
        App -->|"runs as"| PyRuntime

        Persist["Persistence\n(TBD: none / local files / SQLite / external DB)"]:::datastore
        InMem["In-Memory State\n(if no persistence)"]:::datastore

        ExtAPI["External Services\n(TBD: MES/ERP/APIs)"]:::external

        PyRuntime -->|"reads/writes (TBD: file I/O / DB driver)"| Persist
        PyRuntime -->|"stores current session/state"| InMem
        PyRuntime -->|"outbound calls (TBD: requests/websocket/MQTT/etc.)"| ExtAPI
    end

    %% =========================
    %% Component View (C4 L3) - within live_app.py
    %% =========================
    subgraph "Component View (C4 Level 3) - live_app.py (logical components)"
        direction TB

        subgraph "Presentation Layer (TBD)"
            direction TB
            UI["UI / API Layer\n(TBD: Flask/FastAPI/Streamlit/CLI callbacks)"]:::component
        end

        subgraph "Application / Domain Layer"
            direction TB
            Domain["Production Domain Logic\n(KPIs, counts, downtime, throughput)"]:::component
            Scheduler["Scheduling / Real-time Loop\n(TBD: polling/async/threads)"]:::component
        end

        subgraph "Infrastructure Layer"
            direction TB
            Ingest["Ingestion / Data Collection\n(TBD: operator input + machine signals)"]:::component
            Repo["Persistence / Repository Adapter\n(save/load events, config)"]:::component
            Report["Reporting / Export\n(dashboard summaries, CSV/Excel)"]:::component
            Auth["AuthN / AuthZ\n(only if present)"]:::component
        end

        %% Internal flows
        UI -->|"Production actions → ProductionEvent {timestamp,line_id,count,reason}"| Domain
        Ingest -->|"signals → ProductionEvent"| Domain
        Scheduler -->|"tick/trigger updates"| Domain

        Domain -->|"persist events / load current state"| Repo
        Domain -->|"KPI Snapshot {OEE,throughput,downtime}"| Report
        Report -->|"renders/exports results"| UI

        Auth -->|"guards UI/API actions (if implemented)"| UI
    end

    %% =========================
    %% Explicit Unknowns / TBD Callouts
    %% =========================
    subgraph "Unknowns to Confirm (from imports + I/O in live_app.py and requirements*.txt)"
        direction TB
        Unknowns["TBD / Confirm:\n- UI type (web vs CLI vs desktop)\n- Persistence (files vs SQLite vs none)\n- External integrations (MQTT/OPC-UA/REST/etc.)\n- Real-time mechanism (loop/async/threads)\n- Auth (present or absent)"]:::note
        Evidence["Evidence Sources:\n- live_app.py\n- requirements.txt\n- requirements.text\n- README.md (purpose only)"]:::note
    end

    %% Tie unknowns to main artifacts
    Unknowns --- App
    Evidence --- App

    %% =========================
    %% Click Events (from component_mapping)
    %% =========================
    click App "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click PyRuntime "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click UI "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click Domain "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click Scheduler "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click Ingest "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click Repo "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click Report "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"
    click Auth "https://github.com/swalih-vk/live-production-tracking-app/blob/main/live_app.py"

    click Evidence "https://github.com/swalih-vk/live-production-tracking-app/blob/main/README.md"
    click Unknowns "https://github.com/swalih-vk/live-production-tracking-app/blob/main/README.md"

    click Persist "https://github.com/swalih-vk/live-production-tracking-app/blob/main/requirements.txt"
    click ExtAPI "https://github.com/swalih-vk/live-production-tracking-app/blob/main/requirements.txt"
    click ExtClient "https://github.com/swalih-vk/live-production-tracking-app/blob/main/requirements.txt"
    click ExtData "https://github.com/swalih-vk/live-production-tracking-app/blob/main/requirements.txt"
    click ExtNotify "https://github.com/swalih-vk/live-production-tracking-app/blob/main/requirements.txt"

    click Persist "https://github.com/swalih-vk/live-production-tracking-app/blob/main/requirements.text"
    click ExtAPI "https://github.com/swalih-vk/live-production-tracking-app/blob/main/requirements.text"

    %% =========================
    %% Styles
    %% =========================
    classDef actor fill:#E5E7EB,stroke:#6B7280,color:#111827,stroke-width:1px
    classDef app fill:#1D4ED8,stroke:#0B2E87,color:#FFFFFF,stroke-width:1px
    classDef component fill:#2563EB,stroke:#0B2E87,color:#FFFFFF,stroke-width:1px
    classDef datastore fill:#16A34A,stroke:#0B6B2A,color:#FFFFFF,stroke-width:1px
    classDef external fill:#F59E0B,stroke:#B45309,color:#111827,stroke-width:1px
    classDef note fill:#FEF3C7,stroke:#D97706,color:#111827,stroke-width:1px
```
