# shreyaaspires-cloud/satyasetu architecture

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

- Interactive diagram: https://gitdiagram.com/shreyaaspires-cloud/satyasetu
- Repository: https://github.com/shreyaaspires-cloud/satyasetu

## Overview

SatyaSetu accepts WhatsApp forwards and other check requests, extracts text from multimodal inputs, analyzes language and claims, retrieves evidence, scores claim stances, and formats a multilingual response. The documented WhatsApp path is Twilio webhook → ingestion → the fact-check pipeline → Twilio reply; a separate web simulation and check API are also present. The graph preserves the documented domain stages and key internal services. Some subsystem links rely on README architecture statements or SOURCE INDEX references because their implementations were not excerpted.

Main entry points: [`app/pipeline.py`](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/pipeline.py) (Pipeline orchestrator), [`app/features/retrieval/orchestrator.py`](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/orchestrator.py) (Evidence retrieval), [`app/routers/webhook.py`](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/routers/webhook.py) (Twilio webhook), [`app/features/verification/service.py`](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/verification/service.py) (Claim verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app_factory["FastAPI app<br/>[main.py]"]
  node_webhook["Twilio webhook<br/>[webhook.py]"]
  node_check_api["Check API<br/>[check.py]"]
end

subgraph group_ingest["Input processing"]
  node_ingest_service["Ingestion service<br/>[service.py]"]
  node_media_extract["Media extraction"]
end

subgraph group_intelligence["Fact-check engine"]
  node_nlp["Language and claims"]
  node_pipeline["Pipeline orchestrator<br/>[pipeline.py]"]
  node_retrieval["Evidence retrieval<br/>[orchestrator.py]"]
  node_factcheck_api["Fact-check sources"]
  node_official_search["Official search<br/>[official_search.py]"]
  node_web_search["Web search<br/>[search_web.py]"]
  node_wikipedia["Wikipedia context<br/>[wikipedia.py]"]
  node_verification["Claim verification<br/>[service.py]"]
  node_stance["Stance scoring<br/>[stance.py]"]
  node_claim_bank["Prechecked claims<br/>[claim_bank.py]"]
end

subgraph group_delivery["Reply and web"]
  node_explanation["Explanation generation<br/>[generator.py]"]
  node_formatter["WhatsApp formatter<br/>[formatter.py]"]
  node_twilio_client["Twilio sender<br/>[twilio_client.py]"]
  node_web_frontend["WhatsApp web UI<br/>[send.js]"]
  node_web_api["Web API client<br/>[api.js]"]
end

subgraph group_foundation["Shared services"]
  node_claims_db[("Claim log store<br/>[claims_db.py]")]
  node_cache["Response cache<br/>[cache.py]"]
  node_contracts["Pipeline contracts<br/>[models.py]"]
  node_security["URL and input security<br/>[security.py]"]
end

node_whatsapp_user(("WhatsApp user"))
node_twilio{{"Twilio WhatsApp"}}

node_whatsapp_user -->|"forwards media"| node_twilio
node_twilio -->|"posts webhook"| node_webhook
node_webhook -->|"ingests message"| node_ingest_service
node_webhook -->|"starts pipeline"| node_pipeline
node_pipeline -->|"runs analysis"| node_nlp
node_pipeline -->|"verifies claims"| node_verification
node_pipeline -->|"generates reply"| node_explanation
node_pipeline -->|"formats reply"| node_formatter
node_pipeline -->|"logs results"| node_claims_db
node_pipeline -->|"checks cache"| node_cache
node_ingest_service -->|"dispatches media"| node_media_extract
node_verification -->|"retrieves evidence"| node_retrieval
node_verification -->|"scores stance"| node_stance
node_verification -->|"checks claims"| node_claim_bank
node_retrieval -->|"queries"| node_factcheck_api
node_retrieval -->|"queries"| node_official_search
node_retrieval -->|"searches web"| node_web_search
node_retrieval -->|"queries context"| node_wikipedia
node_official_search -->|"uses search"| node_web_search
node_stance -->|"uses evidence"| node_official_search
node_web_search -->|"validates URLs"| node_security
node_ingest_service -.->|"guards input"| node_security
node_twilio_client -->|"sends reply"| node_twilio
node_webhook -->|"sends reply"| node_twilio_client
node_twilio -->|"delivers reply"| node_whatsapp_user
node_app_factory -->|"registers route"| node_webhook
node_app_factory -->|"registers route"| node_check_api
node_check_api -->|"runs check"| node_pipeline
node_web_frontend -->|"sends request"| node_web_api
node_web_api -.->|"calls check API"| node_check_api
node_pipeline -->|"uses schemas"| node_contracts

click node_app_factory "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/main.py"
click node_webhook "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/routers/webhook.py"
click node_check_api "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/routers/check.py"
click node_ingest_service "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/ingestion/service.py"
click node_media_extract "https://github.com/shreyaaspires-cloud/satyasetu/tree/main/app/features/ingestion"
click node_nlp "https://github.com/shreyaaspires-cloud/satyasetu/tree/main/app/features/nlp"
click node_pipeline "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/pipeline.py"
click node_retrieval "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/orchestrator.py"
click node_factcheck_api "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/factcheck_google.py"
click node_official_search "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/official_search.py"
click node_web_search "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/search_web.py"
click node_wikipedia "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/wikipedia.py"
click node_verification "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/verification/service.py"
click node_stance "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/verification/stance.py"
click node_claim_bank "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/verification/claim_bank.py"
click node_explanation "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/explanation/generator.py"
click node_formatter "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/explanation/formatter.py"
click node_twilio_client "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/core/twilio_client.py"
click node_web_frontend "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/web/whatsapp/js/features/send.js"
click node_web_api "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/web/whatsapp/js/api.js"
click node_claims_db "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/db/claims_db.py"
click node_cache "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/core/cache.py"
click node_contracts "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/contracts/models.py"
click node_security "https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/core/security.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_app_factory,node_webhook,node_check_api,node_whatsapp_user toneBlue
class node_ingest_service,node_media_extract toneAmber
class node_nlp,node_pipeline,node_retrieval,node_factcheck_api,node_official_search,node_web_search,node_wikipedia,node_verification,node_stance,node_claim_bank toneMint
class node_explanation,node_formatter,node_twilio_client,node_web_frontend,node_web_api toneRose
class node_claims_db,node_cache,node_contracts,node_security,node_twilio toneIndigo
```

## Components

### Application entry

- [FastAPI app](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/main.py): `app/main.py`
- [Twilio webhook](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/routers/webhook.py): `app/routers/webhook.py`
- [Check API](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/routers/check.py): `app/routers/check.py`

### Input processing

- [Ingestion service](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/ingestion/service.py): `app/features/ingestion/service.py`
- [Media extraction](https://github.com/shreyaaspires-cloud/satyasetu/tree/main/app/features/ingestion): `app/features/ingestion`

### Fact-check engine

- [Language and claims](https://github.com/shreyaaspires-cloud/satyasetu/tree/main/app/features/nlp): `app/features/nlp`
- [Pipeline orchestrator](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/pipeline.py): `app/pipeline.py`
- [Evidence retrieval](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/orchestrator.py): `app/features/retrieval/orchestrator.py`
- [Fact-check sources](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/factcheck_google.py): `app/features/retrieval/factcheck_google.py`
- [Official search](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/official_search.py): `app/features/retrieval/official_search.py`
- [Web search](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/search_web.py): `app/features/retrieval/search_web.py`
- [Wikipedia context](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/retrieval/wikipedia.py): `app/features/retrieval/wikipedia.py`
- [Claim verification](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/verification/service.py): `app/features/verification/service.py`
- [Stance scoring](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/verification/stance.py): `app/features/verification/stance.py`
- [Prechecked claims](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/verification/claim_bank.py): `app/features/verification/claim_bank.py`

### Reply and web

- [Explanation generation](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/explanation/generator.py): `app/features/explanation/generator.py`
- [WhatsApp formatter](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/features/explanation/formatter.py): `app/features/explanation/formatter.py`
- [Twilio sender](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/core/twilio_client.py): `app/core/twilio_client.py`
- [WhatsApp web UI](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/web/whatsapp/js/features/send.js): `web/whatsapp/js/features/send.js`
- [Web API client](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/web/whatsapp/js/api.js): `web/whatsapp/js/api.js`

### Shared services

- [Claim log store](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/db/claims_db.py): `app/db/claims_db.py`
- [Response cache](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/core/cache.py): `app/core/cache.py`
- [Pipeline contracts](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/contracts/models.py): `app/contracts/models.py`
- [URL and input security](https://github.com/shreyaaspires-cloud/satyasetu/blob/main/app/core/security.py): `app/core/security.py`

### Other components

- **WhatsApp user**
- **Twilio WhatsApp**

## Connections

- WhatsApp user → Twilio WhatsApp: forwards media
- Twilio WhatsApp → Twilio webhook: posts webhook
- Twilio webhook → Ingestion service: ingests message (evidence: `app/routers/webhook.py`)
- Twilio webhook → Pipeline orchestrator: starts pipeline (evidence: `app/routers/webhook.py`)
- Pipeline orchestrator → Language and claims: runs analysis (evidence: `app/pipeline.py`)
- Pipeline orchestrator → Claim verification: verifies claims (evidence: `app/pipeline.py`)
- Pipeline orchestrator → Explanation generation: generates reply (evidence: `app/pipeline.py`)
- Pipeline orchestrator → WhatsApp formatter: formats reply (evidence: `app/pipeline.py`)
- Pipeline orchestrator → Claim log store: logs results (evidence: `app/pipeline.py`)
- Pipeline orchestrator → Response cache: checks cache (evidence: `app/pipeline.py`)
- Ingestion service → Media extraction: dispatches media (evidence: `app/features/ingestion/service.py`)
- Claim verification → Evidence retrieval: retrieves evidence (evidence: `app/features/verification/service.py`)
- Claim verification → Stance scoring: scores stance (evidence: `app/features/verification/service.py`)
- Claim verification → Prechecked claims: checks claims (evidence: `app/features/verification/service.py`)
- Evidence retrieval → Fact-check sources: queries (evidence: `app/features/retrieval/orchestrator.py`)
- Evidence retrieval → Official search: queries (evidence: `app/features/retrieval/orchestrator.py`)
- Evidence retrieval → Web search: searches web (evidence: `app/features/retrieval/orchestrator.py`)
- Evidence retrieval → Wikipedia context: queries context (evidence: `app/features/retrieval/orchestrator.py`)
- Official search → Web search: uses search (evidence: `app/features/retrieval/official_search.py`)
- Stance scoring → Official search: uses evidence (evidence: `app/features/verification/stance.py`)
- Web search → URL and input security: validates URLs (evidence: `app/features/retrieval/search_web.py`)
- Ingestion service → URL and input security: guards input
- Twilio sender → Twilio WhatsApp: sends reply
- Twilio webhook → Twilio sender: sends reply (evidence: `app/routers/webhook.py`)
- Twilio WhatsApp → WhatsApp user: delivers reply
- FastAPI app → Twilio webhook: registers route (evidence: `app/main.py`)
- FastAPI app → Check API: registers route (evidence: `app/main.py`)
- Check API → Pipeline orchestrator: runs check (evidence: `app/routers/check.py`)
- WhatsApp web UI → Web API client: sends request (evidence: `web/whatsapp/js/features/send.js`)
- Web API client → Check API: calls check API
- Pipeline orchestrator → Pipeline contracts: uses schemas (evidence: `app/pipeline.py`)
