# izzyflestado/bantayani architecture

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

- Interactive diagram: https://gitdiagram.com/izzyflestado/bantayani
- Repository: https://github.com/izzyflestado/bantayani

## Overview

Bantay Ani is a satellite crop-monitoring and insurance-claim verification platform for Philippine agricultural officers. The main workflow is an officer using the web app to review farms or submit a claim; backend services retrieve satellite indices, assess damage, persist claim data, and return results for review or reporting. The README also describes role-specific PCIC and regional views, chat, advisories, and analytics. Some frontend-to-API wiring and unsampled route implementations are not shown, so those links are omitted or marked unverified.

Main entry points: [`backend/services/claim_service.py`](https://github.com/izzyflestado/bantayani/blob/main/backend/services/claim_service.py) (Claim Assessment), [`backend/main.py`](https://github.com/izzyflestado/bantayani/blob/main/backend/main.py) (FastAPI Runtime), [`backend/api/satellite.py`](https://github.com/izzyflestado/bantayani/blob/main/backend/api/satellite.py) (Satellite API), [`backend/services/satellite_service.py`](https://github.com/izzyflestado/bantayani/blob/main/backend/services/satellite_service.py) (Satellite Analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Officer Web App"]
  node_web_auth["Sign In<br/>[page.js]"]
  node_web_farms["Farm Views<br/>[page.js]"]
  node_web_claims["Claim Review<br/>[page.js]"]
  node_web_verify["Verification Result<br/>[page.js]"]
  node_web_reports["Reports<br/>[page.js]"]
  node_web_roles["Regional and PCIC<br/>[page.js]"]
  node_web_chat["Chat Assistant<br/>[ChatWidget.js]"]
end

subgraph group_api["API Surface"]
  node_api_auth["Authentication API<br/>[auth.py]"]
  node_api_farms["Farm API<br/>[farms.py]"]
  node_api_claims["Claims API<br/>[claims.py]"]
  node_api_verify["Verification API<br/>[verify.py]"]
  node_api_satellite["Satellite API<br/>[satellite.py]"]
  node_api_reports["Reports API<br/>[reports.py]"]
  node_api_chat["Chat API<br/>[chat.py]"]
  node_api_notifications["Notifications API<br/>[notifications.py]"]
  node_runtime["FastAPI Runtime<br/>[main.py]"]
end

subgraph group_domain["Domain Services"]
  node_claim["Claim Assessment<br/>[claim_service.py]"]
  node_farm["Farm Monitoring<br/>[farm_service.py]"]
  node_assistant["Intent and Chat<br/>[chat_service.py]"]
  node_ai["AI Assessment<br/>[ai_service.py]"]
  node_notifications["Notifications"]
  node_auth["Identity and Roles<br/>[auth_service.py]"]
end

subgraph group_data["Data and Imagery"]
  node_satellite["Satellite Analysis"]
  node_sentinel["Sentinel Hub Access"]
  node_earth["Earth Engine Setup<br/>[earth_engine.py]"]
  node_ndvi["NDVI Utilities<br/>[ndvi.py]"]
  node_store[("Demo or PostgreSQL Store<br/>[database.py]")]
end

node_officer(("Agricultural Officer"))

node_officer -->|"signs in"| node_web_auth
node_officer -.->|"reviews farms"| node_web_farms
node_officer -.->|"reviews claims"| node_web_claims
node_web_auth -.->|"submits login"| node_api_auth
node_web_farms -.->|"requests farm data"| node_api_farms
node_web_claims -.->|"requests claims"| node_api_claims
node_web_verify -.->|"requests verification"| node_api_verify
node_web_reports -.->|"requests reports"| node_api_reports
node_web_roles -.->|"views monitoring"| node_api_satellite
node_web_chat -.->|"sends prompts"| node_api_chat
node_runtime -->|"registers route"| node_api_auth
node_runtime -->|"registers route"| node_api_farms
node_runtime -->|"registers route"| node_api_claims
node_runtime -->|"registers route"| node_api_reports
node_runtime -->|"registers route"| node_api_satellite
node_api_auth -->|"authenticates"| node_auth
node_api_auth -->|"loads role data"| node_auth
node_api_farms -->|"dispatches farm work"| node_farm
node_api_claims -->|"dispatches claim work"| node_claim
node_api_verify -->|"requests verification"| node_claim
node_api_reports -->|"loads claim data"| node_claim
node_api_chat -->|"dispatches chat"| node_assistant
node_api_notifications -->|"loads notifications"| node_notifications
node_api_satellite -->|"requests satellite data"| node_satellite
node_api_satellite -->|"requests imagery"| node_sentinel
node_api_satellite -->|"requests claim context"| node_claim
node_api_satellite -->|"requests farm context"| node_farm
node_claim -->|"computes indices"| node_satellite
node_claim -->|"requests assessment"| node_ai
node_claim -->|"sends notifications"| node_notifications
node_farm -->|"reads scan cache"| node_satellite
node_farm -->|"alerts critical farms"| node_notifications
node_ai -->|"uses vegetation indices"| node_ndvi
node_satellite -->|"uses Earth Engine"| node_earth
node_sentinel -->|"uses Earth Engine"| node_earth
node_claim -->|"reads and writes claims"| node_store
node_farm -->|"reads and writes farms"| node_store
node_satellite -->|"stores scan data"| node_store
node_auth -->|"reads users"| node_store
node_notifications -->|"reads and writes alerts"| node_store
node_api_reports -->|"reads imagery dates"| node_store
node_runtime -->|"initializes service"| node_earth
node_runtime -->|"warms imagery cache"| node_satellite

click node_web_auth "https://github.com/izzyflestado/bantayani/blob/main/frontend/app/login/page.js"
click node_web_farms "https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/farms/page.js"
click node_web_claims "https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/claims/page.js"
click node_web_verify "https://github.com/izzyflestado/bantayani/blob/main/frontend/app/verify/%5Bid%5D/page.js"
click node_web_reports "https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/reports/page.js"
click node_web_roles "https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/pcic/claims-queue/page.js"
click node_web_chat "https://github.com/izzyflestado/bantayani/blob/main/frontend/components/chat/ChatWidget.js"
click node_api_auth "https://github.com/izzyflestado/bantayani/blob/main/backend/api/auth.py"
click node_api_farms "https://github.com/izzyflestado/bantayani/blob/main/backend/api/farms.py"
click node_api_claims "https://github.com/izzyflestado/bantayani/blob/main/backend/api/claims.py"
click node_api_verify "https://github.com/izzyflestado/bantayani/blob/main/backend/api/verify.py"
click node_api_satellite "https://github.com/izzyflestado/bantayani/blob/main/backend/api/satellite.py"
click node_api_reports "https://github.com/izzyflestado/bantayani/blob/main/backend/api/reports.py"
click node_api_chat "https://github.com/izzyflestado/bantayani/blob/main/backend/api/chat.py"
click node_api_notifications "https://github.com/izzyflestado/bantayani/blob/main/backend/api/notifications.py"
click node_claim "https://github.com/izzyflestado/bantayani/blob/main/backend/services/claim_service.py"
click node_farm "https://github.com/izzyflestado/bantayani/blob/main/backend/services/farm_service.py"
click node_assistant "https://github.com/izzyflestado/bantayani/blob/main/backend/services/chat_service.py"
click node_ai "https://github.com/izzyflestado/bantayani/blob/main/backend/services/ai_service.py"
click node_notifications "https://github.com/izzyflestado/bantayani/blob/main/backend/services/notification_service.py"
click node_auth "https://github.com/izzyflestado/bantayani/blob/main/backend/services/auth_service.py"
click node_satellite "https://github.com/izzyflestado/bantayani/blob/main/backend/services/satellite_service.py"
click node_sentinel "https://github.com/izzyflestado/bantayani/blob/main/backend/services/sentinel_hub_service.py"
click node_earth "https://github.com/izzyflestado/bantayani/blob/main/backend/services/earth_engine.py"
click node_ndvi "https://github.com/izzyflestado/bantayani/blob/main/backend/utils/ndvi.py"
click node_store "https://github.com/izzyflestado/bantayani/blob/main/backend/utils/database.py"
click node_runtime "https://github.com/izzyflestado/bantayani/blob/main/backend/main.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_web_auth,node_web_farms,node_web_claims,node_web_verify,node_web_reports,node_web_roles,node_web_chat toneBlue
class node_api_auth,node_api_farms,node_api_claims,node_api_verify,node_api_satellite,node_api_reports,node_api_chat,node_api_notifications,node_runtime toneAmber
class node_claim,node_farm,node_assistant,node_ai,node_notifications,node_auth toneMint
class node_satellite,node_sentinel,node_earth,node_ndvi,node_store toneRose
class node_officer toneIndigo
```

## Components

### Officer Web App

- [Sign In](https://github.com/izzyflestado/bantayani/blob/main/frontend/app/login/page.js): `frontend/app/login/page.js`
- [Farm Views](https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/farms/page.js): `frontend/app/(authenticated)/farms/page.js`
- [Claim Review](https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/claims/page.js): `frontend/app/(authenticated)/claims/page.js`
- [Verification Result](https://github.com/izzyflestado/bantayani/blob/main/frontend/app/verify/%5Bid%5D/page.js): `frontend/app/verify/[id]/page.js`
- [Reports](https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/reports/page.js): `frontend/app/(authenticated)/reports/page.js`
- [Regional and PCIC](https://github.com/izzyflestado/bantayani/blob/main/frontend/app/(authenticated)/pcic/claims-queue/page.js): `frontend/app/(authenticated)/pcic/claims-queue/page.js`
- [Chat Assistant](https://github.com/izzyflestado/bantayani/blob/main/frontend/components/chat/ChatWidget.js): `frontend/components/chat/ChatWidget.js`

### API Surface

- [Authentication API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/auth.py): `backend/api/auth.py`
- [Farm API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/farms.py): `backend/api/farms.py`
- [Claims API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/claims.py): `backend/api/claims.py`
- [Verification API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/verify.py): `backend/api/verify.py`
- [Satellite API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/satellite.py): `backend/api/satellite.py`
- [Reports API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/reports.py): `backend/api/reports.py`
- [Chat API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/chat.py): `backend/api/chat.py`
- [Notifications API](https://github.com/izzyflestado/bantayani/blob/main/backend/api/notifications.py): `backend/api/notifications.py`
- [FastAPI Runtime](https://github.com/izzyflestado/bantayani/blob/main/backend/main.py): `backend/main.py`

### Domain Services

- [Claim Assessment](https://github.com/izzyflestado/bantayani/blob/main/backend/services/claim_service.py): `backend/services/claim_service.py`
- [Farm Monitoring](https://github.com/izzyflestado/bantayani/blob/main/backend/services/farm_service.py): `backend/services/farm_service.py`
- [Intent and Chat](https://github.com/izzyflestado/bantayani/blob/main/backend/services/chat_service.py): `backend/services/chat_service.py`
- [AI Assessment](https://github.com/izzyflestado/bantayani/blob/main/backend/services/ai_service.py): `backend/services/ai_service.py`
- [Notifications](https://github.com/izzyflestado/bantayani/blob/main/backend/services/notification_service.py): `backend/services/notification_service.py`
- [Identity and Roles](https://github.com/izzyflestado/bantayani/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`

### Data and Imagery

- [Satellite Analysis](https://github.com/izzyflestado/bantayani/blob/main/backend/services/satellite_service.py): `backend/services/satellite_service.py`
- [Sentinel Hub Access](https://github.com/izzyflestado/bantayani/blob/main/backend/services/sentinel_hub_service.py): `backend/services/sentinel_hub_service.py`
- [Earth Engine Setup](https://github.com/izzyflestado/bantayani/blob/main/backend/services/earth_engine.py): `backend/services/earth_engine.py`
- [NDVI Utilities](https://github.com/izzyflestado/bantayani/blob/main/backend/utils/ndvi.py): `backend/utils/ndvi.py`
- [Demo or PostgreSQL Store](https://github.com/izzyflestado/bantayani/blob/main/backend/utils/database.py): `backend/utils/database.py`

### Other components

- **Agricultural Officer**

## Connections

- Agricultural Officer → Sign In: signs in (evidence: `README.md`)
- Agricultural Officer → Farm Views: reviews farms
- Agricultural Officer → Claim Review: reviews claims
- Sign In → Authentication API: submits login
- Farm Views → Farm API: requests farm data
- Claim Review → Claims API: requests claims
- Verification Result → Verification API: requests verification
- Reports → Reports API: requests reports
- Regional and PCIC → Satellite API: views monitoring
- Chat Assistant → Chat API: sends prompts
- FastAPI Runtime → Authentication API: registers route (evidence: `backend/main.py`)
- FastAPI Runtime → Farm API: registers route (evidence: `backend/main.py`)
- FastAPI Runtime → Claims API: registers route (evidence: `backend/main.py`)
- FastAPI Runtime → Reports API: registers route (evidence: `backend/main.py`)
- FastAPI Runtime → Satellite API: registers route (evidence: `backend/main.py`)
- Authentication API → Identity and Roles: authenticates (evidence: `backend/api/auth.py`)
- Authentication API → Identity and Roles: loads role data (evidence: `backend/api/auth.py`)
- Farm API → Farm Monitoring: dispatches farm work (evidence: `backend/api/farms.py`)
- Claims API → Claim Assessment: dispatches claim work (evidence: `backend/api/claims.py`)
- Verification API → Claim Assessment: requests verification (evidence: `backend/api/verify.py`)
- Reports API → Claim Assessment: loads claim data (evidence: `backend/api/reports.py`)
- Chat API → Intent and Chat: dispatches chat (evidence: `backend/api/chat.py`)
- Notifications API → Notifications: loads notifications (evidence: `backend/api/notifications.py`)
- Satellite API → Satellite Analysis: requests satellite data (evidence: `backend/api/satellite.py`)
- Satellite API → Sentinel Hub Access: requests imagery (evidence: `backend/api/satellite.py`)
- Satellite API → Claim Assessment: requests claim context (evidence: `backend/api/satellite.py`)
- Satellite API → Farm Monitoring: requests farm context (evidence: `backend/api/satellite.py`)
- Claim Assessment → Satellite Analysis: computes indices (evidence: `backend/services/claim_service.py`)
- Claim Assessment → AI Assessment: requests assessment (evidence: `backend/services/claim_service.py`)
- Claim Assessment → Notifications: sends notifications (evidence: `backend/services/claim_service.py`)
- Farm Monitoring → Satellite Analysis: reads scan cache (evidence: `backend/services/farm_service.py`)
- Farm Monitoring → Notifications: alerts critical farms (evidence: `backend/services/farm_service.py`)
- AI Assessment → NDVI Utilities: uses vegetation indices (evidence: `backend/services/ai_service.py`)
- Satellite Analysis → Earth Engine Setup: uses Earth Engine (evidence: `backend/services/satellite_service.py`)
- Sentinel Hub Access → Earth Engine Setup: uses Earth Engine (evidence: `backend/services/sentinel_hub_service.py`)
- Claim Assessment → Demo or PostgreSQL Store: reads and writes claims (evidence: `backend/services/claim_service.py`)
- Farm Monitoring → Demo or PostgreSQL Store: reads and writes farms (evidence: `backend/services/farm_service.py`)
- Satellite Analysis → Demo or PostgreSQL Store: stores scan data (evidence: `backend/services/satellite_service.py`)
- Identity and Roles → Demo or PostgreSQL Store: reads users (evidence: `backend/services/auth_service.py`)
- Notifications → Demo or PostgreSQL Store: reads and writes alerts (evidence: `backend/services/notification_service.py`)
- Reports API → Demo or PostgreSQL Store: reads imagery dates (evidence: `backend/api/reports.py`)
- FastAPI Runtime → Earth Engine Setup: initializes service (evidence: `backend/main.py`)
- FastAPI Runtime → Satellite Analysis: warms imagery cache (evidence: `backend/main.py`)
