# cmanjah/tiagogpt--robot-assisted-interventions- architecture

> Architecture diagram of the GitHub repository cmanjah/tiagogpt--robot-assisted-interventions-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cmanjah/tiagogpt--robot-assisted-interventions-
- Repository: https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-

## Overview

##### Main Components
- Application Launcher and Bootstrapping:
- TIAGoGPT.pyproject, TIAGoGPT.pyproject.user, and TIAGoGPTAppLauncher.py files serve as the entry points.
- Controller Layer:
- The “controller” directory (with AppController.py and ThreadSignalController.py) handles high-level orchestration, conversation management, and thread handling.
- Modules Layer:
- “modules” contains key functional units including:
- Audio Recording Module (for capturing spoken input),
- Data Storage Module (managing databases and file storage for chat logs, consent, etc.),
- EndPoint Module (to integrate external APIs for transcription, response generation, and voice synthesis).
- Resources & Assets:
- The “resources” directory holds audio files, system logs, images, templates, and other static files needed for GUIs, CSS skins, and logging.
- External Services & APIs:
- OpenAI’s Whisper (voice transcription) and GPT-3.5 Turbo (response generation) APIs,
- Google Cloud Text-to-Speech API for synthesised voice outputs.
- GUI/User Interaction:
- Evident from release notes mentioning a user-friendly graphical interface that displays responses and handles dual conversation modes (text and voice).

##### Relationships and Interactions
- The Application Launcher initiates the system, which passes control to the Controller Layer.
- The Controller then coordinates calls between various Modules:
- The Audio Recording module captures user speech.
- The captured audio is sent to the transcription service (via the EndPoint Module) and then forwarded to the GPT response generator.
- Generated responses are passed to the Text Synthesis module, and results are played back or displayed through the GUI.
- The Data Storage Module ensures that chat logs, consent forms, and audit logs are properly managed.
- Thread and concurrency controllers handle simultaneous processes (like recording, transcription, and response generation), ensuring smooth interaction.
- There is clear communication between internal modules and external APIs, with configuration and credential files located in the “modules/includes” folder.

##### Architectural Patterns and Design Principles
- MVC Pattern / Layered Architecture: Separation of concerns is indicated by splitting the controllers (business logic), modules (functional units), and resources (static assets).
- Modular Design: Individual modules target distinct responsibilities such as audio processing, data storage, API integrations, and UI handling.
- Thread Management: Dedicated components (ThreadSignalController) manage asynchronous operations.
- Security and Data Integrity: Components for consent handling, file access control, audit logging, and data encryption/hashing illustrate responsible AI practices and secure design.

##### Relevant Technologies, Frameworks, and Libraries
- Python (with virtual environment setups in the README),
- OpenAI’s Whisper API and GPT-3.5 Turbo,
- Google Cloud TTS,
- Possibly a GUI framework (given the mention of skins and interface; look into libraries like PyQt or Tkinter based on code or further documentation),
- Standard Python threading (as seen in the controllers for thread management).

##### Suggested Elements
- Clear labels for every component (e.g., “Audio Recording Module”, “Transcription Service”, “Response Generation Module”, “Text Synthesis Module”, “GUI Interface”).
- From user input (via microphone/UI) → Audio Recording Module → Controller → Transcription Service → GPT Generator → Text Synthesis → Response to User Interface.
- Another for external APIs/services,
- A distinct style for storage/data repositories.
- Annotations highlighting the MVC structure and threading components.
- If applicable, notes explaining integration with the TIAGo robot hardware.

##### Putting It All Together
- Frontend/UI,
- Business logic (controllers),
- Functional modules, and
- External integrations and storage.
- Directional data flow is clearly mapped, showing sequential interactions between voice input, processing, response generation, and output.
- Security and data handling components (like audit logs and consent forms).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "TIAGo Robot Deployment"
        launcher("TIAGoGPT App Launcher"):::launcher

        subgraph "Controller Layer"
            ctrl1("App Controller"):::controller
            ctrl2("ThreadSignal Controller"):::controller
        end

        subgraph "Modules Layer"
            mod1("Audio Recording Module"):::module
            mod2("Data Storage Module"):::module
            mod3("EndPoint Module"):::module
            stor("Chat Log Storage"):::storage
        end

        subgraph "External Services"
            svc1("Whisper Transcription API"):::service
            svc2("GPT-3.5 Turbo API"):::service
            svc3("Google Cloud TTS API"):::service
        end

        subgraph "Frontend/UI Layer"
            ui("GUI Interface"):::ui
        end

        subgraph "Assets & Resources"
            asset1("Audio Files"):::asset
            asset2("GUI Skins"):::asset
        end
    end

    %% Connections from Launcher to Controllers
    launcher -->|"start"| ctrl1
    ctrl1 -->|"manages"| ctrl2

    %% Controller calling modules
    ctrl1 -->|"invokes"| mod1
    ctrl1 -->|"logs_to"| mod2
    ctrl1 -->|"calls"| mod3

    %% Thread management coordination
    ctrl2 -->|"threads_coord"| mod1
    ctrl2 -->|"threads_coord"| mod3

    %% Modules interactions
    mod1 -->|"captures_audio"| mod3
    mod2 -->|"stores_conversation"| stor

    %% External API flow
    mod3 -->|"transcribes"| svc1
    svc1 -->|"sends_text_to"| svc2
    svc2 -->|"generates_response"| svc3
    svc3 -->|"synthesizes_voice"| ui

    %% GUI and Asset interactions
    asset2 -->|"applies_style"| ui
    asset1 -->|"provides_audio"| ui
    ui -->|"logs_display"| mod2

    %% Styles
    classDef launcher fill:#ADD8E6,stroke:#000,stroke-width:2px
    classDef controller fill:#FFA500,stroke:#000,stroke-width:2px
    classDef module fill:#90EE90,stroke:#000,stroke-width:2px
    classDef service fill:#FFB6C1,stroke:#000,stroke-width:2px
    classDef ui fill:#FFFF99,stroke:#000,stroke-width:2px
    classDef storage fill:#D3D3D3,stroke:#000,stroke-width:2px
    classDef asset fill:#E6E6FA,stroke:#000,stroke-width:2px

    %% Click Events
    click launcher "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/blob/Master/TIAGoGPTAppLauncher.py"
    click ctrl1 "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/blob/Master/controller/AppController.py"
    click ctrl2 "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/blob/Master/controller/ThreadSignalController.py"
    click mod1 "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/blob/Master/modules/AudioRecordingModule.py"
    click mod2 "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/blob/Master/modules/DataStorageModule.py"
    click stor "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/tree/Master/resources/chat-log"
    click mod3 "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/blob/Master/modules/EndPointModule.py"
    click ui "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/tree/Master/resources/system/template"
    click asset1 "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/tree/Master/resources/audio"
    click asset2 "https://github.com/cmanjah/tiagogpt--robot-assisted-interventions-/tree/Master/resources/system/template/css_skins"
```
