# nafisrayan/ai-voice-assistant-st architecture

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

- Interactive diagram: https://gitdiagram.com/nafisrayan/ai-voice-assistant-st
- Repository: https://github.com/nafisrayan/ai-voice-assistant-st

## Overview

##### Main Components

a) Core System Components:
- Voice Input/Output System
- Command Processing Engine
- AI Model Integration Layer
- Task Execution System

b) External Services:
- Google GEMINI API
- HuggingFace MISTRAL API
- Various Web Services (YouTube, Google, Wikipedia)
- Email Service (SMTP)

**User Interface Layer**

**Processing Layer**

**Service Integration Layer**

**External Services Layer**

##### Specific Component Details

Input/Output Layer (Top):
- To the Speech Recognition and Text-to-Speech components

Processing Layer (Middle):
- Command Interpreter component
- Task Router component
- State Manager
- Response Generator

AI Integration Layer:
- GEMINI Integration Module
- MISTRAL Integration Module
- Model Selection Logic

Task Execution Layer:
- Web Browser Controller
- Email Service Handler
- System Operations Handler (screenshots, time, etc.)
- Media Controller (music playback)

##### Connection and Flow Representation

- Blue: Core system components
- Green: AI model integrations
- Orange: External services
- Purple: User interaction points

##### Important Elements to Highlight

a) Key Processes:
- Voice Input → Speech Recognition → Command Processing → Task Execution → Voice Output
- Model Selection Logic between GEMINI and MISTRAL
- Task Routing System

b) Integration Points:
- API connections to AI models
- Web service integrations
- System function calls

Create clear boundaries between:
- User Interface Components
- Core Processing Logic
- External Service Integrations
- AI Model Implementations

##### Technical Details

Key Libraries/Dependencies:
- SpeechRecognition
- pyttsx3
- google.generativeai
- huggingface_hub

##### Notes for Implementation

- Keep the main flow clear and centered
- Related functionalities together
- Clear separation between synchronous and asynchronous operations
- Error handling paths
- System boundaries

Remember to maintain a balance between showing enough detail to understand the system's complexity while keeping it clean and readable. The focus should be on the interaction between components rather than internal implementations.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#b3d1ff,stroke:#4d88ff
    classDef ai fill:#98fb98,stroke:#228b22
    classDef external fill:#ffa07a,stroke:#ff6347
    classDef interface fill:#dda0dd,stroke:#9370db
    classDef config fill:#f0e68c,stroke:#bdb76b

    %% User Interface Layer
    subgraph UI
        MIC[Microphone Input]:::interface
        SPEAK[Speaker Output]:::interface
    end

    %% Core Processing Layer
    subgraph CORE
        SR[Speech Recognition]:::core
        TTS[Text-to-Speech]:::core
        CMD[Command Interpreter]:::core
        ROUTER[Task Router]:::core
        STATE[State Manager]:::core
        RESP[Response Generator]:::core
    end

    %% AI Integration Layer
    subgraph AI
        MODEL_SELECT[Model Selection Logic]:::ai
        GEMINI[GEMINI Integration]:::ai
        MISTRAL[MISTRAL Integration]:::ai
        GEMINI_ASST[GEMINI Assistant]:::ai
        MISTRAL_ASST[MISTRAL Assistant]:::ai
        ALT_GEMINI[Alternative GEMINI]:::ai
    end

    %% Task Execution Layer
    subgraph TASKS
        WEB[Web Browser Controller]:::core
        EMAIL[Email Service Handler]:::core
        SYS[System Operations]:::core
        MEDIA[Media Controller]:::core
    end

    %% External Services Layer
    subgraph EXTERNAL
        GAPI[Google GEMINI API]:::external
        HAPI[HuggingFace API]:::external
        WSERV["Web Services<br/>(YouTube, Google, Wikipedia)"]:::external
        SMTP[Email SMTP]:::external
    end

    %% Configuration
    CONFIG[Configuration & Dependencies]:::config

    %% Connections
    MIC --> SR
    SR --> CMD
    CMD --> ROUTER
    ROUTER --> MODEL_SELECT
    MODEL_SELECT --> |AI Tasks| GEMINI
    MODEL_SELECT --> |AI Tasks| MISTRAL
    GEMINI --> GEMINI_ASST
    MISTRAL --> MISTRAL_ASST
    GEMINI --> GAPI
    MISTRAL --> HAPI
    ROUTER --> |System Tasks| TASKS
    TASKS --> WEB
    TASKS --> EMAIL
    TASKS --> SYS
    TASKS --> MEDIA
    WEB --> WSERV
    EMAIL --> SMTP
    RESP --> TTS
    TTS --> SPEAK
    
    %% Component Click Events
    click GEMINI "https://github.com/NafisRayan/AI-Voice-Assistant-ST/blob/main/Other Files/Basics/Google GEMINI.py"
    click MISTRAL "https://github.com/NafisRayan/AI-Voice-Assistant-ST/blob/main/Other Files/Basics/HuggingFace MISTRAL.py"
    click GEMINI_ASST "https://github.com/NafisRayan/AI-Voice-Assistant-ST/blob/main/Other Files/Model App(s)/assistant Gemini.py"
    click MISTRAL_ASST "https://github.com/NafisRayan/AI-Voice-Assistant-ST/blob/main/Other Files/Model App(s)/assistant Mistral.py"
    click ALT_GEMINI "https://github.com/NafisRayan/AI-Voice-Assistant-ST/blob/main/Other Files/Model App(s)/assistant without unwanted GEMINI.py"
    click CONFIG "https://github.com/NafisRayan/AI-Voice-Assistant-ST/blob/main/requirements.txt"
    
    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[AI Components]:::ai
        L3[External Services]:::external
        L4[User Interface]:::interface
        L5[Configuration]:::config
    end
```
