# watninja68/projecttheata_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/watninja68/projecttheata_frontend
- Repository: https://github.com/watninja68/projecttheata_frontend

## Overview

##### Project type and purpose
- This is a single-page React application (bootstrapped with Create React App) with PWA capabilities.
- It serves as a multimedia chat/agent interface: capturing audio, camera video, screen shares, transcribing speech, and interacting with AI agents (Gemini, Deepgram, WolframAlpha, Google Search).
- It relies on Supabase as a backend (for auth, storage or real-time features) and uses WebSockets for streaming or event handling.

##### File structure
- Top level: package.json, public/, src/
- public/: static assets (HTML shell, audio worklet script, PWA manifest)
- src/: React entry (index.js), core App, global CSS, reportWebVitals, tests
- src/components/: UI building blocks (AudioVisualizerComponent, ChatMessage, MediaControls, SettingsDialog, etc.)
- src/hooks/: custom React hooks orchestrating auth, AI agent interactions, settings
- src/lib/: functional libraries grouped by domain
- audio (recorder, streamer, visualizer, worklets)
- camera, screen capture
- supabase client
- websocket client
- tools (Google search, WolframAlpha, tool manager)
- transcription (Deepgram)
- utils and config

##### README
- Confirms use of CRA build, test, eject, deploy scripts
- No backend code shipped—implies all server-side is external (Supabase or third-party APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client App Layer
    subgraph "Client App"
        subgraph "Entry & Core"
            Entry["src/index.js"]:::frontend
            click Entry "https://github.com/watninja68/projecttheata_frontend/blob/main/src/index.js"
            App["src/App.js"]:::frontend
            click App "https://github.com/watninja68/projecttheata_frontend/blob/main/src/App.js"
        end
        subgraph "PWA"
            Manifest["manifest.json"]:::frontend
            click Manifest "https://github.com/watninja68/projecttheata_frontend/blob/main/public/manifest.json"
            WorkletPub["audio-processor.js"]:::frontend
            click WorkletPub "https://github.com/watninja68/projecttheata_frontend/blob/main/public/js/audio/worklets/audio-processor.js"
        end
        subgraph "UI Components"
            Components["Components"]:::frontend
            click Components "https://github.com/watninja68/projecttheata_frontend/tree/main/src/components/"
            MediaControls["MediaControls.js"]:::frontend
            click MediaControls "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/MediaControls.js"
            AudioVisComp["AudioVisualizerComponent.js"]:::frontend
            click AudioVisComp "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/AudioVisualizerComponent.js"
            ChatMsg["ChatMessage.js"]:::frontend
            click ChatMsg "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/ChatMessage.js"
            ChatHist["ChatHistory.js"]:::frontend
            click ChatHist "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/ChatHistory.js"
            TextInput["TextInput.js"]:::frontend
            click TextInput "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/TextInput.js"
            SettingsDialog["SettingsDialog.js"]:::frontend
            click SettingsDialog "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/SettingsDialog.js"
            Header["Header.js"]:::frontend
            click Header "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/Header.js"
            Footer["Footer.js"]:::frontend
            click Footer "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/Footer.js"
            Sidebar["Sidebar.js"]:::frontend
            click Sidebar "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/Sidebar.js"
            Collapsible["Collapsible.js"]:::frontend
            click Collapsible "https://github.com/watninja68/projecttheata_frontend/blob/main/src/components/Collapsible.js"
        end
        subgraph "Hooks"
            UseAuth["useAuth.js"]:::frontend
            click UseAuth "https://github.com/watninja68/projecttheata_frontend/blob/main/src/hooks/useAuth.js"
            UseSettings["useSettings.js"]:::frontend
            click UseSettings "https://github.com/watninja68/projecttheata_frontend/blob/main/src/hooks/useSettings.js"
            UseGemini["useGeminiAgent.js"]:::frontend
            click UseGemini "https://github.com/watninja68/projecttheata_frontend/blob/main/src/hooks/useGeminiAgent.js"
        end
        subgraph "Services (lib)"
            subgraph "Audio"
                Worklet["audio-processor.js"]:::frontend
                click Worklet "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/audio/worklets/audio-processor.js"
                Recorder["recorder.js"]:::frontend
                click Recorder "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/audio/recorder.js"
                Streamer["streamer.js"]:::frontend
                click Streamer "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/audio/streamer.js"
                Visualizer["visualizer.js"]:::frontend
                click Visualizer "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/audio/visualizer.js"
            end
            Camera["camera.js"]:::frontend
            click Camera "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/camera/camera.js"
            Screen["screen.js"]:::frontend
            click Screen "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/screen/screen.js"
            SupabaseClient["client.js"]:::baas
            click SupabaseClient "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/supabase/client.js"
            WSClient["client.js"]:::frontend
            click WSClient "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/ws/client.js"
            AgentCore["agent.js"]:::frontend
            click AgentCore "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/main/agent.js"
            Deepgram["deepgram.js"]:::external
            click Deepgram "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/transcribe/deepgram.js"
            GoogleSearch["google-search.js"]:::external
            click GoogleSearch "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/tools/google-search.js"
            Wolfram["wolf-from-alpha.js"]:::external
            click Wolfram "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/tools/wolf-from-alpha.js"
            ToolMgr["tool-manager.js"]:::external
            click ToolMgr "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/tools/tool-manager.js"
            Utils["utils.js"]:::frontend
            click Utils "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/utils/utils.js"
            Config["config.js"]:::frontend
            click Config "https://github.com/watninja68/projecttheata_frontend/blob/main/src/lib/config/config.js"
        end
    end

    %% Backend Services
    subgraph "Backend Services"
        Supabase["Supabase BaaS"]:::baas
        WebSocketServer["WebSocket Server"]:::external
        GeminiAPI["Gemini AI"]:::external
        DeepgramAPI["Deepgram API"]:::external
        GoogleAPI["Google Search API"]:::external
        WolframAPI["WolframAlpha API"]:::external
    end

    %% Data Flows
    Entry --> App
    App --> Components
    App --> UseAuth
    App --> UseSettings
    App --> WSClient
    App --> Manifest
    Components --> MediaControls
    Components --> AudioVisComp
    Components --> ChatMsg
    Components --> ChatHist
    Components --> TextInput
    Components --> SettingsDialog
    Components --> Header
    Components --> Footer
    Components --> Sidebar
    Components --> Collapsible

    UseAuth --> SupabaseClient
    UseSettings --> Config
    UseGemini --> AgentCore

    MediaControls --> Recorder
    MediaControls --> Streamer
    MediaControls --> Camera
    MediaControls --> Screen
    Recorder --> Worklet
    Streamer --> WSClient
    Visualizer --> Worklet

    Recorder -->|"AudioBuffer"| DeepgramAPI
    DeepgramAPI -->|"Transcription"| UseGemini
    UseGemini -->|"AI Query"| AgentCore
    AgentCore -->|"AI Response"| UseGemini
    UseGemini --> Components

    TextInput -->|"TextQuery"| GoogleAPI
    TextInput -->|"TextQuery"| WolframAPI
    GoogleAPI --> ToolMgr
    WolframAPI --> ToolMgr
    ToolMgr --> Components

    SupabaseClient --> Supabase
    WSClient -->|"WebSocket"| WebSocketServer

    AgentCore --> GeminiAPI

    %% Styling
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef baas fill:#D5E8D4,stroke:#237804,color:#237804;
    classDef external fill:#FFE0B2,stroke:#d97706,color:#d97706;
```
