# prashu-014/aivoice architecture

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

- Interactive diagram: https://gitdiagram.com/prashu-014/aivoice
- Repository: https://github.com/prashu-014/aivoice

## Overview

##### Main Components Identification

A. Frontend Layer (Client)
- React.js Application
- Three.js 3D Avatar System
- Web Speech API Integration
- User Interface Components

B. Backend Layer (Server)
- Node.js/Express.js Server
- Audio Processing System
- Route Handlers

C. External Services
- Gemini AI Integration
- Text-to-Speech Services
- Speech-to-Text Services

**[User Interface Layer]**
- 3D Avatar Component (Three.js)
- Voice Interface Components
- React Components
- AiResponse
- Avatar System
- UI Controls

**[Server Layer]**
- Express.js Server
- Audio Processing
- API Routes

**[External Services Layer]**
- Gemini AI
- Text-to-Speech Service
- Speech-to-Text Service

##### Data Flow Representation

- Voice input flow from user to system
- Data processing through the backend
- AI response generation
- Avatar animation triggers
- Speech output back to user

##### Detailed Component Relationships

- Frontend hooks (useSpeechToTextWrapper, useTextToSpeech) and their respective services
- Avatar components and animation systems
- API endpoints and their corresponding frontend consumers

##### Implementation Notes

- Use standardized symbols for different component types
- System boundaries
- Asynchronous processes
- Real-time features

##### Technical Details

Frontend:
- React.js components structure
- Three.js integration points
- Web Speech API implementation
- State management flow

Backend:
- Express.js routing system
- Audio processing pipeline
- API endpoint architecture

External Services:
- Gemini AI integration points
- Speech service connections

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI[React Application]:::frontend
        click UI "https://github.com/prashu-014/aiVoice/blob/main/client/src/App.jsx"
        
        subgraph ThreeJS["Three.js Layer"]
            Avatar[3D Avatar System]:::frontend
            click Avatar "https://github.com/prashu-014/aiVoice/blob/main/client/src/components/Avatar/Avatar.jsx"
            AvatarContent[Avatar Content Manager]:::frontend
            click AvatarContent "https://github.com/prashu-014/aiVoice/blob/main/client/src/components/Avatar/Content.jsx"
            Model[3D Model]:::asset
            click Model "https://github.com/prashu-014/aiVoice/blob/main/client/public/models/6743df4d75c188cf4dfb0dff.glb"
            Animations[Animation System]:::asset
            click Animations "https://github.com/prashu-014/aiVoice/blob/main/client/public/animation/Idle.fbx"
        end

        subgraph Voice["Voice Interface"]
            STT[Speech-to-Text Hook]:::frontend
            click STT "https://github.com/prashu-014/aiVoice/blob/main/client/src/hooks/useSpeechToTextWrapper.js"
            TTS[Text-to-Speech Hook]:::frontend
            click TTS "https://github.com/prashu-014/aiVoice/blob/main/client/src/hooks/useTextToSpeech.js"
            VoiceStatus[Voice Status UI]:::frontend
            click VoiceStatus "https://github.com/prashu-014/aiVoice/blob/main/client/src/components/ui/VoiceStatus.jsx"
        end

        subgraph Components["UI Components"]
            AiResponse[AI Response Handler]:::frontend
            click AiResponse "https://github.com/prashu-014/aiVoice/blob/main/client/src/components/AiResponse.jsx"
            NavControls[Navigation Controls]:::frontend
            click NavControls "https://github.com/prashu-014/aiVoice/blob/main/client/src/components/ui/NavButtons.jsx"
        end

        ApiLayer[API Integration Layer]:::frontend
        click ApiLayer "https://github.com/prashu-014/aiVoice/blob/main/client/src/utils/api.js"
    end

    subgraph Server
        Express[Express.js Server]:::backend
        click Express "https://github.com/prashu-014/aiVoice/blob/main/server/server.js"
        
        subgraph Processing["Audio Processing"]
            AudioSystem[Audio Processing System]:::backend
            click AudioSystem "https://github.com/prashu-014/aiVoice/tree/main/server/audio/"
        end

        Routes[Route Handlers]:::backend
        click Routes "https://github.com/prashu-014/aiVoice/blob/main/server/routes/response.js"
    end

    subgraph External["External Services"]
        GeminiAI[Gemini AI]:::external
        SpeechServices[Speech Services]:::external
    end

    %% Connections
    UI --> Avatar
    UI --> Voice
    UI --> Components
    
    Avatar --> Model
    Avatar --> Animations
    Avatar --> AvatarContent
    
    STT --> ApiLayer
    TTS --> ApiLayer
    AiResponse --> ApiLayer
    
    ApiLayer --> Express
    Express --> Routes
    Routes --> AudioSystem
    Routes --> GeminiAI
    Routes --> SpeechServices

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef asset fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend Component]:::frontend
        Backend[Backend Service]:::backend
        External[External Service]:::external
        Asset[Asset/Resource]:::asset
    end
```
