# decalnguyen/htnkgda architecture

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

- Interactive diagram: https://gitdiagram.com/decalnguyen/htnkgda
- Repository: https://github.com/decalnguyen/htnkgda

## Overview

##### Project Type and Purpose
- Full-stack web application
- Front end serves a static HTML/CSS/JS UI
- Back end (Python) hosts an API, loads a PyTorch model (`my_model.pt`), and returns inference results
- Docker Compose orchestrates the two containers

##### File Structure
Top-level:
- docker-compose.yml → orchestration of Frontend and Backend services
- Backend/
- Dockerfile → builds the Python service image
- main.py → application entrypoint, defines API endpoints
- my_model.pt → pre-trained ML model loaded at runtime
- requirements.txt → Python dependencies
- Frontend/
- Dockerfile → builds the static-site container
- HTML, CSS, JS folders → static assets served to the browser
- env.js → front-end configuration (e.g., API base URL)
- mykeypair.pem → certificate or SSH key, likely for secure comms or deployment

##### Extract Additional Insights from README
- Currently minimal; assume standard ML inference API use case

##### Main Components & Their Interactions
a. Components:
1) User’s Web Browser (Client)
2) Frontend Container
– Serves HTML/CSS/JS
– Contains env.js with API endpoint configuration
3) Backend Container
– Flask/FastAPI (or similar) server in main.py
– Loads `my_model.pt` on startup
4) Docker Compose
– Defines and links both containers on a private network
5) Optional: TLS termination or SSH gateway (mykeypair.pem)
b. Interactions / Data Flow:
1) User → HTTP GET → Frontend Container → index.html, CSS, JS
2) Frontend JS → HTTP POST/GET → Backend API (predict endpoint)
3) Backend loads model → runs inference → returns JSON response
4) Frontend JS receives JSON → updates UI
c. Architectural Patterns & Principles:
– Two-tier (client and server) architecture
– Containerization for isolation and reproducible environments
– Separation of concerns: static assets vs. application logic vs. model artifact
d. Key Technologies & Frameworks:
– Docker & Docker Compose
– Python web framework (Flask/FastAPI)
– PyTorch inference (`my_model.pt`)
– Vanilla HTML/CSS/JS (no SPA framework indicated)

##### Putting It All Together
– [Frontend Service]
– [Backend Service]

## Diagram (Mermaid)

```mermaid
graph TD
    %% Orchestrator
    DC["Docker Compose"]:::orchestrator

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

    %% Frontend Service and its assets
    subgraph "Frontend Service"
        FE["Frontend Service"]:::frontend
        FE_DOCKER["Dockerfile"]:::infra
        HTML["index.html"]:::frontend
        CSS["index.css"]:::frontend
        JS["index.js"]:::frontend
        ENV["env.js"]:::frontend
    end

    %% Backend Service and its components
    subgraph "Backend Service (Inference API)"
        BE["Backend Service"]:::backend
        BE_DOCKER["Dockerfile"]:::infra
        API["main.py (API)"]:::backend
        REQ["requirements.txt"]:::backend
        MODEL["ML Model\n(my_model.pt)"]:::storage
        TLS["TLS Cert / SSH Key\n(mykeypair.pem)"]:::optional
    end

    %% Connections
    Browser -->|"GET /index.html"| FE
    FE -->|"POST /predict (JSON)"| BE
    BE -->|"200 OK (JSON)"| FE
    FE -->|"Render UI"| Browser

    %% Orchestration link
    DC --> FE
    DC --> BE

    %% Click Events
    click DC "https://github.com/decalnguyen/htnkgda/blob/main/docker-compose.yml"
    click FE_DOCKER "https://github.com/decalnguyen/htnkgda/tree/main/Frontend/Dockerfile"
    click HTML "https://github.com/decalnguyen/htnkgda/blob/main/Frontend/HTML/index.html"
    click CSS "https://github.com/decalnguyen/htnkgda/blob/main/Frontend/CSS/index.css"
    click JS "https://github.com/decalnguyen/htnkgda/blob/main/Frontend/JS/index.js"
    click ENV "https://github.com/decalnguyen/htnkgda/blob/main/env.js"
    click BE_DOCKER "https://github.com/decalnguyen/htnkgda/tree/main/Backend/Dockerfile"
    click API "https://github.com/decalnguyen/htnkgda/blob/main/Backend/main.py"
    click REQ "https://github.com/decalnguyen/htnkgda/blob/main/Backend/requirements.txt"
    click MODEL "https://github.com/decalnguyen/htnkgda/blob/main/Backend/my_model.pt"
    click TLS "https://github.com/decalnguyen/htnkgda/blob/main/mykeypair.pem"

    %% Styling
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef orchestrator fill:#f9f,stroke:#333,stroke-width:1px
    classDef infra fill:#FFE4B5,stroke:#333,stroke-width:1px
    classDef optional fill:#EEEEEE,stroke:#333,stroke-width:1px
```
