# jiyaagarwal2007-lang/swara-ai architecture

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

- Interactive diagram: https://gitdiagram.com/jiyaagarwal2007-lang/swara-ai
- Repository: https://github.com/jiyaagarwal2007-lang/swara-ai

## Overview

SWARA AI is a Flutter client and FastAPI service for English, Hindi, and Bengali translation, speech, documents, and tutoring. Its main workflow sends a client request to a feature API, performs translation or transcription as needed, and returns translated content or a tracked document job. The graph also shows authentication, user settings, history, and storage. Flutter source files and several feature implementations were not included in the supplied tree or excerpts, so those nodes use the existing `flutter` directory and only documented connections are shown.

Main entry points: [`backend/main.py`](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/main.py) (API entry), [`backend/app/services/translation_service.py`](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/translation_service.py) (Translation service), [`backend/app/database/session.py`](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/database/session.py) (SQL database), [`backend/app/services/auth_service.py`](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/auth_service.py) (Auth service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Flutter client"]
  node_app["Flutter app"]
end

subgraph group_api["API workflows"]
  node_api_entry["API entry<br/>[main.py]"]
  node_auth_api["Auth API<br/>[auth.py]"]
  node_auth_service["Auth service<br/>[auth_service.py]"]
  node_speech_api["Speech API<br/>[speech.py]"]
  node_subtitle_api["Subtitle API<br/>[subtitle.py]"]
  node_document_api["Document API<br/>[document.py]"]
  node_pdf_api["PDF API<br/>[pdf.py]"]
  node_document_jobs["Document jobs<br/>[document_task.py]"]
  node_pdf_jobs["PDF jobs<br/>[pdf_task.py]"]
  node_tutor_api["Tutor API<br/>[tutor.py]"]
  node_history_api["History API<br/>[history.py]"]
  node_settings_api["Settings API<br/>[settings.py]"]
end

subgraph group_ai["AI services"]
  node_translation["Translation service"]
  node_whisper["Whisper service<br/>[whisper_service.py]"]
end

subgraph group_state["State and files"]
  node_subtitle_state["Subtitle sessions"]
  node_storage["File storage<br/>[storage_service.py]"]
  node_database[("SQL database<br/>[session.py]")]
  node_models["Domain records"]
end

node_user(("App user"))
node_groq{{"Groq AI"}}
node_redis[("Redis and broker")]

node_user -->|"uses"| node_app
node_app -->|"REST requests"| node_api_entry
node_api_entry -->|"registers"| node_auth_api
node_api_entry -->|"registers"| node_speech_api
node_api_entry -->|"registers"| node_subtitle_api
node_api_entry -->|"registers"| node_document_api
node_api_entry -->|"registers"| node_pdf_api
node_api_entry -->|"registers"| node_tutor_api
node_api_entry -->|"registers"| node_history_api
node_api_entry -->|"registers"| node_settings_api
node_auth_api -->|"calls"| node_auth_service
node_auth_service -->|"reads/writes"| node_database
node_auth_service -->|"uses records"| node_models
node_speech_api -->|"transcribes"| node_whisper
node_speech_api -->|"translates"| node_translation
node_subtitle_api -->|"manages sessions"| node_subtitle_state
node_subtitle_state -->|"stores session state"| node_redis
node_document_api -->|"dispatches jobs"| node_document_jobs
node_pdf_api -->|"dispatches jobs"| node_pdf_jobs
node_document_jobs -->|"translates text"| node_translation
node_pdf_jobs -->|"translates text"| node_translation
node_document_jobs -->|"stores files"| node_storage
node_pdf_jobs -->|"stores files"| node_storage
node_translation -->|"requests translation"| node_groq
node_tutor_api -->|"requests chat"| node_groq
node_history_api -->|"reads/writes"| node_database
node_settings_api -->|"reads/writes"| node_database
node_storage --> node_database

click node_app "https://github.com/jiyaagarwal2007-lang/swara-ai/tree/main/flutter"
click node_api_entry "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/main.py"
click node_auth_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/auth.py"
click node_auth_service "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/auth_service.py"
click node_speech_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/speech.py"
click node_subtitle_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/subtitle.py"
click node_document_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/document.py"
click node_pdf_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/pdf.py"
click node_document_jobs "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/tasks/document_task.py"
click node_pdf_jobs "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/tasks/pdf_task.py"
click node_tutor_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/tutor.py"
click node_history_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/history.py"
click node_settings_api "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/settings.py"
click node_translation "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/translation_service.py"
click node_whisper "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/whisper_service.py"
click node_subtitle_state "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/subtitle_service.py"
click node_storage "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/storage_service.py"
click node_database "https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/database/session.py"
click node_models "https://github.com/jiyaagarwal2007-lang/swara-ai/tree/main/backend/app/models"

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,node_user toneBlue
class node_api_entry,node_auth_api,node_auth_service,node_speech_api,node_subtitle_api,node_document_api,node_pdf_api,node_document_jobs,node_pdf_jobs,node_tutor_api,node_history_api,node_settings_api,node_redis toneAmber
class node_translation,node_whisper toneMint
class node_subtitle_state,node_storage,node_database,node_models toneRose
class node_groq toneIndigo
```

## Components

### Flutter client

- [Flutter app](https://github.com/jiyaagarwal2007-lang/swara-ai/tree/main/flutter): `flutter`

### API workflows

- [API entry](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/main.py): `backend/main.py`
- [Auth API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Auth service](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Speech API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/speech.py): `backend/app/routers/speech.py`
- [Subtitle API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/subtitle.py): `backend/app/routers/subtitle.py`
- [Document API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/document.py): `backend/app/routers/document.py`
- [PDF API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/pdf.py): `backend/app/routers/pdf.py`
- [Document jobs](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/tasks/document_task.py): `backend/app/tasks/document_task.py`
- [PDF jobs](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/tasks/pdf_task.py): `backend/app/tasks/pdf_task.py`
- [Tutor API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/tutor.py): `backend/app/routers/tutor.py`
- [History API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/history.py): `backend/app/routers/history.py`
- [Settings API](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/routers/settings.py): `backend/app/routers/settings.py`

### AI services

- [Translation service](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/translation_service.py): `backend/app/services/translation_service.py`
- [Whisper service](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/whisper_service.py): `backend/app/services/whisper_service.py`

### State and files

- [Subtitle sessions](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/subtitle_service.py): `backend/app/services/subtitle_service.py`
- [File storage](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/services/storage_service.py): `backend/app/services/storage_service.py`
- [SQL database](https://github.com/jiyaagarwal2007-lang/swara-ai/blob/main/backend/app/database/session.py): `backend/app/database/session.py`
- [Domain records](https://github.com/jiyaagarwal2007-lang/swara-ai/tree/main/backend/app/models): `backend/app/models`

### Other components

- **App user**
- **Groq AI**
- **Redis and broker**

## Connections

- App user → Flutter app: uses
- Flutter app → API entry: REST requests
- API entry → Auth API: registers
- API entry → Speech API: registers
- API entry → Subtitle API: registers
- API entry → Document API: registers
- API entry → PDF API: registers
- API entry → Tutor API: registers
- API entry → History API: registers
- API entry → Settings API: registers
- Auth API → Auth service: calls
- Auth service → SQL database: reads/writes
- Auth service → Domain records: uses records
- Speech API → Whisper service: transcribes
- Speech API → Translation service: translates
- Subtitle API → Subtitle sessions: manages sessions
- Subtitle sessions → Redis and broker: stores session state
- Document API → Document jobs: dispatches jobs
- PDF API → PDF jobs: dispatches jobs
- Document jobs → Translation service: translates text
- PDF jobs → Translation service: translates text
- Document jobs → File storage: stores files
- PDF jobs → File storage: stores files
- Translation service → Groq AI: requests translation
- Tutor API → Groq AI: requests chat
- History API → SQL database: reads/writes
- Settings API → SQL database: reads/writes
- File storage → SQL database
