# userkhalid35/codealpha_language_translation_tool architecture

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

- Interactive diagram: https://gitdiagram.com/userkhalid35/codealpha_language_translation_tool
- Repository: https://github.com/userkhalid35/codealpha_language_translation_tool

## Overview

This is a PySide6 desktop translation application. Users enter text and language choices in the window; the controller dispatches translation to a background worker, which chunks text and calls Google translation services, then returns results for display and history. The app also supports language detection/selection, searchable favorites/history, theme switching, persistent settings, and connectivity monitoring. Edges reflect shown calls or README-described behavior; some UI and worker details are only partially excerpted.

Main entry points: [`controllers/main_controller.py`](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/controllers/main_controller.py) (Main controller), [`ui/main_window.py`](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/ui/main_window.py) (Translation window), [`services/translation_service.py`](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py) (Translation worker), [`main.py`](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/main.py) (App bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application flow"]
  node_entry["App bootstrap<br/>[main.py]"]
  node_controller["Main controller<br/>[main_controller.py]"]
  node_network_worker["Connectivity monitor<br/>[main_window.py]"]
  node_network_check["Connectivity check<br/>[helpers.py]"]
end

subgraph group_translation["Translation"]
  node_worker["Translation worker"]
  node_chunking["Text chunking"]
  node_service["Translation service"]
  node_google{{"Google translation"}}
  node_google_fallback{{"Google Client API"}}
  node_languages["Language catalog"]
end

subgraph group_state["History and state"]
  node_state_model["App state model"]
  node_history_model["History item model"]
  node_persistence["State persistence<br/>[helpers.py]"]
  node_settings[("Settings file<br/>[settings.json]")]
  node_history["History and favorites<br/>[main_controller.py]"]
end

subgraph group_presentation["Interface"]
  node_window["Translation window<br/>[main_window.py]"]
  node_themes["Theme styles<br/>[styles.py]"]
end

node_user(("Desktop user"))

node_user -->|"enters text"| node_window
node_entry -->|"creates"| node_window
node_entry -->|"creates"| node_controller
node_window -->|"emits requests"| node_controller
node_controller -->|"starts worker"| node_worker
node_worker -->|"splits input"| node_chunking
node_worker -->|"uses session"| node_service
node_worker -->|"translates chunks"| node_google
node_worker -->|"falls back"| node_google_fallback
node_controller -->|"updates result"| node_window
node_window -->|"loads language choices"| node_languages
node_controller -->|"maintains state"| node_state_model
node_controller -->|"creates history items"| node_history_model
node_controller -->|"filters and updates"| node_history
node_history -->|"refreshes list"| node_window
node_controller -->|"loads and saves"| node_persistence
node_persistence -->|"reads and writes"| node_settings
node_window -->|"applies theme"| node_themes
node_window -->|"starts checks"| node_network_worker
node_network_worker -.->|"checks connectivity"| node_network_check

click node_entry "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/main.py"
click node_window "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/ui/main_window.py"
click node_controller "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/controllers/main_controller.py"
click node_worker "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py"
click node_chunking "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py"
click node_service "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py"
click node_languages "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py"
click node_state_model "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/models/translation_model.py"
click node_history_model "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/models/translation_model.py"
click node_persistence "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/utils/helpers.py"
click node_settings "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/config/settings.json"
click node_history "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/controllers/main_controller.py"
click node_network_worker "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/ui/main_window.py"
click node_network_check "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/utils/helpers.py"
click node_themes "https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/ui/styles.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_entry,node_controller,node_network_worker,node_network_check,node_user toneBlue
class node_worker,node_chunking,node_service,node_google,node_google_fallback,node_languages toneAmber
class node_state_model,node_history_model,node_persistence,node_settings,node_history toneMint
class node_window,node_themes toneRose
```

## Components

### Application flow

- [App bootstrap](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/main.py): `main.py`
- [Main controller](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/controllers/main_controller.py): `controllers/main_controller.py`
- [Connectivity monitor](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/ui/main_window.py): `ui/main_window.py`
- [Connectivity check](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/utils/helpers.py): `utils/helpers.py`

### Translation

- [Translation worker](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py): `services/translation_service.py`
- [Text chunking](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py): `services/translation_service.py`
- [Translation service](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py): `services/translation_service.py`
- **Google translation**
- **Google Client API**
- [Language catalog](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/services/translation_service.py): `services/translation_service.py`

### History and state

- [App state model](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/models/translation_model.py): `models/translation_model.py`
- [History item model](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/models/translation_model.py): `models/translation_model.py`
- [State persistence](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/utils/helpers.py): `utils/helpers.py`
- [Settings file](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/config/settings.json): `config/settings.json`
- [History and favorites](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/controllers/main_controller.py): `controllers/main_controller.py`

### Interface

- [Translation window](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/ui/main_window.py): `ui/main_window.py`
- [Theme styles](https://github.com/userkhalid35/codealpha_language_translation_tool/blob/main/ui/styles.py): `ui/styles.py`

### Other components

- **Desktop user**

## Connections

- Desktop user → Translation window: enters text (evidence: `README.md`)
- App bootstrap → Translation window: creates (evidence: `main.py`)
- App bootstrap → Main controller: creates (evidence: `main.py`)
- Translation window → Main controller: emits requests (evidence: `controllers/main_controller.py`)
- Main controller → Translation worker: starts worker (evidence: `controllers/main_controller.py`)
- Translation worker → Text chunking: splits input (evidence: `README.md`)
- Translation worker → Translation service: uses session (evidence: `services/translation_service.py`)
- Translation worker → Google translation: translates chunks (evidence: `services/translation_service.py`)
- Translation worker → Google Client API: falls back (evidence: `services/translation_service.py`)
- Main controller → Translation window: updates result (evidence: `README.md`)
- Translation window → Language catalog: loads language choices (evidence: `ui/main_window.py`)
- Main controller → App state model: maintains state (evidence: `controllers/main_controller.py`)
- Main controller → History item model: creates history items (evidence: `controllers/main_controller.py`)
- Main controller → History and favorites: filters and updates (evidence: `controllers/main_controller.py`)
- History and favorites → Translation window: refreshes list (evidence: `controllers/main_controller.py`)
- Main controller → State persistence: loads and saves (evidence: `controllers/main_controller.py`)
- State persistence → Settings file: reads and writes (evidence: `utils/helpers.py`)
- Translation window → Theme styles: applies theme (evidence: `ui/main_window.py`)
- Translation window → Connectivity monitor: starts checks (evidence: `README.md`)
- Connectivity monitor → Connectivity check: checks connectivity (evidence: `ui/main_window.py`)
