# helidastar/sagip-ai architecture

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

- Interactive diagram: https://gitdiagram.com/helidastar/sagip-ai
- Repository: https://github.com/helidastar/sagip-ai

## Overview

SAGIP-AI is a citizen emergency-reporting and responder-triage application: citizens submit photo, description, and GPS without an account; reports are classified, uncertain cases go to staff, and incidents are ranked for response. Staff can review classifications, assign teams, and update incident status or priority; citizens can track reports by code. The map is part of the ranked staff view. This checkout provides no source excerpts or source tree, so relationships and paths below rely on README statements only; undocumented implementation details are omitted.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Citizen Intake"]
  node_report_form["Report Form"]
  node_rate_limit["IP Rate Limit"]
  node_report_api["Report API"]
  node_supabase[("Supabase")]
end

subgraph group_classification["AI Classification"]
  node_ai_chain["AI Chain"]
  node_onnx["ONNX Classifier"]
  node_gemini["Gemini"]
  node_keyword_matcher["Keyword Matcher"]
  node_review_policy["Review Policy"]
end

subgraph group_response["Review and Response"]
  node_review_queue["Staff Review Queue"]
  node_priority_scoring["Priority Scoring"]
  node_staff_dashboard["Ranked Dashboard and Map"]
  node_incident_operations["Incident Operations API"]
  node_audit_logs[("Audit Logs")]
end

subgraph group_tracking["Report Tracking"]
  node_tracking_api["Tracking API"]
  node_tracking_citizen(("Tracking Citizen"))
end

node_citizen(("Citizen"))

node_citizen -->|"submits report"| node_report_form
node_report_form -->|"posts report"| node_report_api
node_report_form -->|"limited by"| node_rate_limit
node_report_api -->|"stores report"| node_supabase
node_report_api -->|"classifies report"| node_ai_chain
node_ai_chain -->|"uses primary"| node_onnx
node_ai_chain -.->|"falls back"| node_gemini
node_ai_chain -->|"falls back"| node_keyword_matcher
node_review_policy -->|"sends for review"| node_review_queue
node_priority_scoring -->|"ranks incidents"| node_staff_dashboard
node_incident_operations -->|"writes changes"| node_audit_logs
node_tracking_citizen -->|"requests status"| node_tracking_api
node_tracking_api -.->|"reads report"| node_supabase

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_report_form,node_rate_limit,node_report_api,node_supabase toneBlue
class node_ai_chain,node_onnx,node_gemini,node_keyword_matcher,node_review_policy toneAmber
class node_review_queue,node_priority_scoring,node_staff_dashboard,node_incident_operations,node_audit_logs toneMint
class node_tracking_api,node_tracking_citizen toneRose
class node_citizen toneIndigo
```

## Components

### Citizen Intake

- **Report Form**
- **IP Rate Limit**
- **Report API**
- **Supabase**

### AI Classification

- **AI Chain**
- **ONNX Classifier**
- **Gemini**
- **Keyword Matcher**
- **Review Policy**

### Review and Response

- **Staff Review Queue**
- **Priority Scoring**
- **Ranked Dashboard and Map**
- **Incident Operations API**
- **Audit Logs**

### Report Tracking

- **Tracking API**
- **Tracking Citizen**

### Other components

- **Citizen**

## Connections

- Citizen → Report Form: submits report (evidence: `README.md`)
- Report Form → Report API: posts report (evidence: `README.md`)
- Report Form → IP Rate Limit: limited by (evidence: `README.md`)
- Report API → Supabase: stores report (evidence: `README.md`)
- Report API → AI Chain: classifies report (evidence: `README.md`)
- AI Chain → ONNX Classifier: uses primary (evidence: `README.md`)
- AI Chain → Gemini: falls back (evidence: `README.md`)
- AI Chain → Keyword Matcher: falls back (evidence: `README.md`)
- Review Policy → Staff Review Queue: sends for review (evidence: `README.md`)
- Priority Scoring → Ranked Dashboard and Map: ranks incidents (evidence: `README.md`)
- Incident Operations API → Audit Logs: writes changes (evidence: `README.md`)
- Tracking Citizen → Tracking API: requests status (evidence: `README.md`)
- Tracking API → Supabase: reads report
