# purnalokesh31-hub/earthmind-ai architecture

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

- Interactive diagram: https://gitdiagram.com/purnalokesh31-hub/earthmind-ai
- Repository: https://github.com/purnalokesh31-hub/earthmind-ai

## Overview

EarthMind PIOS is a municipal urban-intelligence and decision-support platform. Its documented workflow collects city data, reports, and evidence; analyzes and assesses risks; recommends actions; then leaves approval and tracking to human operators. The web application exposes command-center and domain workflows, while a Python API handles case and vision endpoints. The README documents broad domain coverage, simulations, and governance; sampled source confirms selected API, inference, scoring, and orchestration behavior. Many web routes and domain services were not sampled, so their internal links are not asserted.

Main entry points: [`apps/api/app/workers/orchestrator.py`](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/workers/orchestrator.py) (Case Analysis), [`apps/web/app/command-center/page.tsx`](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/command-center/page.tsx) (Command Center), [`apps/api/app/main.py`](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/main.py) (Python API Runtime), [`apps/web/app/api/v1/digital-twin/governance/evaluate/route.ts`](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/digital-twin/governance/evaluate/route.ts) (Human Governance)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Intake and Evidence"]
  node_reports["Reports and Incidents<br/>[route.ts]"]
  node_evidence["Evidence Analysis<br/>[vision_v1.py]"]
  node_case_api["Case API<br/>[cases.py]"]
end

subgraph group_analysis["Intelligence and Risk"]
  node_agent_flow["Agent Orchestrator"]
  node_ai_inference["AI Inference"]
  node_case_orchestrator["Case Analysis<br/>[orchestrator.py]"]
  node_predictive["Risk Prediction<br/>[predictive.py]"]
  node_spatial["Spatial Analysis<br/>[spatial.py]"]
  node_scoring["Risk Scoring<br/>[scoring.py]"]
  node_domain_twin["Urban Domain Twin"]
  node_simulation["Demo and Simulation<br/>[route.ts]"]
end

subgraph group_decision["Decision and Governance"]
  node_city_decisions["Decision Orchestration"]
  node_interventions["Intervention Planning"]
  node_governance["Human Governance<br/>[route.ts]"]
  node_decision_routes["Decision Workflows<br/>[route.ts]"]
end

subgraph group_experience["Operator Experience"]
  node_command_ui["Command Center<br/>[page.tsx]"]
  node_citizen_ui["Citizen Reporting"]
  node_web_app["Web Application<br/>[EarthMindApp.tsx]"]
end

subgraph group_platform["Runtime Platform"]
  node_case_store[("Case Store<br/>[db.py]")]
  node_runtime["Python API Runtime<br/>[main.py]"]
end

node_citizens(("Citizens"))
node_operators(("City Operators"))

node_citizens -->|"submit reports"| node_citizen_ui
node_citizen_ui -.->|"send reports"| node_reports
node_operators -->|"monitor city"| node_command_ui
node_command_ui -.->|"use interface"| node_web_app
node_runtime -->|"routes analysis"| node_evidence
node_runtime -.->|"routes cases"| node_case_api
node_runtime -->|"saves cases"| node_case_store
node_case_orchestrator -->|"reads cases"| node_case_store
node_case_orchestrator -->|"uses forecasts"| node_predictive
node_case_orchestrator -->|"uses geography"| node_spatial
node_case_orchestrator -->|"scores cases"| node_scoring
node_ai_inference -.->|"analyzes images"| node_evidence
node_agent_flow -.->|"invokes inference"| node_ai_inference
node_domain_twin -->|"offers simulations"| node_simulation
node_city_decisions -.->|"serves decisions"| node_decision_routes
node_city_decisions -.->|"frames actions"| node_interventions
node_decision_routes -->|"requires review"| node_governance
node_operators -->|"approve or reject"| node_governance
node_governance -.->|"tracks outcomes"| node_command_ui
node_domain_twin -.->|"provides domain views"| node_command_ui

click node_command_ui "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/command-center/page.tsx"
click node_citizen_ui "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/components/citizen/CitizenReportingModal.tsx"
click node_web_app "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/EarthMindApp.tsx"
click node_reports "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/citizen/reports/route.ts"
click node_evidence "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/api/vision_v1.py"
click node_case_api "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/api/cases.py"
click node_case_store "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/core/db.py"
click node_agent_flow "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/ai-agents/agent-orchestrator.service.ts"
click node_ai_inference "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/ai/ai-inference.service.ts"
click node_case_orchestrator "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/workers/orchestrator.py"
click node_predictive "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/engines/predictive.py"
click node_spatial "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/engines/spatial.py"
click node_scoring "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/packages/scoring-rules/scoring.py"
click node_city_decisions "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/services/city-decision-orchestrator.service.ts"
click node_interventions "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/services/city-intervention-orchestrator.service.ts"
click node_governance "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/digital-twin/governance/evaluate/route.ts"
click node_decision_routes "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/digital-twin/decisions/route.ts"
click node_domain_twin "https://github.com/purnalokesh31-hub/earthmind-ai/tree/main/apps/web/app/api/v1/digital-twin"
click node_runtime "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/main.py"
click node_simulation "https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/digital-twin/simulations/route.ts"

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_reports,node_evidence,node_case_api toneBlue
class node_agent_flow,node_ai_inference,node_case_orchestrator,node_predictive,node_spatial,node_scoring,node_domain_twin,node_simulation toneAmber
class node_city_decisions,node_interventions,node_governance,node_decision_routes toneMint
class node_command_ui,node_citizen_ui,node_web_app toneRose
class node_case_store,node_runtime,node_citizens,node_operators toneIndigo
```

## Components

### Intake and Evidence

- [Reports and Incidents](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/citizen/reports/route.ts): `apps/web/app/api/v1/citizen/reports/route.ts`
- [Evidence Analysis](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/api/vision_v1.py): `apps/api/app/api/vision_v1.py`
- [Case API](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/api/cases.py): `apps/api/app/api/cases.py`

### Intelligence and Risk

- [Agent Orchestrator](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/ai-agents/agent-orchestrator.service.ts): `apps/web/lib/server/ai-agents/agent-orchestrator.service.ts`
- [AI Inference](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/ai/ai-inference.service.ts): `apps/web/lib/server/ai/ai-inference.service.ts`
- [Case Analysis](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/workers/orchestrator.py): `apps/api/app/workers/orchestrator.py`
- [Risk Prediction](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/engines/predictive.py): `apps/api/app/engines/predictive.py`
- [Spatial Analysis](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/engines/spatial.py): `apps/api/app/engines/spatial.py`
- [Risk Scoring](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/packages/scoring-rules/scoring.py): `packages/scoring-rules/scoring.py`
- [Urban Domain Twin](https://github.com/purnalokesh31-hub/earthmind-ai/tree/main/apps/web/app/api/v1/digital-twin): `apps/web/app/api/v1/digital-twin`
- [Demo and Simulation](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/digital-twin/simulations/route.ts): `apps/web/app/api/v1/digital-twin/simulations/route.ts`

### Decision and Governance

- [Decision Orchestration](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/services/city-decision-orchestrator.service.ts): `apps/web/lib/server/services/city-decision-orchestrator.service.ts`
- [Intervention Planning](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/lib/server/services/city-intervention-orchestrator.service.ts): `apps/web/lib/server/services/city-intervention-orchestrator.service.ts`
- [Human Governance](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/digital-twin/governance/evaluate/route.ts): `apps/web/app/api/v1/digital-twin/governance/evaluate/route.ts`
- [Decision Workflows](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/api/v1/digital-twin/decisions/route.ts): `apps/web/app/api/v1/digital-twin/decisions/route.ts`

### Operator Experience

- [Command Center](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/command-center/page.tsx): `apps/web/app/command-center/page.tsx`
- [Citizen Reporting](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/components/citizen/CitizenReportingModal.tsx): `apps/web/components/citizen/CitizenReportingModal.tsx`
- [Web Application](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/web/app/EarthMindApp.tsx): `apps/web/app/EarthMindApp.tsx`

### Runtime Platform

- [Case Store](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/core/db.py): `apps/api/app/core/db.py`
- [Python API Runtime](https://github.com/purnalokesh31-hub/earthmind-ai/blob/main/apps/api/app/main.py): `apps/api/app/main.py`

### Other components

- **Citizens**
- **City Operators**

## Connections

- Citizens → Citizen Reporting: submit reports (evidence: `README.md`)
- Citizen Reporting → Reports and Incidents: send reports
- City Operators → Command Center: monitor city (evidence: `README.md`)
- Command Center → Web Application: use interface
- Python API Runtime → Evidence Analysis: routes analysis (evidence: `apps/api/app/main.py`)
- Python API Runtime → Case API: routes cases
- Python API Runtime → Case Store: saves cases (evidence: `apps/api/app/main.py`)
- Case Analysis → Case Store: reads cases (evidence: `apps/api/app/workers/orchestrator.py`)
- Case Analysis → Risk Prediction: uses forecasts (evidence: `apps/api/app/workers/orchestrator.py`)
- Case Analysis → Spatial Analysis: uses geography (evidence: `apps/api/app/workers/orchestrator.py`)
- Case Analysis → Risk Scoring: scores cases (evidence: `apps/api/app/workers/orchestrator.py`)
- AI Inference → Evidence Analysis: analyzes images
- Agent Orchestrator → AI Inference: invokes inference
- Urban Domain Twin → Demo and Simulation: offers simulations (evidence: `README.md`)
- Decision Orchestration → Decision Workflows: serves decisions
- Decision Orchestration → Intervention Planning: frames actions
- Decision Workflows → Human Governance: requires review (evidence: `README.md`)
- City Operators → Human Governance: approve or reject (evidence: `README.md`)
- Human Governance → Command Center: tracks outcomes
- Urban Domain Twin → Command Center: provides domain views
