# addyosmani/say architecture

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

- Interactive diagram: https://gitdiagram.com/addyosmani/say
- Repository: https://github.com/addyosmani/say

## Overview

##### Main System Components

a) Frontend Layer (React Application)
- Divide it into these sub-components:
- UI Components (from src/components)
- Hooks Layer (from src/hooks)
- Utils Layer (from src/utils)

b) Core Processing Layer
- Worker Thread (src/worker.js)
- ML Models (Whisper and T5)

c) Storage Layer
- Browser's LocalStorage
- IndexedDB (if used for audio storage)

##### Component Relationships

a) User Interface Flow:
**AudioRecorder → AudioManager → AudioPlayer**
- ↓
**TranscribeButton → Transcript → TextSummary**
- ↓
- NoteEditor → NoteList

b) Data Flow:
**AudioRecorder → Worker Thread → ML Models**
- ↓
- Transcript → Summarizer → TextSummary

##### Specific Implementation Details

- Blue Rectangles: React Components
- Green Hexagons: ML Models
- Yellow Diamonds: Browser APIs
- Purple Circles: Utility Services
- Red Rectangles: Web Workers

##### Technical Stack Indicators

- React 18
- TypeScript
- Transformers.js
- TinyMCE
- Tailwind CSS
- Vite

##### Key Architectural Patterns to Highlight

- Worker Thread Architecture: Show how the ML processing is offloaded to prevent UI blocking
- Hook-based State Management: Illustrate how custom hooks (useTranscriber, useSummarizer) manage application state
- Component Composition: Demonstrate the hierarchy of UI components

##### Storage and Retrieval Flow

**[User Interface Layer]**
- ↕
**[Application Logic Layer (Hooks)]**
- ↕
**[Processing Layer (Workers & ML)]**
- ↕
**[Storage Layer]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        AR["Audio Recorder"]:::ui
        AM["Audio Manager"]:::ui
        AP["Audio Player"]:::ui
        TB["Transcribe Button"]:::ui
        TR["Transcript"]:::ui
        TS["Text Summary"]:::ui
        NE["Note Editor"]:::ui
        NL["Note List"]:::ui
        MS["Model Selector"]:::ui
        PI["Progress Indicator"]:::ui
        MC["Modal Container"]:::ui
        UI["URL Input"]:::ui
    end

    subgraph "Application Logic Layer"
        UT["useTranscriber"]:::hook
        US["useSummarizer"]:::hook
        UW["useWorker"]:::hook
        AU["Audio Utils"]:::util
        CN["Constants"]:::util
        BH["Blob Handler"]:::util
    end

    subgraph "Processing Layer"
        WT["Worker Thread"]:::worker
        WM["Whisper Model"]:::ml
        T5["T5 Model"]:::ml
    end

    subgraph "Storage Layer"
        LS["LocalStorage"]:::storage
        IDB["IndexedDB"]:::storage
    end

    subgraph "Entry Points"
        APP["App"]:::entry
        IDX["Index"]:::entry
        PP["Permission Page"]:::entry
        PL["Permission Logic"]:::entry
    end

    %% Relationships
    AR --> AM
    AM --> AP
    AR --> TB
    TB --> TR
    TR --> TS
    TR --> NE
    NE --> NL
    MS --> WT
    PI --> WT

    AR --> UT
    UT --> UW
    UW --> WT
    WT --> WM
    WT --> T5
    TR --> US
    US --> T5

    AM --> AU
    AU --> BH
    AU --> CN

    APP --> IDX
    PP --> PL

    %% Storage Connections
    NE --> LS
    NL --> LS
    AM --> IDB

    %% Modal Connections
    MC --> UI
    UI --> AM

    %% Click Events
    click AR "https://github.com/addyosmani/say/blob/main/src/components/AudioRecorder.tsx"
    click AM "https://github.com/addyosmani/say/blob/main/src/components/AudioManager.tsx"
    click AP "https://github.com/addyosmani/say/blob/main/src/components/AudioPlayer.tsx"
    click TB "https://github.com/addyosmani/say/blob/main/src/components/TranscribeButton.tsx"
    click TR "https://github.com/addyosmani/say/blob/main/src/components/Transcript.tsx"
    click TS "https://github.com/addyosmani/say/blob/main/src/components/TextSummary.tsx"
    click NE "https://github.com/addyosmani/say/blob/main/src/components/NoteEditor.tsx"
    click NL "https://github.com/addyosmani/say/blob/main/src/components/NoteList.tsx"
    click MS "https://github.com/addyosmani/say/blob/main/src/components/ModelSelector.tsx"
    click PI "https://github.com/addyosmani/say/blob/main/src/components/Progress.tsx"
    click MC "https://github.com/addyosmani/say/blob/main/src/components/modal/Modal.tsx"
    click UI "https://github.com/addyosmani/say/blob/main/src/components/modal/UrlInput.tsx"
    click UT "https://github.com/addyosmani/say/blob/main/src/hooks/useTranscriber.ts"
    click US "https://github.com/addyosmani/say/blob/main/src/hooks/useSummarizer.ts"
    click UW "https://github.com/addyosmani/say/blob/main/src/hooks/useWorker.ts"
    click AU "https://github.com/addyosmani/say/blob/main/src/utils/AudioUtils.ts"
    click CN "https://github.com/addyosmani/say/blob/main/src/utils/Constants.ts"
    click BH "https://github.com/addyosmani/say/blob/main/src/utils/BlobFix.ts"
    click WT "https://github.com/addyosmani/say/blob/main/src/worker.js"
    click APP "https://github.com/addyosmani/say/blob/main/src/App.tsx"
    click IDX "https://github.com/addyosmani/say/blob/main/src/index.tsx"
    click PP "https://github.com/addyosmani/say/blob/main/src/pages/permission/index.html"
    click PL "https://github.com/addyosmani/say/blob/main/src/pages/permission/requestPermission.ts"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef hook fill:#9b59b6,stroke:#8e44ad,color:white
    classDef util fill:#f1c40f,stroke:#f39c12,color:black
    classDef worker fill:#e74c3c,stroke:#c0392b,color:white
    classDef ml fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef entry fill:#1abc9c,stroke:#16a085,color:white
```
