# sidedwards/ai-video-summarizer architecture

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

- Interactive diagram: https://gitdiagram.com/sidedwards/ai-video-summarizer
- Repository: https://github.com/sidedwards/ai-video-summarizer

## Overview

##### Main Components
- Backend:
- Core logic is implemented in Python within the “backend” directory.
- Key modules include:
▪ ai_jobs.py – Likely responsible for handling AI-related processing tasks.
▪ cli.py – Handles command line interactions.
▪ server.py – Launches the backend server for GUI requests.
▪ log.py, s3.py, transcription_goal.py, utils.py – Provide supporting functionality (logging, AWS S3 integration, transcription goals, and miscellaneous utilities).
- Configuration management from “config/config-example.yaml” (which should be renamed and edited as “config/config.yaml”).
- Frontend:
- Found in the “frontend” directory, primarily built with Svelte.
- Key aspects:
▪ src/routes and src/lib – Define the interface, routing and reusable components.
▪ Vite and TypeScript configuration indicating modern frontend tooling.
- External Services and Dependencies:
- AWS S3 for storage and file handling.
- WhisperX (accessed via Replicate API) for video/audio transcription.
- Additional APIs (such as Anthropic’s API) for processing summaries.
- FFmpeg (an external dependency for video processing).
- Execution Modes:
- CLI: Enables video file selection and summary type through terminal.
- GUI: Combines backend server and the Svelte-powered frontend to allow browser-based uploading and processing.

##### Relationships and Interactions
- The CLI and GUI modes share the same backend processing logic.
- The backend server module (server.py) interacts with the frontend via HTTP (or WebSocket) requests.
- Both processing methods interact with AWS S3 for file storage and retrieval.
- External API integrations (Replicate API for WhisperX and others) are called from within the backend modules.
- The configuration file (config.yaml) centralizes external API keys and model parameters that affect processing throughout the system.

##### Architectural Patterns and Technologies
- Separation of concerns: Clear delineation between frontend (user interface) and backend (processing logic).
- Modular design in the backend: Modules handling single responsibilities (CLI, server, S3 interaction, logging).
- API-driven design: Backend serves as the API for the web frontend.
- Use of industry-standard libraries and frameworks: Python’s ecosystem, Node.js, Svelte, Vite.
- Cloud integration pattern: Interaction with AWS S3 for scalable storage.
- The project supports two different modes (CLI and web) using overlapping core functionalities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces
    subgraph "User Interfaces"
        CLI_UI["CLI Interface"]:::client
        GUI_UI["Web GUI"]:::client
    end

    %% Backend Components
    subgraph "Backend"
        AI_JOBS["ai_jobs.py"]:::module
        CLI["cli.py"]:::module
        SERVER["server.py"]:::module
        LOG["log.py"]:::module
        S3["s3.py"]:::module
        TRANSCRIPTION["transcription_goal.py"]:::module
        UTILS["utils.py"]:::module
    end

    %% Configuration
    subgraph "Configuration"
        CONFIG["config.yaml"]:::config
    end

    %% Frontend Components
    subgraph "Frontend"
        SVELTE["Svelte Components (frontend/src/routes & frontend/src/lib)"]:::module
        STATIC["Static Assets"]:::module
        SVELTE_CONFIG["svelte.config.js"]:::module
        VITE_CONFIG["vite.config.ts"]:::module
        TSCONFIG["tsconfig.json"]:::module
    end

    %% External Services
    subgraph "External Services"
        AWS_S3["AWS S3"]:::external
        WHISPERX["WhisperX (via Replicate API)"]:::external
        FFMPEG["FFmpeg"]:::external
        ADD_API["Additional APIs (Anthropic etc.)"]:::external
    end

    %% Connections between User Interfaces and Core Components
    CLI_UI -->|"triggers"| CLI
    GUI_UI -->|"interacts with"| SVELTE

    %% Frontend to Backend Communication
    SVELTE -->|"API_calls"| SERVER

    %% Backend Processing Flow
    CLI -->|"invokes"| AI_JOBS
    SERVER -->|"invokes"| AI_JOBS

    %% Configuration feeding Backend Modules
    CONFIG -->|"configures"| AI_JOBS
    CONFIG -->|"configures"| CLI
    CONFIG -->|"configures"| SERVER
    CONFIG -->|"configures"| LOG
    CONFIG -->|"configures"| S3
    CONFIG -->|"configures"| TRANSCRIPTION
    CONFIG -->|"configures"| UTILS

    %% Backend External Service Interactions
    CLI -->|"S3_access"| AWS_S3
    SERVER -->|"S3_access"| AWS_S3
    AI_JOBS -->|"calls"| WHISPERX
    AI_JOBS -->|"calls"| ADD_API
    S3 -->|"handles"| AWS_S3
    SERVER -->|"processes_media"| FFMPEG

    %% Click Events
    click AI_JOBS "https://github.com/sidedwards/ai-video-summarizer/blob/main/backend/ai_jobs.py"
    click CLI "https://github.com/sidedwards/ai-video-summarizer/blob/main/backend/cli.py"
    click SERVER "https://github.com/sidedwards/ai-video-summarizer/blob/main/backend/server.py"
    click LOG "https://github.com/sidedwards/ai-video-summarizer/blob/main/backend/log.py"
    click S3 "https://github.com/sidedwards/ai-video-summarizer/blob/main/backend/s3.py"
    click TRANSCRIPTION "https://github.com/sidedwards/ai-video-summarizer/blob/main/backend/transcription_goal.py"
    click UTILS "https://github.com/sidedwards/ai-video-summarizer/blob/main/backend/utils.py"
    click CONFIG "https://github.com/sidedwards/ai-video-summarizer/blob/main/config/config-example.yaml"
    click SVELTE "https://github.com/sidedwards/ai-video-summarizer/tree/main/frontend/"
    click STATIC "https://github.com/sidedwards/ai-video-summarizer/tree/main/frontend/static"
    click SVELTE_CONFIG "https://github.com/sidedwards/ai-video-summarizer/blob/main/frontend/svelte.config.js"
    click VITE_CONFIG "https://github.com/sidedwards/ai-video-summarizer/blob/main/frontend/vite.config.ts"
    click TSCONFIG "https://github.com/sidedwards/ai-video-summarizer/blob/main/frontend/tsconfig.json"

    %% Styles
    classDef module fill:#bbf,stroke:#333,stroke-width:2px;
    classDef config fill:#f9d,stroke:#333,stroke-width:2px;
    classDef external fill:#dfd,stroke:#333,stroke-width:2px;
    classDef client fill:#ffd,stroke:#333,stroke-width:2px;
```
