# 23f2001033/environmental-hacks architecture

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

- Interactive diagram: https://gitdiagram.com/23f2001033/environmental-hacks
- Repository: https://github.com/23f2001033/environmental-hacks

## Overview

JalSaathi turns JJM-WQMIS drinking-water failures into village cases, contaminant-specific Hindi/English alerts, and a tracked remediation workflow that requires field-kit and lab re-tests to pass before closure. The graph covers ingestion and classification, case handling, messaging and read models, and the supporting data store. Evidence is limited to the supplied excerpts, SOURCE INDEX references, and README; unsampled subsystem links are omitted where their wiring is not shown.

Main entry points: [`src/jalsaathi/case_steps.py`](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/case_steps.py) (Case steps), [`src/jalsaathi/webhook.py`](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/webhook.py) (Bot webhook), [`src/jalsaathi/ingest.py`](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/ingest.py) (Failure ingestion), [`src/jalsaathi/store.py`](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/store.py) (DynamoDB access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data ingestion"]
  node_ingestor["Failure ingestion<br/>[ingest.py]"]
  node_wqmis["WQMIS access<br/>[wqmis.py]"]
  node_portal["Portal adapter<br/>[wqmis_portal.py]"]
  node_http["HTTP adapter<br/>[wqmis_http.py]"]
  node_parser["Record parsing<br/>[parse.py]"]
  node_geo["Geocoding<br/>[geo.py]"]
end

subgraph group_workflow["Case workflow"]
  node_cases["Case steps<br/>[case_steps.py]"]
  node_rules["Severity and timers<br/>[rules.py]"]
  node_advice["Contaminant advice<br/>[advice.py]"]
  node_policy["Action policy<br/>[policy.py]"]
end

subgraph group_messaging["Alerts and interaction"]
  node_webhook["Bot webhook<br/>[webhook.py]"]
  node_telegram["Telegram client<br/>[telegram.py]"]
  node_voice["Voice notes<br/>[voice.py]"]
  node_vision["Kit photo hint<br/>[vision.py]"]
  node_i18n["Bot translations<br/>[i18n.py]"]
end

subgraph group_data["Data and policy"]
  node_store["DynamoDB access<br/>[store.py]"]
  node_dynamodb[("DynamoDB")]
  node_config["Runtime configuration<br/>[config.py]"]
  node_paths["Bundled data paths<br/>[paths.py]"]
  node_infra["AWS runtime stack<br/>[stack.py]"]
end

subgraph group_access["User access"]
  node_api["Web API<br/>[api.py]"]
  node_views["Shared read models<br/>[views.py]"]
  node_actions["Admin actions<br/>[actions.py]"]
end

node_labs(("JJM-WQMIS"))
node_village(("Village relay / engineer"))

node_labs -->|"supplies results"| node_ingestor
node_ingestor -->|"uses source access"| node_wqmis
node_ingestor -->|"parses records"| node_parser
node_ingestor -->|"classifies failures"| node_rules
node_ingestor -->|"geocodes villages"| node_geo
node_ingestor -->|"writes cases"| node_store
node_ingestor -->|"starts workflows"| node_infra
node_cases -->|"records progress"| node_store
node_cases -->|"uses deadlines"| node_rules
node_cases -->|"builds alerts"| node_advice
node_cases -->|"checks permission"| node_policy
node_cases -->|"sends messages"| node_telegram
node_cases -->|"prepares audio"| node_voice
node_webhook -->|"handles callbacks"| node_cases
node_webhook -->|"dispatches actions"| node_actions
node_webhook -->|"parses and replies"| node_telegram
node_webhook -->|"requests photo hint"| node_vision
node_webhook -->|"reads subscriptions"| node_store
node_webhook -->|"formats prompts"| node_i18n
node_village -.->|"submits bot updates"| node_webhook
node_village -.->|"views case status"| node_api
node_api -->|"builds responses"| node_views
node_api -->|"reads and updates"| node_store
node_views -->|"loads case data"| node_store
node_views -->|"includes advice"| node_advice
node_views -->|"provides audio URLs"| node_voice
node_store -->|"reads and writes"| node_dynamodb
node_rules -->|"uses normalization"| node_parser
node_advice -->|"uses contaminant rules"| node_rules
node_advice -->|"loads advice content"| node_paths
node_policy -->|"loads policy files"| node_paths
node_voice -->|"uses voice scripts"| node_advice
node_voice -->|"stores audio metadata"| node_store
node_infra -->|"configures task handler"| node_cases
node_infra -->|"configures webhook"| node_webhook

click node_ingestor "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/ingest.py"
click node_wqmis "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/wqmis.py"
click node_portal "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/wqmis_portal.py"
click node_http "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/wqmis_http.py"
click node_parser "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/parse.py"
click node_geo "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/geo.py"
click node_cases "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/case_steps.py"
click node_rules "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/rules.py"
click node_advice "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/advice.py"
click node_policy "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/policy.py"
click node_webhook "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/webhook.py"
click node_telegram "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/telegram.py"
click node_voice "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/voice.py"
click node_vision "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/vision.py"
click node_i18n "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/i18n.py"
click node_api "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/api.py"
click node_views "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/views.py"
click node_store "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/store.py"
click node_config "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/config.py"
click node_paths "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/paths.py"
click node_actions "https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/actions.py"
click node_infra "https://github.com/23f2001033/environmental-hacks/blob/main/infra/stack.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_ingestor,node_wqmis,node_portal,node_http,node_parser,node_geo toneBlue
class node_cases,node_rules,node_advice,node_policy toneAmber
class node_webhook,node_telegram,node_voice,node_vision,node_i18n toneMint
class node_store,node_dynamodb,node_config,node_paths,node_infra toneRose
class node_api,node_views,node_actions,node_labs,node_village toneIndigo
```

## Components

### Data ingestion

- [Failure ingestion](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/ingest.py): `src/jalsaathi/ingest.py`
- [WQMIS access](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/wqmis.py): `src/jalsaathi/wqmis.py`
- [Portal adapter](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/wqmis_portal.py): `src/jalsaathi/wqmis_portal.py`
- [HTTP adapter](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/wqmis_http.py): `src/jalsaathi/wqmis_http.py`
- [Record parsing](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/parse.py): `src/jalsaathi/parse.py`
- [Geocoding](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/geo.py): `src/jalsaathi/geo.py`

### Case workflow

- [Case steps](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/case_steps.py): `src/jalsaathi/case_steps.py`
- [Severity and timers](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/rules.py): `src/jalsaathi/rules.py`
- [Contaminant advice](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/advice.py): `src/jalsaathi/advice.py`
- [Action policy](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/policy.py): `src/jalsaathi/policy.py`

### Alerts and interaction

- [Bot webhook](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/webhook.py): `src/jalsaathi/webhook.py`
- [Telegram client](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/telegram.py): `src/jalsaathi/telegram.py`
- [Voice notes](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/voice.py): `src/jalsaathi/voice.py`
- [Kit photo hint](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/vision.py): `src/jalsaathi/vision.py`
- [Bot translations](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/i18n.py): `src/jalsaathi/i18n.py`

### Data and policy

- [DynamoDB access](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/store.py): `src/jalsaathi/store.py`
- **DynamoDB**
- [Runtime configuration](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/config.py): `src/jalsaathi/config.py`
- [Bundled data paths](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/paths.py): `src/jalsaathi/paths.py`
- [AWS runtime stack](https://github.com/23f2001033/environmental-hacks/blob/main/infra/stack.py): `infra/stack.py`

### User access

- [Web API](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/api.py): `src/jalsaathi/api.py`
- [Shared read models](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/views.py): `src/jalsaathi/views.py`
- [Admin actions](https://github.com/23f2001033/environmental-hacks/blob/main/src/jalsaathi/actions.py): `src/jalsaathi/actions.py`

### Other components

- **JJM-WQMIS**
- **Village relay / engineer**

## Connections

- JJM-WQMIS → Failure ingestion: supplies results (evidence: `README.md`)
- Failure ingestion → WQMIS access: uses source access (evidence: `src/jalsaathi/ingest.py`)
- Failure ingestion → Record parsing: parses records (evidence: `src/jalsaathi/ingest.py`)
- Failure ingestion → Severity and timers: classifies failures (evidence: `src/jalsaathi/ingest.py`)
- Failure ingestion → Geocoding: geocodes villages (evidence: `src/jalsaathi/ingest.py`)
- Failure ingestion → DynamoDB access: writes cases (evidence: `src/jalsaathi/ingest.py`)
- Failure ingestion → AWS runtime stack: starts workflows (evidence: `src/jalsaathi/ingest.py`)
- Case steps → DynamoDB access: records progress (evidence: `src/jalsaathi/case_steps.py`)
- Case steps → Severity and timers: uses deadlines (evidence: `src/jalsaathi/case_steps.py`)
- Case steps → Contaminant advice: builds alerts (evidence: `src/jalsaathi/case_steps.py`)
- Case steps → Action policy: checks permission (evidence: `src/jalsaathi/case_steps.py`)
- Case steps → Telegram client: sends messages (evidence: `src/jalsaathi/case_steps.py`)
- Case steps → Voice notes: prepares audio (evidence: `src/jalsaathi/case_steps.py`)
- Bot webhook → Case steps: handles callbacks (evidence: `src/jalsaathi/webhook.py`)
- Bot webhook → Admin actions: dispatches actions (evidence: `src/jalsaathi/webhook.py`)
- Bot webhook → Telegram client: parses and replies (evidence: `src/jalsaathi/webhook.py`)
- Bot webhook → Kit photo hint: requests photo hint (evidence: `src/jalsaathi/webhook.py`)
- Bot webhook → DynamoDB access: reads subscriptions (evidence: `src/jalsaathi/webhook.py`)
- Bot webhook → Bot translations: formats prompts (evidence: `src/jalsaathi/webhook.py`)
- Village relay / engineer → Bot webhook: submits bot updates (evidence: `README.md`)
- Village relay / engineer → Web API: views case status (evidence: `README.md`)
- Web API → Shared read models: builds responses (evidence: `src/jalsaathi/api.py`)
- Web API → DynamoDB access: reads and updates (evidence: `src/jalsaathi/api.py`)
- Shared read models → DynamoDB access: loads case data (evidence: `src/jalsaathi/views.py`)
- Shared read models → Contaminant advice: includes advice (evidence: `src/jalsaathi/views.py`)
- Shared read models → Voice notes: provides audio URLs (evidence: `src/jalsaathi/views.py`)
- DynamoDB access → DynamoDB: reads and writes (evidence: `src/jalsaathi/store.py`)
- Severity and timers → Record parsing: uses normalization (evidence: `src/jalsaathi/rules.py`)
- Contaminant advice → Severity and timers: uses contaminant rules (evidence: `src/jalsaathi/advice.py`)
- Contaminant advice → Bundled data paths: loads advice content (evidence: `src/jalsaathi/advice.py`)
- Action policy → Bundled data paths: loads policy files (evidence: `src/jalsaathi/policy.py`)
- Voice notes → Contaminant advice: uses voice scripts (evidence: `src/jalsaathi/voice.py`)
- Voice notes → DynamoDB access: stores audio metadata (evidence: `src/jalsaathi/voice.py`)
- AWS runtime stack → Case steps: configures task handler (evidence: `infra/stack.py`)
- AWS runtime stack → Bot webhook: configures webhook (evidence: `infra/stack.py`)
