# akramj13/ai-voice architecture

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

- Interactive diagram: https://gitdiagram.com/akramj13/ai-voice
- Repository: https://github.com/akramj13/ai-voice

## Overview

##### Main Components
- Frontend Interface:
- Next.js pages (e.g., app/page.js, app/layout.js) and the overall app structure including authentication pages under "app/(auth)".
- Dashboard and project creation pages found in "app/dashboard" and "app/dashboard/create-new".
- Shared UI components (under "components/ui" and "components/theme-provider.jsx") that provide the themes, alerts, buttons, and toggles, as well as global styling with Tailwind CSS.
- API Endpoints:
- Located under "app/api", these endpoints include:
▪ /generate-audio (voice synthesis using ElevenLabs)
▪ /generate-caption (auto-captioning using AssemblyAI)
▪ /get-video-script (content generation via Google Gemini AI)
- Backend & Database:
- A Neon PostgreSQL database configured via Drizzle ORM (see "configs/db.js", "configs/schema.js").
- The Drizzle configuration in "drizzle.config.js" ties the database operations together.
- External Services:
- ElevenLabs (for voice synthesis), AssemblyAI (for captions), Google Gemini AI (for content generation), AWS S3 for file storage, and Clerk for user authentication.

##### Analyzing Relationships & Interactions
- Users access the frontend application, navigating to the authentication pages and the dashboard.
- Upon initiating a voice synthesis project, the frontend communicates with API endpoints:
- The API layer manages calls and responses from the corresponding third-party services.
- For example, when generating audio, the frontend sends a request to "app/api/generate-audio/route.js" which in turn interacts with ElevenLabs.
- The API layer also handles database operations (using Drizzle ORM) to store user data, project configurations, and possibly metadata about generated content.
- The application integrates external services for content processes (like captioning and text generation), so the data flows from the frontend → API endpoints → External Services, and back with the processed results.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global User
    U("User"):::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        F1("Page.js"):::frontend
        F2("Layout.js"):::frontend
        
        subgraph "Authentication Pages"
            direction TB
            F3("Sign-In Page"):::frontend
            F4("Sign-Up Page"):::frontend
        end
        
        subgraph "Dashboard & Content Creation"
            direction TB
            F5("Dashboard Main"):::frontend
            F6("Dashboard Layout"):::frontend
            F7("Dashboard Components"):::frontend
            F8("Create New Project"):::frontend
            F9("Create New Components"):::frontend
        end
        
        subgraph "Shared UI Components"
            direction TB
            F10("UI Components"):::frontend
            F11("Theme Provider"):::frontend
            F12("Theme Toggle"):::frontend
        end
        
        subgraph "Global Styles & Providers"
            direction TB
            F13("Global CSS"):::frontend
            F14("Provider"):::frontend
        end
        
        subgraph "Middleware & Configuration"
            direction TB
            F15("Middleware"):::frontend
            F16("Configs"):::frontend
        end
    end

    %% Backend/API Layer
    subgraph "Backend/API Layer"
        direction TB
        B1("API: Generate Audio"):::api
        B2("API: Generate Caption"):::api
        B3("API: Get Video Script"):::api
        
        subgraph "Database & ORM"
            direction TB
            B4("Database Config"):::database
            B5("Schema Definition"):::database
            B6("Model Config"):::database
            B7("Drizzle Config"):::database
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        E1("ElevenLabs"):::external
        E2("AssemblyAI"):::external
        E3("Google Gemini"):::external
        E4("AWS S3"):::external
        E5("Clerk"):::external
    end

    %% Connections from User to Frontend
    U --> F1
    U --> F3
    U --> F5

    %% Frontend to API calls (from Dashboard Main)
    F5 -->|"initiates"| B1
    F5 -->|"initiates"| B2
    F5 -->|"initiates"| B3

    %% API endpoints to Database & ORM
    B1 -->|"stores data in"| B4
    B2 -->|"stores data in"| B4
    B3 -->|"stores data in"| B4

    %% Chaining Database configuration details
    B4 --> B5
    B4 --> B6
    B4 --> B7

    %% API endpoints interactions with External Services
    B1 -->|"calls"| E1
    B1 -->|"stores output in"| E4
    B2 -->|"calls"| E2
    B3 -->|"calls"| E3

    %% Authentication Pages interaction with Clerk for user auth
    F3 -->|"auth via"| E5
    F4 -->|"auth via"| E5

    %% Middleware influence on Frontend/API flow
    F15 -->|"handles requests for"| B1
    F16 -->|"configures"| F1

    %% Styling Classes
    classDef frontend fill:#a3d5ff,stroke:#000,stroke-width:1px;
    classDef api fill:#ffda9e,stroke:#000,stroke-width:1px;
    classDef database fill:#d1f1c7,stroke:#000,stroke-width:1px;
    classDef external fill:#f4c2c2,stroke:#000,stroke-width:1px;
    classDef user fill:#fff2a8,stroke:#000,stroke-width:1px;

    %% Click Events for Frontend Interface
    click F1 "https://github.com/akramj13/ai-voice/blob/main/app/page.js"
    click F2 "https://github.com/akramj13/ai-voice/blob/main/app/layout.js"
    click F3 "https://github.com/akramj13/ai-voice/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.jsx"
    click F4 "https://github.com/akramj13/ai-voice/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.jsx"
    click F5 "https://github.com/akramj13/ai-voice/blob/main/app/dashboard/page.jsx"
    click F6 "https://github.com/akramj13/ai-voice/blob/main/app/dashboard/layout.jsx"
    click F7 "https://github.com/akramj13/ai-voice/tree/main/app/dashboard/_components"
    click F8 "https://github.com/akramj13/ai-voice/blob/main/app/dashboard/create-new/page.jsx"
    click F9 "https://github.com/akramj13/ai-voice/tree/main/app/dashboard/create-new/_components"
    click F10 "https://github.com/akramj13/ai-voice/tree/main/components/ui"
    click F11 "https://github.com/akramj13/ai-voice/blob/main/components/theme-provider.jsx"
    click F12 "https://github.com/akramj13/ai-voice/blob/main/components/theme-toggle.jsx"
    click F13 "https://github.com/akramj13/ai-voice/blob/main/app/globals.css"
    click F14 "https://github.com/akramj13/ai-voice/blob/main/app/provider.js"
    click F15 "https://github.com/akramj13/ai-voice/blob/main/middleware.js"
    click F16 "https://github.com/akramj13/ai-voice/blob/main/next.config.mjs"

    %% Click Events for API Endpoints
    click B1 "https://github.com/akramj13/ai-voice/blob/main/app/api/generate-audio/route.js"
    click B2 "https://github.com/akramj13/ai-voice/blob/main/app/api/generate-caption/route.js"
    click B3 "https://github.com/akramj13/ai-voice/blob/main/app/api/get-video-script/route.js"

    %% Click Events for Backend & Database
    click B4 "https://github.com/akramj13/ai-voice/blob/main/configs/db.js"
    click B5 "https://github.com/akramj13/ai-voice/blob/main/configs/schema.js"
    click B6 "https://github.com/akramj13/ai-voice/blob/main/configs/model.js"
    click B7 "https://github.com/akramj13/ai-voice/blob/main/drizzle.config.js"
```
