# tanujkumar24/multi-lingual-ai-assistant architecture

> Architecture diagram of the GitHub repository tanujkumar24/multi-lingual-ai-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tanujkumar24/multi-lingual-ai-assistant
- Repository: https://github.com/tanujkumar24/multi-lingual-ai-assistant

## Overview

##### Project type and purpose
- This is a Python‐based, single‐page web application built with Streamlit.
- It implements a “multilingual assistant” that takes user speech, converts it to text, sends it to a language model (PaLM2), and then renders and speaks back the response via text-to-speech.

##### File structure
- At the root:
- app.py – the Streamlit entry point that ties UI to backend logic.
- requirements.txt / setup.py / multilingual_assistant.egg-info – packaging + dependencies.
- speech.mp3 – sample media asset.
- research/ – Jupyter notebook for experiments; not part of runtime.
- src/
- helper.py – utility functions for calling Google APIs.
- template.py – UI rendering helpers or response templates.

##### README
- Tech stack: Python, Streamlit, Google APIs (Speech-to-Text, PaLM2, Text-to-Speech).
- Runs locally via `streamlit run app.py` or on an EC2 instance.
- Requires a .env file with `GOOGLE_API_KEY`.

##### Main components
a. Client / User
- Browser / Streamlit front-end UI
b. Streamlit Server (app.py)
- UI layer (widgets, audio capture, display)
- Controller/business logic (routes user requests to helper functions)
c. Application modules (src/helper.py, src/template.py)
- API integration layer
d. External services (Google Cloud APIs)
- Speech-to-Text (s2t)
- Language Model (PaLM2)
- Text-to-Speech (t2s)
e. Deployment environment (optional)
- AWS EC2 instance running the Streamlit process

##### Relationships and data flows
- User → Browser UI: clicks “Record” or types text
- Browser → Streamlit Server: HTTP/WebSocket requests carrying audio blobs or text
- Streamlit Server → Helper Module → Google Speech-to-Text API (audio → transcript)
- Google STT API → Helper → Streamlit Server (transcript)
- Streamlit Server → PaLM2 API (prompt + transcript → response text)
- PaLM2 API → Streamlit Server (response text)
- Streamlit Server → Google TTS API (text → speech audio)
- Google TTS → Streamlit Server → Browser (plays audio)

##### Architectural patterns / design principles
- Layered architecture:
- Presentation (Streamlit UI)
- Orchestration / Controller (app.py)
- Integration layer (helper.py calls external APIs)
- Single‐process, single‐codebase design (no microservices)
- Clear separation of concerns: UI vs. business logic vs. external dependencies

##### Essential elements
- Clear labels on every node (e.g., “Streamlit Server”, “Google TTS”)
- Arrowheads showing direction of data (uni- or bi-directional)

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Application Layer
  subgraph "Application Layer"
    App["Streamlit Server<br/>Streamlit (Python)<br/>UI & Controller"]:::internal
    Helper["API Integration Layer<br/>helper.py"]:::internal
    Template["UI Rendering / Response Templates<br/>template.py"]:::internal
  end

  %% External Services
  subgraph "External Services"
    STT["Google Cloud STT"]:::external
    LLM["PaLM2 API"]:::external
    TTS["Google Cloud TTS"]:::external
  end

  %% Deployment
  subgraph "Deployment"
    EC2["AWS EC2 Instance<br/>port 8501"]:::deployment
  end

  %% Assets & Packaging
  subgraph "Assets & Packaging"
    Req["requirements.txt"]:::package
    Setup["setup.py"]:::package
    Egg["multilingual_assistant.egg-info/"]:::package
    Sample["speech.mp3"]:::asset
    Research["research/trials.ipynb"]:::research
  end

  %% Client
  User["Browser UI"]:::external

  %% Relationships
  User -->|"audio/text"| App
  App -->|"calls API"| Helper
  App -->|"renders UI"| Template
  Helper -->|"audio→transcript"| STT
  STT -->|"JSON transcript"| Helper
  Helper -->|"returns transcript"| App
  App -->|"prompt+transcript"| LLM
  LLM -->|"response text"| App
  App -->|"text→audio"| TTS
  TTS -->|"audio blob"| App
  App -->|"plays audio"| User
  EC2 --> App

  %% Click Events
  click App "https://github.com/tanujkumar24/multi-lingual-ai-assistant/blob/master/app.py"
  click Helper "https://github.com/tanujkumar24/multi-lingual-ai-assistant/blob/master/src/helper.py"
  click Template "https://github.com/tanujkumar24/multi-lingual-ai-assistant/blob/master/template.py"
  click Req "https://github.com/tanujkumar24/multi-lingual-ai-assistant/blob/master/requirements.txt"
  click Setup "https://github.com/tanujkumar24/multi-lingual-ai-assistant/blob/master/setup.py"
  click Egg "https://github.com/tanujkumar24/multi-lingual-ai-assistant/tree/master/multilingual_assistant.egg-info/"
  click Sample "https://github.com/tanujkumar24/multi-lingual-ai-assistant/blob/master/speech.mp3"
  click Research "https://github.com/tanujkumar24/multi-lingual-ai-assistant/blob/master/research/trials.ipynb"

  %% Styles
  classDef internal fill:#E0F7FA,stroke:#006064,color:#004D40
  classDef external fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
  classDef deployment fill:#FFF3E0,stroke:#EF6C00,color:#E65100
  classDef package fill:#ECEFF1,stroke:#455A64,color:#263238
  classDef asset fill:#FFFDE7,stroke:#F9A825,color:#F57F17
  classDef research fill:#FCE4EC,stroke:#C2185B,color:#880E4F
```
