# shandiash/systemresearch architecture

> Architecture diagram of the GitHub repository shandiash/systemresearch, 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/shandiash/systemresearch
- Repository: https://github.com/shandiash/systemresearch

## Overview

TUGON AI is a municipal incident-reporting and verification application for Cebu City. Citizens submit a narrative, photo, and location through the portal; the FastAPI application offers preview analysis, verifies location evidence, and manages report records. Reports carry classification, office assignment, urgency, and verification information for command-center review and optional sector notification. The README also documents document-requirement advisories and human oversight. Edges reflect shown calls, indexed module references, or README descriptions; unsampled dashboard and lifecycle details are represented conservatively.

Main entry points: [`app/main.py`](https://github.com/shandiash/systemresearch/blob/main/app/main.py) (FastAPI routes), [`static/js/app.js`](https://github.com/shandiash/systemresearch/blob/main/static/js/app.js) (Reporting interface), [`app/database.py`](https://github.com/shandiash/systemresearch/blob/main/app/database.py) (SQL database), [`app/notifier.py`](https://github.com/shandiash/systemresearch/blob/main/app/notifier.py) (Sector notifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Citizen portal"]
  node_portal_ui["Reporting interface<br/>[app.js]"]
  node_portal_pages["Portal pages"]
  node_api["FastAPI routes<br/>[main.py]"]
end

subgraph group_inference["Analysis and verification"]
  node_classifier["Multimodal classifier<br/>[classifier.py]"]
  node_verification["GPS and EXIF verifier<br/>[verifier.py]"]
  node_settings["Sectors and offices<br/>[config.py]"]
end

subgraph group_records["Reports and persistence"]
  node_users["Accounts and roles<br/>[models.py]"]
  node_reports["Incident records<br/>[models.py]"]
  node_notifications["Dispatch log<br/>[models.py]"]
  node_database[("SQL database<br/>[database.py]")]
end

subgraph group_oversight["Municipal oversight"]
  node_notifier["Sector notifier<br/>[notifier.py]"]
  node_dashboard["Command dashboard<br/>[dashboard.html]"]
  node_dashboard_ui["Dashboard behavior<br/>[dashboard.js]"]
end

node_citizen(("Citizen"))
node_partner_offices["Partner government offices"]

node_citizen -->|"submits report"| node_portal_ui
node_portal_ui -->|"requests preview"| node_api
node_portal_ui -->|"submits report"| node_api
node_api -->|"renders portal"| node_portal_pages
node_api -->|"renders dashboard"| node_dashboard
node_api -->|"uses classification"| node_classifier
node_api -->|"checks location"| node_verification
node_api -->|"queries reports"| node_reports
node_api -->|"manages accounts"| node_users
node_api -->|"triggers dispatch"| node_notifier
node_api -->|"gets sessions"| node_database
node_database -->|"maps tables"| node_reports
node_database -->|"maps tables"| node_users
node_notifier -->|"records alert"| node_notifications
node_notifier -.->|"emails office"| node_partner_offices
node_classifier -->|"uses office data"| node_settings
node_dashboard -.->|"uses behavior"| node_dashboard_ui

click node_portal_ui "https://github.com/shandiash/systemresearch/blob/main/static/js/app.js"
click node_portal_pages "https://github.com/shandiash/systemresearch/tree/main/templates"
click node_api "https://github.com/shandiash/systemresearch/blob/main/app/main.py"
click node_classifier "https://github.com/shandiash/systemresearch/blob/main/app/classifier.py"
click node_verification "https://github.com/shandiash/systemresearch/blob/main/app/verifier.py"
click node_settings "https://github.com/shandiash/systemresearch/blob/main/app/config.py"
click node_users "https://github.com/shandiash/systemresearch/blob/main/app/models.py"
click node_reports "https://github.com/shandiash/systemresearch/blob/main/app/models.py"
click node_notifications "https://github.com/shandiash/systemresearch/blob/main/app/models.py"
click node_database "https://github.com/shandiash/systemresearch/blob/main/app/database.py"
click node_notifier "https://github.com/shandiash/systemresearch/blob/main/app/notifier.py"
click node_dashboard "https://github.com/shandiash/systemresearch/blob/main/templates/dashboard.html"
click node_dashboard_ui "https://github.com/shandiash/systemresearch/blob/main/static/js/dashboard.js"

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_portal_ui,node_portal_pages,node_api toneBlue
class node_classifier,node_verification,node_settings toneAmber
class node_users,node_reports,node_notifications,node_database toneMint
class node_notifier,node_dashboard,node_dashboard_ui toneRose
class node_citizen,node_partner_offices toneIndigo
```

## Components

### Citizen portal

- [Reporting interface](https://github.com/shandiash/systemresearch/blob/main/static/js/app.js): `static/js/app.js`
- [Portal pages](https://github.com/shandiash/systemresearch/tree/main/templates): `templates`
- [FastAPI routes](https://github.com/shandiash/systemresearch/blob/main/app/main.py): `app/main.py`

### Analysis and verification

- [Multimodal classifier](https://github.com/shandiash/systemresearch/blob/main/app/classifier.py): `app/classifier.py`
- [GPS and EXIF verifier](https://github.com/shandiash/systemresearch/blob/main/app/verifier.py): `app/verifier.py`
- [Sectors and offices](https://github.com/shandiash/systemresearch/blob/main/app/config.py): `app/config.py`

### Reports and persistence

- [Accounts and roles](https://github.com/shandiash/systemresearch/blob/main/app/models.py): `app/models.py`
- [Incident records](https://github.com/shandiash/systemresearch/blob/main/app/models.py): `app/models.py`
- [Dispatch log](https://github.com/shandiash/systemresearch/blob/main/app/models.py): `app/models.py`
- [SQL database](https://github.com/shandiash/systemresearch/blob/main/app/database.py): `app/database.py`

### Municipal oversight

- [Sector notifier](https://github.com/shandiash/systemresearch/blob/main/app/notifier.py): `app/notifier.py`
- [Command dashboard](https://github.com/shandiash/systemresearch/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Dashboard behavior](https://github.com/shandiash/systemresearch/blob/main/static/js/dashboard.js): `static/js/dashboard.js`

### Other components

- **Citizen**
- **Partner government offices**

## Connections

- Citizen → Reporting interface: submits report (evidence: `static/js/app.js`)
- Reporting interface → FastAPI routes: requests preview (evidence: `static/js/app.js`)
- Reporting interface → FastAPI routes: submits report (evidence: `static/js/app.js`)
- FastAPI routes → Portal pages: renders portal (evidence: `app/main.py`)
- FastAPI routes → Command dashboard: renders dashboard (evidence: `app/main.py`)
- FastAPI routes → Multimodal classifier: uses classification (evidence: `app/main.py`)
- FastAPI routes → GPS and EXIF verifier: checks location (evidence: `app/main.py`)
- FastAPI routes → Incident records: queries reports (evidence: `app/main.py`)
- FastAPI routes → Accounts and roles: manages accounts (evidence: `app/main.py`)
- FastAPI routes → Sector notifier: triggers dispatch (evidence: `app/main.py`)
- FastAPI routes → SQL database: gets sessions (evidence: `app/main.py`)
- SQL database → Incident records: maps tables (evidence: `app/database.py`)
- SQL database → Accounts and roles: maps tables (evidence: `app/database.py`)
- Sector notifier → Dispatch log: records alert (evidence: `app/notifier.py`)
- Sector notifier → Partner government offices: emails office (evidence: `app/notifier.py`)
- Multimodal classifier → Sectors and offices: uses office data (evidence: `app/classifier.py`)
- Command dashboard → Dashboard behavior: uses behavior
