# sachinnchoudhary/jarvis_aichat architecture

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

- Interactive diagram: https://gitdiagram.com/sachinnchoudhary/jarvis_aichat
- Repository: https://github.com/sachinnchoudhary/jarvis_aichat

## Overview

##### Project type and purpose
- This is a single‐page web application (SPA) built with React/TypeScript and Vite.
- Its primary function is to provide a voice-driven assistant interface that leverages the local Ollama LLM model, plus browser speech APIs and text-to-speech.

##### File structure
- Top level: configuration files (`vite.config.ts`, `tailwind.config.ts`, `tsconfig.json`), `package.json`, `README.md`, and a `public` folder.
- `src/` contains:
- `main.tsx` (entrypoint) and `index.html` (shell)
- `App.tsx` + `App.css` (root application container)
- `components/` (UI widgets, grouped into feature components and a `ui/` library of shadcn/ui primitives)
- `hooks/` (custom React hooks for mobile detection, toast notifications, Ollama API calls, text‐to‐speech, and overall voice-assistant orchestration)
- `lib/utils.ts` (shared utility functions)
- `pages/` (route‐level components: home and 404)
- No dedicated backend code; the “backend” is the local Ollama process and browser APIs.

##### README for architectural insights
- Technology stack: Vite, TypeScript, React, shadcn/ui, Tailwind CSS
- External dependency: Ollama CLI and models (e.g., llama3)
- Runtime flow: user speaks → browser speech recognizer → custom hook sends text to Ollama → receives model response → optionally reads out via text-to-speech

##### Diagramming conventions
- Blue for UI components
- Green for logic/hooks
- Orange for external services/APIs

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Device / Browser"
        subgraph "Presentation Layer"
            MAIN["React SPA Entrypoint\nsrc/main.tsx"]:::ui
            SHELL["Application Shell\nindex.html"]:::ui
            ROOT["App.tsx / App.css"]:::ui
            subgraph "Pages"
                HOME["Home Page\nIndex.tsx"]:::ui
                NOTFOUND["404 Page\nNotFound.tsx"]:::ui
            end
            subgraph "Feature Components"
                PB["Particle Background"]:::ui
                SMODAL["Settings Modal"]:::ui
                SPANEL["Settings Panel"]:::ui
                VIZ["Voice Visualizer"]:::ui
            end
            ULIB["UI Library\n(shadcn/ui primitives)"]:::ui
        end
        subgraph "Logic Layer"
            VA["useVoiceAssistant"]:::logic
            OLL["useOllama"]:::logic
            TTS["useTextToSpeech"]:::logic
            UMOB["use-mobile"]:::logic
            UTOAST["use-toast"]:::logic
            USET["useAppSettings"]:::logic
            UTILS["Shared Utilities\nutils.ts"]:::logic
        end
    end

    subgraph "External Services"
        SPEECHREC["Browser Speech Recognition API"]:::external
        TTSAPI["Browser Text-to-Speech API"]:::external
        OLLAMA["Ollama LLM Engine\n(local)"]:::external
    end

    %% Data Flows
    MAIN -->|"loads"| ROOT
    ROOT -->|"renders"| HOME
    ROOT -->|"renders"| NOTFOUND
    ROOT -->|"uses UI lib"| ULIB

    SPANEL -->|"invokes"| VA
    SPEECHREC -->|"audio levels"| VIZ
    SPANEL -->|"visual feedback"| VIZ

    VA -->|"start recognition"| SPEECHREC
    SPEECHREC -->|"audio stream"| VA
    SPEECHREC -->|"transcript"| VA

    VA -->|"text prompt"| OLL
    OLL -->|"model response"| VA

    VA -->|"display text"| ROOT
    VA -->|"send to TTS"| TTS
    TTS -->|"synthesize speech"| TTSAPI

    %% Utilities usage
    UTILS --> VA
    UTILS --> OLL
    UTILS --> TTS

    %% Hook registrations
    ROOT --> UMOB
    ROOT --> UTOAST
    ROOT --> USET

    %% Click Events
    click MAIN "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/main.tsx"
    click SHELL "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/index.html"
    click ROOT "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/App.tsx"
    click HOME "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/pages/Index.tsx"
    click NOTFOUND "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/pages/NotFound.tsx"
    click PB "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/components/ParticleBackground.tsx"
    click SMODAL "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/components/SettingsModal.tsx"
    click SPANEL "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/components/SettingsPanel.tsx"
    click VIZ "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/components/VoiceVisualizer.tsx"
    click ULIB "https://github.com/sachinnchoudhary/jarvis_aichat/tree/main/src/components/ui/"
    click VA "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/hooks/useVoiceAssistant.ts"
    click OLL "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/hooks/useOllama.ts"
    click TTS "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/hooks/useTextToSpeech.ts"
    click UMOB "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/hooks/use-mobile.tsx"
    click UTOAST "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/hooks/use-toast.ts"
    click USET "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/hooks/useAppSettings.ts"
    click UTILS "https://github.com/sachinnchoudhary/jarvis_aichat/blob/main/src/lib/utils.ts"

    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef logic fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef external fill:#ffe5b4,stroke:#cc8400,stroke-width:1px
```
