# actualize-ae/voice-chat-pdf architecture

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

- Interactive diagram: https://gitdiagram.com/actualize-ae/voice-chat-pdf
- Repository: https://github.com/actualize-ae/voice-chat-pdf

## Overview

##### Main Components

a) Frontend Layer (Next.js Application):
- User Interface Components (src/components)
- Pages (src/pages)
- Hooks (src/hooks)
- Utils (src/utils)

b) Backend Layer (Next.js API):
- API Routes (src/pages/api)
- Authentication Endpoints
- Document Processing Endpoints
- Search Configuration Endpoints

c) External Services:
- Supabase Section:
- Authentication Service
- Storage Service (for documents)
- Database (for user data)
- Qdrant Vector Store:
- Vector Database Container
- Embedding Storage
- Cohere Service:
- Reranking Component
- OpenAI Realtime API:
- Voice Processing
- Response Generation

##### Connection and Data Flow

- User authentication flow through Supabase
- Document upload path from frontend to Supabase Storage
- Embedding generation and storage flow to Qdrant
- Query processing path through the RAG pipeline
- Voice interaction flow with OpenAI API

##### Additional Elements

Include:
- Version information
- Key technology stack indicators
- Security boundaries
- API endpoints

##### Implementation Details

Specific implementation aspects:
- Authentication flow
- Document upload and processing pipeline
- Voice interaction system
- Search and retrieval mechanism

- The microservices architecture
- Clear separation of concerns
- Security boundaries
- Data flow paths
- Integration points between services

For this specific project, pay special attention to:
- The voice processing pipeline
- The RAG (Retrieval-Augmented Generation) system
- The integration between various AI services
- The real-time communication aspects
- The document processing and embedding generation workflow

This will create a comprehensive yet clear representation of the system's architecture that accurately reflects the project's structure and complexity.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[UI Components]
        Pages[Application Pages]
        Hooks[Application Hooks]
        Utils[Utility Functions]
        AuthForms[Authentication Forms]
        DocUI[Document Management UI]
        SearchUI[Search Configuration UI]
    end

    subgraph "API Layer"
        AuthAPI[Authentication Endpoints]
        DocAPI[Document Processing Endpoints]
        SearchAPI[Search Configuration]
        APIUtils[API Utilities]
    end

    subgraph "External Services"
        subgraph "Supabase"
            SupaAuth[Authentication Service]
            SupaStorage[Storage Service]
            SupaDB[(Database)]
        end

        subgraph "AI Services"
            Qdrant[(Vector Store)]
            Cohere[Reranking Service]
            OpenAI[OpenAI Realtime API]
        end

        subgraph "Voice Processing"
            WavTools[Voice Processing System]
        end
    end

    UI --> Pages
    Pages --> AuthAPI
    Pages --> DocAPI
    Pages --> SearchAPI
    AuthForms --> AuthAPI
    DocUI --> DocAPI
    SearchUI --> SearchAPI

    AuthAPI --> SupaAuth
    DocAPI --> SupaStorage
    DocAPI --> Qdrant
    SearchAPI --> Cohere
    SearchAPI --> OpenAI
    WavTools --> OpenAI

    classDef frontend fill:#3498db
    classDef api fill:#2ecc71
    classDef auth fill:#9b59b6
    classDef storage fill:#e67e22
    classDef ai fill:#e74c3c
    classDef voice fill:#f1c40f

    class UI,Pages,Hooks,Utils,AuthForms,DocUI,SearchUI frontend
    class AuthAPI,DocAPI,SearchAPI,APIUtils api
    class SupaAuth auth
    class SupaStorage,SupaDB storage
    class Qdrant,Cohere,OpenAI ai
    class WavTools voice

    click UI "https://github.com/actualize-ae/voice-chat-pdf/tree/main/src/components"
    click Pages "https://github.com/actualize-ae/voice-chat-pdf/tree/main/src/pages"
    click Hooks "https://github.com/actualize-ae/voice-chat-pdf/tree/main/src/hooks"
    click Utils "https://github.com/actualize-ae/voice-chat-pdf/tree/main/src/utils"
    click AuthForms "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/components/forms/SignIn.tsx"
    click DocUI "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/components/forms/GenerateEmbeddings.tsx"
    click SearchUI "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/components/forms/SearchConfiguration.tsx"
    click AuthAPI "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/pages/api/login.ts"
    click DocAPI "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/pages/api/generate-embeddings.ts"
    click SearchAPI "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/pages/api/save-search-configs.ts"
    click APIUtils "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/lib/api/utils.ts"
    click SupaAuth "https://github.com/actualize-ae/voice-chat-pdf/tree/main/src/lib/supabase"
    click Qdrant "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/lib/engine/qdrant.ts"
    click Cohere "https://github.com/actualize-ae/voice-chat-pdf/blob/main/src/lib/engine/cohere.ts"
    click WavTools "https://github.com/actualize-ae/voice-chat-pdf/tree/main/src/lib/wavtools"
```
