# vedantbhatotia/clip-plot2 architecture

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

- Interactive diagram: https://gitdiagram.com/vedantbhatotia/clip-plot2
- Repository: https://github.com/vedantbhatotia/clip-plot2

## Overview

##### Project type and purpose
- This is a full-stack application that lets users upload or process audio (and possibly video) files, transcribe them, generate embeddings, store and search the results, and display them in a web UI.
- The backend is a Python-based service (likely FastAPI or Flask) orchestrating audio transcription, segmentation, embedding, vector‐search (via Chroma), and RAG. The frontend is a Next.js/React dashboard in TypeScript.

##### File structure
Top-level:
- docker-compose.yml – orchestrates containers (backend, maybe Chromadb, frontend)
- extract.py – CLI script for batch extraction/transcription
- frontend/ – Next.js web app
- backend/ – Python service with Dockerfile, .env, requirements, services/, data/
- data/ – Chroma DB production files (vector store)
backend/services:
- transcription_service.py – invokes Whisper or another ASR model
- segment_processor_service.py – splits audio into chunks
- embedding_service.py – calls an embedding model
- database_service.py – wraps vector store calls to ChromaDB
- search_service.py & rag_service.py – perform vector search and RAG answer generation
- media_processor.py & clip_builder_service.py – handle media I/O and clip creation
frontend/app:
- page.tsx, dashboard/page.tsx – UI entry points
- components/ui – buttons, cards, etc.
- lib/utils.ts – shared utilities

##### README
- The README is empty, so we rely solely on the file layout and naming conventions to infer architecture.

Frontend → Backend.API → TranscriptionService → External ASR → TranscriptionService → DatabaseService → ChromaDB
- Blue for Frontend
- Green for Backend services
- Orange for Data store
- Gray for External APIs
- Rectangles for processes/services
- Clouds for external systems

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Docker-Compose Orchestrator"
        direction TB
        DC["docker-compose.yml"]:::backend
        DC --> Frontend
        DC --> Backend
        DC --> ChromaContainer
        DC --> VolumeTemp
        DC --> VolumeChroma
    end

    subgraph "Frontend (Next.js UI)"
        direction TB
        Frontend["Frontend Container"]
        FEHome["Home Page<br>page.tsx"]:::frontend
        FEDash["Dashboard Page<br>dashboard/page.tsx"]:::frontend
        FELayout["Global Layout & Styles<br>layout.tsx<br>globals.css"]:::frontend
        UIButton["Button Component<br>button.tsx"]:::frontend
        UICard["Card Component<br>card.tsx"]:::frontend
        FEUtils["Utilities<br>utils.ts"]:::frontend

        Frontend --> FEHome
        Frontend --> FEDash
        Frontend --> FELayout
        Frontend --> UIButton
        Frontend --> UICard
        Frontend --> FEUtils
    end

    subgraph "Backend (Python API)"
        direction TB
        Backend["Backend Container"]
        API["API Entry Point<br>main.py"]:::backend
        subgraph "Services"
            direction TB
            TSvc["Transcription Service"]:::backend
            SegSvc["Segment Processor Service"]:::backend
            EmbSvc["Embedding Service"]:::backend
            DBSvc["Database Service"]:::backend
            SearchSvc["Search Service"]:::backend
            RAGSvc["RAG Service"]:::backend
            MediaProc["Media Processor"]:::backend
            ClipBuilder["Clip Builder Service"]:::backend
            AudioHelper["Audio-only Helper"]:::backend
        end
        Backend --> API
        API --> TSvc
        API --> SearchSvc
        API --> RAGSvc
        API --> MediaProc
        TSvc --> SegSvc
        SegSvc --> EmbSvc
        EmbSvc --> DBSvc
        MediaProc --> ClipBuilder
    end

    subgraph "Vector Database"
        direction TB
        ChromaContainer["ChromaDB Container"]
        Chroma["ChromaDB"]:::datastore
        ChromaContainer --> Chroma
    end

    VolumeTemp["Temp Audio Volume<br>backend/data"]:::datastore
    VolumeChroma["Chroma Data Volume<br>data/"]:::datastore

    CLI["Batch Extraction Worker<br>extract.py"]:::cli

    ExternalASR["External ASR API"]:::external
    ExternalEmb["External Embedding API"]:::external

    FEHome -->|"HTTP Request"| API
    FEDash -->|"HTTP Request"| API
    API -->|"invoke Transcription"| TSvc
    TSvc -->|"store audio"| VolumeTemp
    TSvc -->|"call ASR"| ExternalASR
    EmbSvc -->|"call Embedding"| ExternalEmb
    EmbSvc -->|"upsert embeddings"| DBSvc
    DBSvc -->|"write vectors"| Chroma
    SearchSvc -->|"query vectors"| Chroma
    RAGSvc -->|"query vectors"| Chroma
    MediaProc -->|"read/write media"| VolumeTemp
    ClipBuilder --> VolumeTemp
    CLI --> TSvc

    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#D0FFD8,stroke:#28a745,color:#28a745;
    classDef datastore fill:#FFE6A7,stroke:#d97706,color:#d97706;
    classDef external fill:#E0E0E0,stroke:#6c757d,color:#495057;
    classDef cli fill:#F5D0FF,stroke:#a42adb,color:#6f42c1;

    click FEHome "https://github.com/vedantbhatotia/clip-plot2/blob/main/frontend/app/page.tsx"
    click FEDash "https://github.com/vedantbhatotia/clip-plot2/blob/main/frontend/app/dashboard/page.tsx"
    click FELayout "https://github.com/vedantbhatotia/clip-plot2/blob/main/frontend/app/layout.tsx"
    click FELayout "https://github.com/vedantbhatotia/clip-plot2/blob/main/frontend/app/globals.css"
    click UIButton "https://github.com/vedantbhatotia/clip-plot2/blob/main/frontend/components/ui/button.tsx"
    click UICard "https://github.com/vedantbhatotia/clip-plot2/blob/main/frontend/components/ui/card.tsx"
    click FEUtils "https://github.com/vedantbhatotia/clip-plot2/blob/main/frontend/lib/utils.ts"
    click API "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/main.py"
    click TSvc "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/transcription_service.py"
    click SegSvc "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/segment_processor_service.py"
    click EmbSvc "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/embedding_service.py"
    click DBSvc "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/database_service.py"
    click SearchSvc "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/search_service.py"
    click RAGSvc "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/rag_service.py"
    click MediaProc "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/media_processor.py"
    click ClipBuilder "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/clip_builder_service.py"
    click AudioHelper "https://github.com/vedantbhatotia/clip-plot2/blob/main/backend/services/audio_no_vid.py"
    click CLI "https://github.com/vedantbhatotia/clip-plot2/blob/main/extract.py"
    click DC "https://github.com/vedantbhatotia/clip-plot2/blob/main/docker-compose.yml"
```
