# yasaswini-ch/snap-safe-india architecture

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

- Interactive diagram: https://gitdiagram.com/yasaswini-ch/snap-safe-india
- Repository: https://github.com/yasaswini-ch/snap-safe-india

## Overview

Snap Safe India is a photo-privacy agent: a person submits a photo and optional caption through the web UI or a messaging bot, and receives a cleaned image plus an exposure report. Its core workflow decodes the image, checks visible text, asks a vision model to assess exposure, plans and applies edits, then rechecks the result. Region packs tailor detection and prompts; recorded runs support instant sample playback. The README and excerpts establish the main routes and calls; some implementation details are unsampled, so uncertain links are omitted.

Main entry points: [`app/agent.py`](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/agent.py) (Agent loop), [`app/meta.py`](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/meta.py) (Model calls), [`app/telegram_bot.py`](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/telegram_bot.py) (Telegram bot), [`app/whatsapp.py`](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/whatsapp.py) (WhatsApp webhook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User Interfaces"]
  node_web["Web interface<br/>[index.html]"]
  node_telegram["Telegram bot<br/>[telegram_bot.py]"]
  node_whatsapp["WhatsApp webhook<br/>[whatsapp.py]"]
end

subgraph group_service["Request Service"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_replay["Sample replay<br/>[samples.py]"]
  node_samples[("Recorded runs")]
end

subgraph group_analysis["Privacy Analysis"]
  node_agent["Agent loop<br/>[agent.py]"]
  node_textcheck["Text exposure check<br/>[meta.py]"]
  node_modelcalls["Model calls<br/>[meta.py]"]
  node_planner["Edit planning<br/>[agent.py]"]
  node_imagepipe["Image processing<br/>[pipeline.py]"]
end

subgraph group_regions["Regional Detection"]
  node_regionconfig["Region pack config<br/>[__init__.py]"]
  node_india["India pack<br/>[india.py]"]
  node_us["US pack<br/>[us.py]"]
  node_verhoeff["Aadhaar checksum<br/>[verhoeff.py]"]
end

subgraph group_integrations["External Services"]
  node_vision{{"Vision model"}}
  node_telegramapi{{"Telegram API"}}
  node_metaapi{{"WhatsApp Cloud API"}}
end

node_person(("Photo sender"))

node_person -->|"submits photo"| node_web
node_person -->|"sends photo"| node_telegram
node_person -->|"sends photo"| node_whatsapp
node_web -->|"uploads"| node_api
node_api -->|"runs scan"| node_agent
node_telegram -->|"runs scan"| node_agent
node_whatsapp -->|"runs scan"| node_agent
node_telegram -->|"exchanges messages"| node_telegramapi
node_whatsapp -->|"sends messages"| node_metaapi
node_api -->|"replays sample"| node_replay
node_replay -->|"reads recordings"| node_samples
node_agent -->|"checks text"| node_textcheck
node_agent -->|"requests assessment"| node_modelcalls
node_modelcalls -->|"sends photo prompt"| node_vision
node_vision -->|"returns exposure graph"| node_modelcalls
node_agent -->|"plans edits"| node_planner
node_agent -->|"decodes and edits"| node_imagepipe
node_agent -->|"rechecks edits"| node_modelcalls
node_modelcalls -->|"uses pack rules"| node_regionconfig
node_regionconfig -->|"registers pack"| node_india
node_regionconfig -->|"registers pack"| node_us
node_india -->|"validates Aadhaar"| node_verhoeff

click node_web "https://github.com/yasaswini-ch/snap-safe-india/blob/main/static/index.html"
click node_telegram "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/telegram_bot.py"
click node_whatsapp "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/whatsapp.py"
click node_api "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/main.py"
click node_replay "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/samples.py"
click node_samples "https://github.com/yasaswini-ch/snap-safe-india/tree/main/static/samples"
click node_agent "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/agent.py"
click node_textcheck "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/meta.py"
click node_modelcalls "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/meta.py"
click node_planner "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/agent.py"
click node_imagepipe "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/pipeline.py"
click node_regionconfig "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/__init__.py"
click node_india "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/india.py"
click node_us "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/us.py"
click node_verhoeff "https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/verhoeff.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,node_telegram,node_whatsapp toneBlue
class node_api,node_replay,node_samples toneAmber
class node_agent,node_textcheck,node_modelcalls,node_planner,node_imagepipe toneMint
class node_regionconfig,node_india,node_us,node_verhoeff toneRose
class node_vision,node_telegramapi,node_metaapi,node_person toneIndigo
```

## Components

### User Interfaces

- [Web interface](https://github.com/yasaswini-ch/snap-safe-india/blob/main/static/index.html): `static/index.html`
- [Telegram bot](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/telegram_bot.py): `app/telegram_bot.py`
- [WhatsApp webhook](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/whatsapp.py): `app/whatsapp.py`

### Request Service

- [FastAPI routes](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/main.py): `app/main.py`
- [Sample replay](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/samples.py): `app/samples.py`
- [Recorded runs](https://github.com/yasaswini-ch/snap-safe-india/tree/main/static/samples): `static/samples`

### Privacy Analysis

- [Agent loop](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/agent.py): `app/agent.py`
- [Text exposure check](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/meta.py): `app/meta.py`
- [Model calls](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/meta.py): `app/meta.py`
- [Edit planning](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/agent.py): `app/agent.py`
- [Image processing](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/pipeline.py): `app/pipeline.py`

### Regional Detection

- [Region pack config](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/__init__.py): `app/regions/__init__.py`
- [India pack](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/india.py): `app/regions/india.py`
- [US pack](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/us.py): `app/regions/us.py`
- [Aadhaar checksum](https://github.com/yasaswini-ch/snap-safe-india/blob/main/app/regions/verhoeff.py): `app/regions/verhoeff.py`

### External Services

- **Vision model**
- **Telegram API**
- **WhatsApp Cloud API**

### Other components

- **Photo sender**

## Connections

- Photo sender → Web interface: submits photo (evidence: `README.md`)
- Photo sender → Telegram bot: sends photo (evidence: `README.md`)
- Photo sender → WhatsApp webhook: sends photo (evidence: `README.md`)
- Web interface → FastAPI routes: uploads (evidence: `README.md`)
- FastAPI routes → Agent loop: runs scan (evidence: `README.md`)
- Telegram bot → Agent loop: runs scan (evidence: `README.md`)
- WhatsApp webhook → Agent loop: runs scan (evidence: `app/whatsapp.py`)
- Telegram bot → Telegram API: exchanges messages (evidence: `app/telegram_bot.py`)
- WhatsApp webhook → WhatsApp Cloud API: sends messages (evidence: `app/whatsapp.py`)
- FastAPI routes → Sample replay: replays sample (evidence: `app/main.py`)
- Sample replay → Recorded runs: reads recordings (evidence: `app/samples.py`)
- Agent loop → Text exposure check: checks text (evidence: `README.md`)
- Agent loop → Model calls: requests assessment (evidence: `README.md`)
- Model calls → Vision model: sends photo prompt (evidence: `README.md`)
- Vision model → Model calls: returns exposure graph (evidence: `README.md`)
- Agent loop → Edit planning: plans edits (evidence: `README.md`)
- Agent loop → Image processing: decodes and edits (evidence: `app/agent.py`)
- Agent loop → Model calls: rechecks edits (evidence: `README.md`)
- Model calls → Region pack config: uses pack rules (evidence: `app/meta.py`)
- Region pack config → India pack: registers pack (evidence: `app/regions/__init__.py`)
- Region pack config → US pack: registers pack (evidence: `app/regions/__init__.py`)
- India pack → Aadhaar checksum: validates Aadhaar (evidence: `app/regions/india.py`)
