# chakriroyal2007-star/tera-2.o architecture

> Architecture diagram of the GitHub repository chakriroyal2007-star/tera-2.o, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chakriroyal2007-star/tera-2.o
- Repository: https://github.com/chakriroyal2007-star/tera-2.o

## Overview

TERA is a role-based emergency coordination platform. Citizens submit reports and track incidents; operators verify and dispatch responders, hospitals handle referrals and handover, and operators close the response. PostgreSQL persists operational records. The graph also includes the documented speech, first-aid companion, administration, real-time, analytics, and DBMS Studio capabilities. Some subsystem internals were not sampled, so documented but unverified links are dashed.

Main entry points: [`backend/app/main.py`](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/main.py) (API application), [`backend/app/speech/router.py`](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/router.py) (Speech services), [`backend/app/dbms/router.py`](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/dbms/router.py) (DBMS inspection and lab), [`backend/app/workflow.py`](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/workflow.py) (Incident workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User portals"]
  node_portals["Portal routing<br/>[App.tsx]"]
  node_public["Public reporting<br/>[Public.tsx]"]
  node_operations["Operations portal<br/>[Operations.tsx]"]
  node_management["Management portal<br/>[Management.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_response["Incident response"]
  node_api_entry["API application<br/>[main.py]"]
  node_workflow["Incident workflow<br/>[workflow.py]"]
  node_hospital["Hospital coordination<br/>[workflow.py]"]
end

subgraph group_identity["Identity and administration"]
  node_auth["Authentication<br/>[auth.py]"]
  node_security["Sessions and security<br/>[security.py]"]
  node_admin["Administration<br/>[admin.py]"]
  node_bootstrap["Initial administrator<br/>[bootstrap.py]"]
end

subgraph group_assistance["Voice and companion"]
  node_speech_ui["Voice recorder<br/>[VoiceRecorder.tsx]"]
  node_speech_api["Speech services<br/>[router.py]"]
  node_extraction["Speech extraction<br/>[extraction.py]"]
  node_speech_intelligence["Speech intelligence<br/>[intelligence.py]"]
  node_speech_report["Speech reporting<br/>[report.py]"]
  node_companion["Emergency companion<br/>[router.py]"]
  node_knowledge["Medical knowledge<br/>[knowledge.py]"]
  node_videos["Guidance videos<br/>[videos.py]"]
end

subgraph group_platform["Data and analysis"]
  node_records[("Operational records<br/>[models.py]")]
  node_database[("PostgreSQL<br/>[db.py]")]
  node_realtime["Live event updates<br/>[realtime.py]"]
  node_dbms_ui["DBMS Studio<br/>[DbmsStudio.tsx]"]
  node_dbms_api["DBMS inspection and lab<br/>[router.py]"]
  node_dbms_introspect["Schema introspection<br/>[introspect.py]"]
  node_dbms_algorithms["DBMS algorithms<br/>[algorithms.py]"]
end

node_citizen(("Citizen"))

node_citizen -->|"submits report"| node_public
node_public -.->|"sends requests"| node_api_client
node_operations -.->|"sends requests"| node_api_client
node_portals -->|"renders portal"| node_operations
node_api_client -.->|"calls API"| node_api_entry
node_api_entry -->|"routes requests"| node_workflow
node_workflow -->|"reads and writes"| node_records
node_records -->|"persists records"| node_database
node_operations -.->|"dispatches response"| node_workflow
node_management -.->|"handles referral"| node_workflow
node_api_entry -->|"registers routes"| node_auth
node_api_entry -->|"registers routes"| node_admin
node_auth -->|"uses session security"| node_security
node_bootstrap -->|"creates administrator"| node_records
node_api_entry -->|"registers routes"| node_speech_api
node_speech_ui -.->|"uploads audio"| node_speech_api
node_speech_api -->|"extracts fields"| node_extraction
node_speech_api -->|"uses intelligence"| node_speech_intelligence
node_speech_api -->|"builds reports"| node_speech_report
node_api_entry -->|"registers routes"| node_companion
node_companion -->|"uses protocols"| node_knowledge
node_companion -->|"serves guidance"| node_videos
node_api_entry -->|"registers updates"| node_realtime
node_dbms_ui -.->|"queries DBMS"| node_dbms_api
node_api_entry -->|"registers routes"| node_dbms_api
node_dbms_api -->|"inspects schema"| node_dbms_introspect
node_dbms_api -->|"runs analysis"| node_dbms_algorithms
node_dbms_introspect -->|"reads metadata"| node_database

click node_portals "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/App.tsx"
click node_public "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/Public.tsx"
click node_operations "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/Operations.tsx"
click node_management "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/Management.tsx"
click node_api_client "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/api.ts"
click node_api_entry "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/main.py"
click node_workflow "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/workflow.py"
click node_hospital "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/workflow.py"
click node_records "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/models.py"
click node_database "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/db.py"
click node_auth "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/auth.py"
click node_security "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/security.py"
click node_admin "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/admin.py"
click node_bootstrap "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/bootstrap.py"
click node_speech_ui "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/VoiceRecorder.tsx"
click node_speech_api "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/router.py"
click node_extraction "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/extraction.py"
click node_speech_intelligence "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/intelligence.py"
click node_speech_report "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/report.py"
click node_companion "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/companion/router.py"
click node_knowledge "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/companion/knowledge.py"
click node_videos "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/companion/videos.py"
click node_realtime "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/realtime.py"
click node_dbms_ui "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/dbms/DbmsStudio.tsx"
click node_dbms_api "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/dbms/router.py"
click node_dbms_introspect "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/dbms/introspect.py"
click node_dbms_algorithms "https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/dbms/algorithms.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_portals,node_public,node_operations,node_management,node_api_client toneBlue
class node_api_entry,node_workflow,node_hospital toneAmber
class node_auth,node_security,node_admin,node_bootstrap toneMint
class node_speech_ui,node_speech_api,node_extraction,node_speech_intelligence,node_speech_report,node_companion,node_knowledge,node_videos toneRose
class node_records,node_database,node_realtime,node_dbms_ui,node_dbms_api,node_dbms_introspect,node_dbms_algorithms,node_citizen toneIndigo
```

## Components

### User portals

- [Portal routing](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Public reporting](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/Public.tsx): `frontend/src/Public.tsx`
- [Operations portal](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/Operations.tsx): `frontend/src/Operations.tsx`
- [Management portal](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/Management.tsx): `frontend/src/Management.tsx`
- [API client](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### Incident response

- [API application](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/main.py): `backend/app/main.py`
- [Incident workflow](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/workflow.py): `backend/app/workflow.py`
- [Hospital coordination](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/workflow.py): `backend/app/workflow.py`

### Identity and administration

- [Authentication](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Sessions and security](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/security.py): `backend/app/security.py`
- [Administration](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/admin.py): `backend/app/admin.py`
- [Initial administrator](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/bootstrap.py): `backend/app/bootstrap.py`

### Voice and companion

- [Voice recorder](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/VoiceRecorder.tsx): `frontend/src/VoiceRecorder.tsx`
- [Speech services](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/router.py): `backend/app/speech/router.py`
- [Speech extraction](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/extraction.py): `backend/app/speech/extraction.py`
- [Speech intelligence](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/intelligence.py): `backend/app/speech/intelligence.py`
- [Speech reporting](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/speech/report.py): `backend/app/speech/report.py`
- [Emergency companion](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/companion/router.py): `backend/app/companion/router.py`
- [Medical knowledge](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/companion/knowledge.py): `backend/app/companion/knowledge.py`
- [Guidance videos](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/companion/videos.py): `backend/app/companion/videos.py`

### Data and analysis

- [Operational records](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/models.py): `backend/app/models.py`
- [PostgreSQL](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/db.py): `backend/app/db.py`
- [Live event updates](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/realtime.py): `backend/app/realtime.py`
- [DBMS Studio](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/frontend/src/dbms/DbmsStudio.tsx): `frontend/src/dbms/DbmsStudio.tsx`
- [DBMS inspection and lab](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/dbms/router.py): `backend/app/dbms/router.py`
- [Schema introspection](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/dbms/introspect.py): `backend/app/dbms/introspect.py`
- [DBMS algorithms](https://github.com/chakriroyal2007-star/tera-2.o/blob/main/backend/app/dbms/algorithms.py): `backend/app/dbms/algorithms.py`

### Other components

- **Citizen**

## Connections

- Citizen → Public reporting: submits report
- Public reporting → API client: sends requests (evidence: `frontend/src/Public.tsx`)
- Operations portal → API client: sends requests (evidence: `frontend/src/Operations.tsx`)
- Portal routing → Operations portal: renders portal (evidence: `frontend/src/App.tsx`)
- API client → API application: calls API
- API application → Incident workflow: routes requests (evidence: `backend/app/main.py`)
- Incident workflow → Operational records: reads and writes (evidence: `backend/app/workflow.py`)
- Operational records → PostgreSQL: persists records (evidence: `backend/app/db.py`)
- Operations portal → Incident workflow: dispatches response
- Management portal → Incident workflow: handles referral
- API application → Authentication: registers routes (evidence: `backend/app/main.py`)
- API application → Administration: registers routes (evidence: `backend/app/main.py`)
- Authentication → Sessions and security: uses session security (evidence: `backend/app/auth.py`)
- Initial administrator → Operational records: creates administrator (evidence: `backend/app/bootstrap.py`)
- API application → Speech services: registers routes (evidence: `backend/app/main.py`)
- Voice recorder → Speech services: uploads audio
- Speech services → Speech extraction: extracts fields (evidence: `backend/app/speech/router.py`)
- Speech services → Speech intelligence: uses intelligence (evidence: `backend/app/speech/router.py`)
- Speech services → Speech reporting: builds reports (evidence: `backend/app/speech/router.py`)
- API application → Emergency companion: registers routes (evidence: `backend/app/main.py`)
- Emergency companion → Medical knowledge: uses protocols (evidence: `backend/app/companion/router.py`)
- Emergency companion → Guidance videos: serves guidance (evidence: `backend/app/companion/router.py`)
- API application → Live event updates: registers updates (evidence: `backend/app/main.py`)
- DBMS Studio → DBMS inspection and lab: queries DBMS
- API application → DBMS inspection and lab: registers routes (evidence: `backend/app/main.py`)
- DBMS inspection and lab → Schema introspection: inspects schema (evidence: `backend/app/dbms/router.py`)
- DBMS inspection and lab → DBMS algorithms: runs analysis (evidence: `backend/app/dbms/router.py`)
- Schema introspection → PostgreSQL: reads metadata (evidence: `backend/app/dbms/introspect.py`)
