# david6604/bhashasetu architecture

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

- Interactive diagram: https://gitdiagram.com/david6604/bhashasetu
- Repository: https://github.com/david6604/bhashasetu

## Overview

BhashaSetu is a multilingual translation application: users submit text or audio through a web interface or API, the gateway coordinates translation and account features, and a Python service detects languages and translates text. The README also documents authentication, history, caching, resilience controls, rate limiting, and OpenAPI; WebSocket rooms and broadcasts are visible in the gateway excerpt. Voice-service internals and several gateway integrations are not fully sampled, so those links are limited to documented capabilities and visible calls.

Main entry points: [`server/index.js`](https://github.com/david6604/bhashasetu/blob/main/server/index.js) (HTTP gateway), [`python_service/main.py`](https://github.com/david6604/bhashasetu/blob/main/python_service/main.py) (Translation API), [`frontend/src/pages/TranslatePage.tsx`](https://github.com/david6604/bhashasetu/blob/main/frontend/src/pages/TranslatePage.tsx) (Translation UI), [`frontend/src/App.tsx`](https://github.com/david6604/bhashasetu/blob/main/frontend/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["Web application<br/>[App.tsx]"]
  node_translatepage["Translation UI<br/>[TranslatePage.tsx]"]
  node_translationstate["Translation state<br/>[index.ts]"]
  node_translateapi["Translation API client<br/>[translate.ts]"]
end

subgraph group_gateway["API gateway"]
  node_gatewayapi["HTTP gateway<br/>[index.js]"]
  node_voicegateway["Voice upload route<br/>[index.js]"]
  node_redis[("Redis cache<br/>[cache.js]")]
  node_gatewaycontrols["Gateway controls"]
  node_gatewaycircuit["Gateway circuit breaker<br/>[circuit.js]"]
  node_openapi["API documentation<br/>[openapi.js]"]
end

subgraph group_translation["Translation services"]
  node_pythonapi["Translation API<br/>[main.py]"]
  node_detection["Language detection<br/>[main.py]"]
  node_engine["NLLB engine"]
  node_voice["Voice translation<br/>[voice.py]"]
end

subgraph group_accounts["Accounts and history"]
  node_auth["JWT authentication<br/>[auth.js]"]
  node_history["Translation history<br/>[index.js]"]
  node_translationdb[("Translation records<br/>[schema.prisma]")]
end

subgraph group_realtime["Realtime"]
  node_websocket["WebSocket rooms and broadcasts<br/>[index.js]"]
  node_rooms["Room manager<br/>[roomManager.js]"]
  node_broadcasts["Broadcast subscriptions"]
end

node_user(("Translator"))

node_user -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_translatepage
node_translatepage -->|"reads and updates"| node_translationstate
node_translatepage -->|"requests translation"| node_translateapi
node_translateapi -->|"sends request"| node_gatewayapi
node_gatewayapi -->|"forwards translation"| node_pythonapi
node_pythonapi -->|"detects language"| node_detection
node_pythonapi -->|"translates text"| node_engine
node_voicegateway -->|"forwards audio"| node_voice
node_gatewayapi -->|"mounts auth routes"| node_auth
node_gatewayapi -->|"serves history"| node_history
node_history -->|"reads records"| node_translationdb
node_gatewayapi -->|"stores translations"| node_translationdb
node_gatewayapi -.->|"caches"| node_redis
node_gatewayapi -.->|"rate limits"| node_gatewaycontrols
node_gatewayapi -.->|"uses breaker"| node_gatewaycircuit
node_gatewayapi -->|"mounts docs"| node_openapi
node_gatewayapi -->|"handles connections"| node_websocket
node_websocket -->|"manages rooms"| node_rooms
node_websocket -->|"manages subscriptions"| node_broadcasts
node_websocket -->|"requests detection and translation"| node_pythonapi

click node_webapp "https://github.com/david6604/bhashasetu/blob/main/frontend/src/App.tsx"
click node_translatepage "https://github.com/david6604/bhashasetu/blob/main/frontend/src/pages/TranslatePage.tsx"
click node_translationstate "https://github.com/david6604/bhashasetu/blob/main/frontend/src/store/index.ts"
click node_translateapi "https://github.com/david6604/bhashasetu/blob/main/frontend/src/api/translate.ts"
click node_gatewayapi "https://github.com/david6604/bhashasetu/blob/main/server/index.js"
click node_auth "https://github.com/david6604/bhashasetu/blob/main/server/auth.js"
click node_history "https://github.com/david6604/bhashasetu/blob/main/server/index.js"
click node_translationdb "https://github.com/david6604/bhashasetu/blob/main/prisma/schema.prisma"
click node_voicegateway "https://github.com/david6604/bhashasetu/blob/main/server/index.js"
click node_pythonapi "https://github.com/david6604/bhashasetu/blob/main/python_service/main.py"
click node_detection "https://github.com/david6604/bhashasetu/blob/main/python_service/main.py"
click node_engine "https://github.com/david6604/bhashasetu/blob/main/python_service/translation_engine.py"
click node_voice "https://github.com/david6604/bhashasetu/blob/main/python_service/voice.py"
click node_redis "https://github.com/david6604/bhashasetu/blob/main/server/cache.js"
click node_gatewaycircuit "https://github.com/david6604/bhashasetu/blob/main/server/circuit.js"
click node_openapi "https://github.com/david6604/bhashasetu/blob/main/server/openapi.js"
click node_websocket "https://github.com/david6604/bhashasetu/blob/main/server/index.js"
click node_rooms "https://github.com/david6604/bhashasetu/blob/main/server/roomManager.js"
click node_broadcasts "https://github.com/david6604/bhashasetu/blob/main/server/broadcastManager.js"

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_webapp,node_translatepage,node_translationstate,node_translateapi toneBlue
class node_gatewayapi,node_voicegateway,node_redis,node_gatewaycontrols,node_gatewaycircuit,node_openapi toneAmber
class node_pythonapi,node_detection,node_engine,node_voice toneMint
class node_auth,node_history,node_translationdb toneRose
class node_websocket,node_rooms,node_broadcasts,node_user toneIndigo
```

## Components

### Web client

- [Web application](https://github.com/david6604/bhashasetu/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Translation UI](https://github.com/david6604/bhashasetu/blob/main/frontend/src/pages/TranslatePage.tsx): `frontend/src/pages/TranslatePage.tsx`
- [Translation state](https://github.com/david6604/bhashasetu/blob/main/frontend/src/store/index.ts): `frontend/src/store/index.ts`
- [Translation API client](https://github.com/david6604/bhashasetu/blob/main/frontend/src/api/translate.ts): `frontend/src/api/translate.ts`

### API gateway

- [HTTP gateway](https://github.com/david6604/bhashasetu/blob/main/server/index.js): `server/index.js`
- [Voice upload route](https://github.com/david6604/bhashasetu/blob/main/server/index.js): `server/index.js`
- [Redis cache](https://github.com/david6604/bhashasetu/blob/main/server/cache.js): `server/cache.js`
- **Gateway controls**
- [Gateway circuit breaker](https://github.com/david6604/bhashasetu/blob/main/server/circuit.js): `server/circuit.js`
- [API documentation](https://github.com/david6604/bhashasetu/blob/main/server/openapi.js): `server/openapi.js`

### Translation services

- [Translation API](https://github.com/david6604/bhashasetu/blob/main/python_service/main.py): `python_service/main.py`
- [Language detection](https://github.com/david6604/bhashasetu/blob/main/python_service/main.py): `python_service/main.py`
- [NLLB engine](https://github.com/david6604/bhashasetu/blob/main/python_service/translation_engine.py): `python_service/translation_engine.py`
- [Voice translation](https://github.com/david6604/bhashasetu/blob/main/python_service/voice.py): `python_service/voice.py`

### Accounts and history

- [JWT authentication](https://github.com/david6604/bhashasetu/blob/main/server/auth.js): `server/auth.js`
- [Translation history](https://github.com/david6604/bhashasetu/blob/main/server/index.js): `server/index.js`
- [Translation records](https://github.com/david6604/bhashasetu/blob/main/prisma/schema.prisma): `prisma/schema.prisma`

### Realtime

- [WebSocket rooms and broadcasts](https://github.com/david6604/bhashasetu/blob/main/server/index.js): `server/index.js`
- [Room manager](https://github.com/david6604/bhashasetu/blob/main/server/roomManager.js): `server/roomManager.js`
- [Broadcast subscriptions](https://github.com/david6604/bhashasetu/blob/main/server/broadcastManager.js): `server/broadcastManager.js`

### Other components

- **Translator**

## Connections

- Translator → Web application: uses
- Web application → Translation UI: routes to
- Translation UI → Translation state: reads and updates
- Translation UI → Translation API client: requests translation
- Translation API client → HTTP gateway: sends request
- HTTP gateway → Translation API: forwards translation
- Translation API → Language detection: detects language
- Translation API → NLLB engine: translates text
- Voice upload route → Voice translation: forwards audio
- HTTP gateway → JWT authentication: mounts auth routes
- HTTP gateway → Translation history: serves history
- Translation history → Translation records: reads records
- HTTP gateway → Translation records: stores translations
- HTTP gateway → Redis cache: caches
- HTTP gateway → Gateway controls: rate limits
- HTTP gateway → Gateway circuit breaker: uses breaker
- HTTP gateway → API documentation: mounts docs
- HTTP gateway → WebSocket rooms and broadcasts: handles connections
- WebSocket rooms and broadcasts → Room manager: manages rooms
- WebSocket rooms and broadcasts → Broadcast subscriptions: manages subscriptions
- WebSocket rooms and broadcasts → Translation API: requests detection and translation
