# shwet46/vyom-app architecture

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

- Interactive diagram: https://gitdiagram.com/shwet46/vyom-app
- Repository: https://github.com/shwet46/vyom-app

## Overview

VYOM is an AI business partner for small-shop merchants. Merchants use the web app to review sales opportunities, manage campaigns and credit, and use voice or camera workflows; the backend applies detection and safety rules, invokes AI where useful, and persists domain data. A Telegram bot provides customer-facing credit and festival-shop interactions, while background jobs refresh detections and dispatch work. The README documents these major connections; sampled source confirms selected entry points and handlers, but unsampled route and service internals limit finer call-level detail.

Main entry points: [`apps/api/src/vyom/api/v1`](https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/api/v1) (REST API), [`apps/api/src/vyom/bot/app.py`](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/bot/app.py) (Telegram bot), [`apps/web/src/App.tsx`](https://github.com/shwet46/vyom-app/blob/main/apps/web/src/App.tsx) (Merchant PWA), [`apps/web/src/services/api.ts`](https://github.com/shwet46/vyom-app/blob/main/apps/web/src/services/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_merchant["Merchant app"]
  node_web_app["Merchant PWA<br/>[App.tsx]"]
  node_web_api["API client<br/>[api.ts]"]
  node_voice_ui["Voice copilot UI"]
  node_khata_ui["Khata scanner UI"]
end

subgraph group_backend["Backend services"]
  node_api["REST API"]
  node_app_boot["Application runtime<br/>[main.py]"]
  node_sse["Live events<br/>[sse.py]"]
  node_ai_services["AI capabilities"]
  node_guardrails["Safety guardrails<br/>[guardrails.py]"]
  node_worker["Background jobs<br/>[jobs.py]"]
end

subgraph group_intelligence["Business intelligence"]
  node_detection["Opportunity detection"]
  node_proactive["Proactive engine<br/>[engine.py]"]
  node_festival["Festival intelligence"]
  node_campaigns["Campaign dispatch"]
end

subgraph group_customer["Customer channels"]
  node_web_bot["Telegram bot<br/>[app.py]"]
  node_bot_khata["Bot credit flows<br/>[khata.py]"]
  node_bot_catalog["Bot shop flows<br/>[catalog.py]"]
end

subgraph group_platform["Platform services"]
  node_mongo[("MongoDB")]
end

node_merchant_actor(("Merchant"))
node_customer_actor(("Shop customer"))
node_sarvam{{"Sarvam AI"}}
node_telegram{{"Telegram"}}

node_merchant_actor -->|"uses"| node_web_app
node_web_app -->|"requests data"| node_web_api
node_web_app -->|"opens copilot"| node_voice_ui
node_web_app -->|"opens scanner"| node_khata_ui
node_voice_ui -->|"sends voice"| node_web_api
node_khata_ui -->|"uploads scans"| node_web_api
node_web_api -->|"calls REST"| node_api
node_app_boot -->|"mounts routes"| node_api
node_api -->|"requests detection"| node_detection
node_api -->|"requests analysis"| node_proactive
node_api -->|"checks actions"| node_guardrails
node_api -->|"invokes AI"| node_ai_services
node_api -->|"reads and writes"| node_mongo
node_api -->|"publishes events"| node_sse
node_ai_services -->|"calls AI models"| node_sarvam
node_worker -->|"runs sweeps"| node_detection
node_worker -->|"updates state"| node_mongo
node_worker -->|"dispatches campaigns"| node_campaigns
node_campaigns -->|"validates sends"| node_guardrails
node_campaigns -->|"dispatches messages"| node_web_bot
node_web_bot -->|"registers handler"| node_bot_khata
node_web_bot -->|"registers handler"| node_bot_catalog
node_customer_actor -->|"messages"| node_telegram
node_telegram -->|"routes updates"| node_web_bot
node_bot_khata -->|"reads and writes ledger"| node_mongo
node_bot_khata -->|"requests OCR"| node_ai_services
node_bot_catalog -.->|"offers festival kits"| node_festival
node_festival -->|"informs opportunities"| node_detection
node_web_bot -->|"broadcasts events"| node_sse

click node_web_app "https://github.com/shwet46/vyom-app/blob/main/apps/web/src/App.tsx"
click node_web_api "https://github.com/shwet46/vyom-app/blob/main/apps/web/src/services/api.ts"
click node_voice_ui "https://github.com/shwet46/vyom-app/blob/main/apps/web/src/components/VoiceAssistantModal.tsx"
click node_khata_ui "https://github.com/shwet46/vyom-app/blob/main/apps/web/src/components/KhataScannerModal.tsx"
click node_api "https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/api/v1"
click node_app_boot "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/main.py"
click node_sse "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/core/sse.py"
click node_ai_services "https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/ai"
click node_guardrails "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/services/guardrails.py"
click node_detection "https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/services/detection"
click node_proactive "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/services/proactive_detection/engine.py"
click node_festival "https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/services/festival"
click node_campaigns "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/services/campaign_dispatch.py"
click node_web_bot "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/bot/app.py"
click node_bot_khata "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/bot/handlers/khata.py"
click node_bot_catalog "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/bot/handlers/catalog.py"
click node_worker "https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/worker/jobs.py"
click node_mongo "https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/db"

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_app,node_web_api,node_voice_ui,node_khata_ui toneBlue
class node_api,node_app_boot,node_sse,node_ai_services,node_guardrails,node_worker toneAmber
class node_detection,node_proactive,node_festival,node_campaigns toneMint
class node_web_bot,node_bot_khata,node_bot_catalog toneRose
class node_mongo,node_merchant_actor,node_customer_actor,node_sarvam,node_telegram toneIndigo
```

## Components

### Merchant app

- [Merchant PWA](https://github.com/shwet46/vyom-app/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [API client](https://github.com/shwet46/vyom-app/blob/main/apps/web/src/services/api.ts): `apps/web/src/services/api.ts`
- [Voice copilot UI](https://github.com/shwet46/vyom-app/blob/main/apps/web/src/components/VoiceAssistantModal.tsx): `apps/web/src/components/VoiceAssistantModal.tsx`
- [Khata scanner UI](https://github.com/shwet46/vyom-app/blob/main/apps/web/src/components/KhataScannerModal.tsx): `apps/web/src/components/KhataScannerModal.tsx`

### Backend services

- [REST API](https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/api/v1): `apps/api/src/vyom/api/v1`
- [Application runtime](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/main.py): `apps/api/src/vyom/main.py`
- [Live events](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/core/sse.py): `apps/api/src/vyom/core/sse.py`
- [AI capabilities](https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/ai): `apps/api/src/vyom/ai`
- [Safety guardrails](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/services/guardrails.py): `apps/api/src/vyom/services/guardrails.py`
- [Background jobs](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/worker/jobs.py): `apps/api/src/vyom/worker/jobs.py`

### Business intelligence

- [Opportunity detection](https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/services/detection): `apps/api/src/vyom/services/detection`
- [Proactive engine](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/services/proactive_detection/engine.py): `apps/api/src/vyom/services/proactive_detection/engine.py`
- [Festival intelligence](https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/services/festival): `apps/api/src/vyom/services/festival`
- [Campaign dispatch](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/services/campaign_dispatch.py): `apps/api/src/vyom/services/campaign_dispatch.py`

### Customer channels

- [Telegram bot](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/bot/app.py): `apps/api/src/vyom/bot/app.py`
- [Bot credit flows](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/bot/handlers/khata.py): `apps/api/src/vyom/bot/handlers/khata.py`
- [Bot shop flows](https://github.com/shwet46/vyom-app/blob/main/apps/api/src/vyom/bot/handlers/catalog.py): `apps/api/src/vyom/bot/handlers/catalog.py`

### Platform services

- [MongoDB](https://github.com/shwet46/vyom-app/tree/main/apps/api/src/vyom/db): `apps/api/src/vyom/db`

### Other components

- **Merchant**
- **Shop customer**
- **Sarvam AI**
- **Telegram**

## Connections

- Merchant → Merchant PWA: uses
- Merchant PWA → API client: requests data (evidence: `apps/web/src/App.tsx`)
- Merchant PWA → Voice copilot UI: opens copilot (evidence: `apps/web/src/App.tsx`)
- Merchant PWA → Khata scanner UI: opens scanner (evidence: `apps/web/src/App.tsx`)
- Voice copilot UI → API client: sends voice (evidence: `apps/web/src/services/api.ts`)
- Khata scanner UI → API client: uploads scans (evidence: `apps/web/src/services/api.ts`)
- API client → REST API: calls REST
- Application runtime → REST API: mounts routes (evidence: `apps/api/src/vyom/main.py`)
- REST API → Opportunity detection: requests detection
- REST API → Proactive engine: requests analysis
- REST API → Safety guardrails: checks actions
- REST API → AI capabilities: invokes AI
- REST API → MongoDB: reads and writes
- REST API → Live events: publishes events (evidence: `apps/api/src/vyom/api/v1/webhooks.py`)
- AI capabilities → Sarvam AI: calls AI models
- Background jobs → Opportunity detection: runs sweeps (evidence: `apps/api/src/vyom/worker/jobs.py`)
- Background jobs → MongoDB: updates state
- Background jobs → Campaign dispatch: dispatches campaigns (evidence: `apps/api/src/vyom/worker/jobs.py`)
- Campaign dispatch → Safety guardrails: validates sends
- Campaign dispatch → Telegram bot: dispatches messages (evidence: `apps/api/src/vyom/services/campaign_dispatch.py`)
- Telegram bot → Bot credit flows: registers handler (evidence: `apps/api/src/vyom/bot/app.py`)
- Telegram bot → Bot shop flows: registers handler (evidence: `apps/api/src/vyom/bot/app.py`)
- Shop customer → Telegram: messages
- Telegram → Telegram bot: routes updates
- Bot credit flows → MongoDB: reads and writes ledger (evidence: `apps/api/src/vyom/bot/handlers/khata.py`)
- Bot credit flows → AI capabilities: requests OCR (evidence: `apps/api/src/vyom/bot/handlers/khata.py`)
- Bot shop flows → Festival intelligence: offers festival kits
- Festival intelligence → Opportunity detection: informs opportunities
- Telegram bot → Live events: broadcasts events
