# fatec420/gemini-playground architecture

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

- Interactive diagram: https://gitdiagram.com/fatec420/gemini-playground
- Repository: https://github.com/fatec420/gemini-playground

## Overview

##### Client-Side (Frontend)
- Static Assets (HTML, CSS)
- Core JavaScript Modules
- Audio Processing Components
- Video Processing Components
- WebSocket Client
- Tool Management System

##### Server-Side
- Deno Server
- Cloudflare Worker
- API Proxy Layer

##### External Services
- Google Gemini API
- Optional integrations (ChatBox, Cursor)

##### Top Level (User Interface)
- Video/Audio Controls
- Chat Interface
- Tool Panel

##### Middle Level (Processing Layer)
- Audio Processing Worklets
- Video Management System
- WebSocket Communication
- Tool Manager

##### Bottom Level (Backend Services)
- API proxy architecture:
- Format Conversion Layer (Gemini to OpenAI)
- Authentication Handling
- Request/Response Flow

Use the following visual elements:

- Blue: Frontend components
- Green: Processing components
- Orange: API proxy layer
- Purple: External services

##### Grouping
- Use containers to group related components
- Separate client and server sides clearly
- Deployment options in parallel

Special Considerations:

##### Audio/Video Pipeline
- Detail the flow from input devices through worklets to the API
- Relationship between recorders and processors

##### Tool System
- How tools (weather, Google search) integrate with the main application
- Extensibility points

##### API Proxy
- Demonstrate the transformation of Gemini API format to OpenAI format
- Authentication flow

##### Deployment Options
- Both Deno and Cloudflare Worker paths
- How they interact with the frontend differently

Labels and Documentation:

##### Notes for
- API key requirements
- Deployment-specific configurations
- Network routing considerations

Level of Detail:
- Keep high-level components visible at first glance
- Use expandable sections for detailed components
- Version/model information for external services
- Error handling pathways

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Browser[Browser Interface]
        direction TB
        UI[User Interface]
        SA[Static Assets]:::frontend
        click SA "https://github.com/FATEC420/gemini-playground/tree/main/src/static"
        Main[Main Application]:::frontend
        click Main "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/main.js"
        Config[Configuration]:::frontend
        click Config "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/config/config.js"
    end

    subgraph Processing[Processing Layer]
        direction TB
        subgraph AudioSystem[Audio Processing System]
            direction TB
            AP[Audio Processor]:::processing
            AW[Audio Worklets]:::processing
            click AP "https://github.com/FATEC420/gemini-playground/tree/main/src/static/js/audio"
            click AW "https://github.com/FATEC420/gemini-playground/tree/main/src/static/js/audio/worklets"
        end

        subgraph VideoSystem[Video Processing System]
            direction TB
            VM[Video Manager]:::processing
            SR[Screen Recorder]:::processing
            VR[Video Recorder]:::processing
            click VM "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/video/video-manager.js"
            click SR "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/video/screen-recorder.js"
            click VR "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/video/video-recorder.js"
        end

        WS[WebSocket Client]:::processing
        click WS "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/core/websocket-client.js"
        
        subgraph Tools[Tool Management]
            direction TB
            TM[Tool Manager]:::processing
            WT[Weather Tool]:::tool
            GS[Google Search]:::tool
            click TM "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/tools/tool-manager.js"
            click WT "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/tools/weather-tool.js"
            click GS "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/tools/google-search.js"
        end

        Utils[Utility Functions]:::processing
        ErrorH[Error Handling]:::processing
        click Utils "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/utils/utils.js"
        click ErrorH "https://github.com/FATEC420/gemini-playground/blob/main/src/static/js/utils/error-boundary.js"
    end

    subgraph Backend[Backend Services]
        direction TB
        DS[Deno Server]:::backend
        click DS "https://github.com/FATEC420/gemini-playground/blob/main/src/deno_index.ts"
        CW[Cloudflare Worker]:::backend
        click CW "https://github.com/FATEC420/gemini-playground/blob/main/src/api_proxy/worker.mjs"
    end

    subgraph External[External Services]
        direction TB
        GA[Google Gemini API]:::external
        CB[ChatBox]:::external
        CU[Cursor]:::external
    end

    UI --> Main
    Main --> SA
    Main --> Config
    Main --> Processing
    AP --> AW
    VM --> SR
    VM --> VR
    Processing --> WS
    WS --> Backend
    Backend --> External
    Tools --> Main
    Utils --> Main
    ErrorH --> Main

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef backend fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef tool fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        direction TB
        F[Frontend]:::frontend
        P[Processing]:::processing
        B[Backend]:::backend
        E[External Services]:::external
        T[Tools]:::tool
    end
```
