# smartwolly5-afk/5_final architecture

> Architecture diagram of the GitHub repository smartwolly5-afk/5_final, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/smartwolly5-afk/5_final
- Repository: https://github.com/smartwolly5-afk/5_final

## Overview

TANK is a Flask/MySQL prototype for video-derived armored-vehicle threat assessment and a separate tank-specification dictionary. The principal workflow accepts detections, aggregates frame-level tracks, classifies known/variant/unknown vehicles, computes threat and cluster response levels, then serves dashboard APIs and reports; unknown sightings can be grouped across videos. The dictionary independently serves searchable country, family, and variant views from tank_specs. The graph follows README documentation and shown imports/calls; several dashboard internals are only partially excerpted, so uncertain links are omitted.

Main entry points: [`dashboard/__init__.py`](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/__init__.py) (Dashboard routes), [`app.py`](https://github.com/smartwolly5-afk/5_final/blob/main/app.py) (Flask app), [`dashboard/threat/pipeline.py`](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/pipeline.py) (Analysis pipeline), [`dictionary.py`](https://github.com/smartwolly5-afk/5_final/blob/main/dictionary.py) (Dictionary routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask app<br/>[app.py]"]
  node_dashboard["Dashboard routes<br/>[__init__.py]"]
  node_dashboard_ui["Dashboard UI"]
  node_dashboard_js["Dashboard client<br/>[dashboard.js]"]
  node_report_ui["Report view<br/>[report.html]"]
  node_unknown_ui["Unknown browser<br/>[unknowns.js]"]
  node_threat_api["Threat API<br/>[threat_api.py]"]
end

subgraph group_analysis["Threat analysis"]
  node_pipeline["Analysis pipeline<br/>[pipeline.py]"]
  node_tracking["Track aggregation<br/>[track.py]"]
  node_judging["Vehicle identification<br/>[judge.py]"]
  node_threat_core["Vehicle threat score<br/>[core.py]"]
  node_response_adapter["Response adapter<br/>[adapter.py]"]
  node_response_engine["Cluster response level<br/>[response_level.py]"]
  node_crop["Track crops<br/>[media.py]"]
  node_unknown_registry["Unknown registry"]
end

subgraph group_data["Persistence"]
  node_threat_db["Threat data access<br/>[threat_db.py]"]
  node_mysql[("MySQL / SQLite")]
  node_db_access["MySQL access<br/>[db.py]"]
  node_tank_specs[("Tank specifications<br/>[schema.sql]")]
  node_threat_schema[("Threat records<br/>[schema_threat.sql]")]
end

subgraph group_dictionary["Tank dictionary"]
  node_dictionary_routes["Dictionary routes<br/>[dictionary.py]"]
  node_dictionary_views["Dictionary pages"]
  node_threat_calc["Dictionary threat calculations<br/>[threat_calc.py]"]
end

node_user(("Analyst"))
node_detector(("Detector input"))

node_user -->|"uses"| node_app
node_detector -->|"submits detections"| node_dashboard
node_app -->|"registers routes"| node_dashboard
node_app -->|"registers routes"| node_dictionary_routes
node_app -->|"registers routes"| node_threat_api
node_dashboard -->|"analyzes payload"| node_pipeline
node_pipeline -->|"aggregates tracks"| node_tracking
node_pipeline -->|"judges tracks"| node_judging
node_judging -->|"scores vehicles"| node_threat_core
node_pipeline -->|"adapts results"| node_response_adapter
node_response_adapter -->|"assesses clusters"| node_response_engine
node_dashboard -->|"saves representative crops"| node_crop
node_dashboard -->|"stores unknown sightings"| node_unknown_registry
node_unknown_registry -->|"reads and writes"| node_threat_db
node_dashboard -->|"renders"| node_dashboard_ui
node_dashboard_ui -->|"loads client"| node_dashboard_js
node_dashboard_js -->|"calls analysis APIs"| node_dashboard
node_dashboard -->|"renders report"| node_report_ui
node_unknown_ui -->|"uses unknown APIs"| node_dashboard
node_threat_api -->|"uses response rules"| node_response_engine
node_threat_api -->|"reads threat data"| node_threat_db
node_response_engine -->|"records assessments"| node_threat_db
node_threat_db -->|"connects"| node_mysql
node_dictionary_routes -->|"queries data"| node_db_access
node_dictionary_routes -->|"uses calculations"| node_threat_calc
node_dictionary_routes -->|"renders pages"| node_dictionary_views
node_db_access -->|"opens connection"| node_mysql
node_mysql -.->|"stores specifications"| node_tank_specs
node_mysql -.->|"stores assessment records"| node_threat_schema

click node_app "https://github.com/smartwolly5-afk/5_final/blob/main/app.py"
click node_dashboard "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/__init__.py"
click node_dashboard_ui "https://github.com/smartwolly5-afk/5_final/tree/main/dashboard/templates/dashboard"
click node_dashboard_js "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/static/dashboard.js"
click node_report_ui "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/templates/dashboard/report.html"
click node_unknown_ui "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/static/unknowns.js"
click node_pipeline "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/pipeline.py"
click node_tracking "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/track.py"
click node_judging "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/judge.py"
click node_threat_core "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/core.py"
click node_response_adapter "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/adapter.py"
click node_response_engine "https://github.com/smartwolly5-afk/5_final/blob/main/response_level.py"
click node_crop "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/media.py"
click node_unknown_registry "https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/unknown_registry.py"
click node_threat_api "https://github.com/smartwolly5-afk/5_final/blob/main/threat_api.py"
click node_threat_db "https://github.com/smartwolly5-afk/5_final/blob/main/threat_db.py"
click node_dictionary_routes "https://github.com/smartwolly5-afk/5_final/blob/main/dictionary.py"
click node_dictionary_views "https://github.com/smartwolly5-afk/5_final/tree/main/templates/dictionary"
click node_db_access "https://github.com/smartwolly5-afk/5_final/blob/main/db.py"
click node_tank_specs "https://github.com/smartwolly5-afk/5_final/blob/main/schema.sql"
click node_threat_schema "https://github.com/smartwolly5-afk/5_final/blob/main/schema_threat.sql"
click node_threat_calc "https://github.com/smartwolly5-afk/5_final/blob/main/threat_calc.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_dashboard,node_dashboard_ui,node_dashboard_js,node_report_ui,node_unknown_ui,node_threat_api toneBlue
class node_pipeline,node_tracking,node_judging,node_threat_core,node_response_adapter,node_response_engine,node_crop,node_unknown_registry toneAmber
class node_threat_db,node_mysql,node_db_access,node_tank_specs,node_threat_schema toneMint
class node_dictionary_routes,node_dictionary_views,node_threat_calc toneRose
class node_user,node_detector toneIndigo
```

## Components

### Web application

- [Flask app](https://github.com/smartwolly5-afk/5_final/blob/main/app.py): `app.py`
- [Dashboard routes](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/__init__.py): `dashboard/__init__.py`
- [Dashboard UI](https://github.com/smartwolly5-afk/5_final/tree/main/dashboard/templates/dashboard): `dashboard/templates/dashboard`
- [Dashboard client](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/static/dashboard.js): `dashboard/static/dashboard.js`
- [Report view](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/templates/dashboard/report.html): `dashboard/templates/dashboard/report.html`
- [Unknown browser](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/static/unknowns.js): `dashboard/static/unknowns.js`
- [Threat API](https://github.com/smartwolly5-afk/5_final/blob/main/threat_api.py): `threat_api.py`

### Threat analysis

- [Analysis pipeline](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/pipeline.py): `dashboard/threat/pipeline.py`
- [Track aggregation](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/track.py): `dashboard/threat/track.py`
- [Vehicle identification](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/judge.py): `dashboard/threat/judge.py`
- [Vehicle threat score](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/core.py): `dashboard/threat/core.py`
- [Response adapter](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/threat/adapter.py): `dashboard/threat/adapter.py`
- [Cluster response level](https://github.com/smartwolly5-afk/5_final/blob/main/response_level.py): `response_level.py`
- [Track crops](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/media.py): `dashboard/media.py`
- [Unknown registry](https://github.com/smartwolly5-afk/5_final/blob/main/dashboard/unknown_registry.py): `dashboard/unknown_registry.py`

### Persistence

- [Threat data access](https://github.com/smartwolly5-afk/5_final/blob/main/threat_db.py): `threat_db.py`
- **MySQL / SQLite**
- [MySQL access](https://github.com/smartwolly5-afk/5_final/blob/main/db.py): `db.py`
- [Tank specifications](https://github.com/smartwolly5-afk/5_final/blob/main/schema.sql): `schema.sql`
- [Threat records](https://github.com/smartwolly5-afk/5_final/blob/main/schema_threat.sql): `schema_threat.sql`

### Tank dictionary

- [Dictionary routes](https://github.com/smartwolly5-afk/5_final/blob/main/dictionary.py): `dictionary.py`
- [Dictionary pages](https://github.com/smartwolly5-afk/5_final/tree/main/templates/dictionary): `templates/dictionary`
- [Dictionary threat calculations](https://github.com/smartwolly5-afk/5_final/blob/main/threat_calc.py): `threat_calc.py`

### Other components

- **Analyst**
- **Detector input**

## Connections

- Analyst → Flask app: uses (evidence: `README.md`)
- Detector input → Dashboard routes: submits detections (evidence: `dashboard/__init__.py`)
- Flask app → Dashboard routes: registers routes (evidence: `app.py`)
- Flask app → Dictionary routes: registers routes (evidence: `app.py`)
- Flask app → Threat API: registers routes (evidence: `app.py`)
- Dashboard routes → Analysis pipeline: analyzes payload (evidence: `dashboard/__init__.py`)
- Analysis pipeline → Track aggregation: aggregates tracks (evidence: `dashboard/threat/pipeline.py`)
- Analysis pipeline → Vehicle identification: judges tracks (evidence: `dashboard/threat/pipeline.py`)
- Vehicle identification → Vehicle threat score: scores vehicles (evidence: `dashboard/threat/judge.py`)
- Analysis pipeline → Response adapter: adapts results (evidence: `dashboard/threat/pipeline.py`)
- Response adapter → Cluster response level: assesses clusters (evidence: `dashboard/threat/adapter.py`)
- Dashboard routes → Track crops: saves representative crops (evidence: `dashboard/__init__.py`)
- Dashboard routes → Unknown registry: stores unknown sightings (evidence: `dashboard/__init__.py`)
- Unknown registry → Threat data access: reads and writes (evidence: `dashboard/unknown_registry.py`)
- Dashboard routes → Dashboard UI: renders (evidence: `README.md`)
- Dashboard UI → Dashboard client: loads client (evidence: `README.md`)
- Dashboard client → Dashboard routes: calls analysis APIs (evidence: `README.md`)
- Dashboard routes → Report view: renders report (evidence: `README.md`)
- Unknown browser → Dashboard routes: uses unknown APIs (evidence: `dashboard/__init__.py`)
- Threat API → Cluster response level: uses response rules (evidence: `threat_api.py`)
- Threat API → Threat data access: reads threat data (evidence: `threat_api.py`)
- Cluster response level → Threat data access: records assessments (evidence: `response_level.py`)
- Threat data access → MySQL / SQLite: connects (evidence: `threat_db.py`)
- Dictionary routes → MySQL access: queries data (evidence: `dictionary.py`)
- Dictionary routes → Dictionary threat calculations: uses calculations (evidence: `dictionary.py`)
- Dictionary routes → Dictionary pages: renders pages (evidence: `README.md`)
- MySQL access → MySQL / SQLite: opens connection (evidence: `db.py`)
- MySQL / SQLite → Tank specifications: stores specifications (evidence: `README.md`)
- MySQL / SQLite → Threat records: stores assessment records (evidence: `README.md`)
