# eusholli/ttv-ai-clipper architecture

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

- Interactive diagram: https://gitdiagram.com/eusholli/ttv-ai-clipper
- Repository: https://github.com/eusholli/ttv-ai-clipper

## Overview

##### Main Components

A. Client Layer:
- React Frontend (Vite-based)
- Key components: Authentication, Pricing, and User Profile modules
- Static assets served through Nginx

B. Server Layer:
- Nginx Reverse Proxy
- FastAPI Backend
- Authentication Service (evident from auth components)

C. External Services & Storage:
- PostgreSQL Database (indicated by *_psql.py files)
- R2 Storage (indicated by r2_manager.py)
- Google Services Integration (shown by google_found_psql.py)
- Video Processing Service (indicated by video_utils.py)

**[Client Layer]**
- ↕
**[Reverse Proxy Layer]**
- ↕
**[Application Layer]**
- ↕
**[External Services Layer]**

##### Component Relationships to Highlight

Frontend → Backend Interactions:
- API routes through Nginx reverse proxy
- Authentication flow
- Video processing requests
- Search functionality (from transcript_search.py)

Backend → External Services:
- Database connections
- R2 storage operations
- Video processing pipeline
- Google service integrations

##### Specific Implementation Details

**[Nginx Container]**
- Static file serving
- API request routing
- Port 80 exposure

**[Frontend Container]**
- React components
- Authentication UI
- Pricing interface
- User profile management

**[Backend Container]**
- FastAPI application
- Video processing logic
- Transcript search
- R2 storage management
- PostgreSQL interactions

##### Environment & Configuration

A section showing:
- Environment variables (.env files)
- Configuration files (logging.conf)
- Build/deployment scripts

##### Additional Elements

- Development tools (.devcontainer)
- CI/CD components (cloudbuild.yaml)
- Deployment configurations (render.yaml)

##### Technical Stack Callouts

Technologies:
- Vite/React (Frontend)
- FastAPI (Backend)
- PostgreSQL (Database)
- R2 (Storage)
- Docker (Containerization)
- Nginx (Reverse Proxy)

Remember to:
- Version information
- Security boundaries
- Scalable components
- Monitoring/logging points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[React Frontend]:::frontend
        Auth[Authentication UI]:::frontend
        Price[Pricing Module]:::frontend
        Profile[User Profile]:::frontend
    end

    subgraph Proxy
        Nginx[Nginx Reverse Proxy]:::infra
    end

    subgraph Backend
        FastAPI[FastAPI Backend]:::backend
        VideoProc[Video Processing Service]:::backend
        Search[Search Service]:::backend
        R2Manager[R2 Storage Manager]:::backend
        DBIntegration[Database Integration]:::backend
    end

    subgraph "External Services"
        PG[(PostgreSQL)]:::external
        R2[(R2 Storage)]:::external
        Google[Google Services]:::external
    end

    subgraph "Infrastructure & Config"
        Docker[Docker]:::infra
        EnvConfig[Environment Config]:::infra
        DevConfig[Development Config]:::infra
        BuildScripts[Build Scripts]:::infra
    end

    %% Relationships
    FE --> |API Requests| Nginx
    Auth --> |Auth Requests| Nginx
    Price --> |Pricing Data| Nginx
    Profile --> |Profile Updates| Nginx

    Nginx --> FastAPI
    FastAPI --> VideoProc
    FastAPI --> Search
    FastAPI --> R2Manager
    FastAPI --> DBIntegration

    DBIntegration --> PG
    R2Manager --> R2
    DBIntegration --> Google

    %% Click Events
    click FE "https://github.com/eusholli/ttv-ai-clipper/blob/main/frontend/src/App.jsx"
    click Auth "https://github.com/eusholli/ttv-ai-clipper/tree/main/frontend/src/components/auth"
    click Price "https://github.com/eusholli/ttv-ai-clipper/blob/main/frontend/src/components/pricing/Pricing.jsx"
    click Profile "https://github.com/eusholli/ttv-ai-clipper/blob/main/frontend/src/components/auth/UserProfile.jsx"
    click FastAPI "https://github.com/eusholli/ttv-ai-clipper/blob/main/backend/main.py"
    click VideoProc "https://github.com/eusholli/ttv-ai-clipper/blob/main/backend/video_utils.py"
    click Search "https://github.com/eusholli/ttv-ai-clipper/blob/main/backend/transcript_search.py"
    click R2Manager "https://github.com/eusholli/ttv-ai-clipper/blob/main/backend/r2_manager.py"
    click DBIntegration "https://github.com/eusholli/ttv-ai-clipper/blob/main/backend/google_found_psql.py"
    click Nginx "https://github.com/eusholli/ttv-ai-clipper/blob/main/nginx.conf"
    click Docker "https://github.com/eusholli/ttv-ai-clipper/tree/main/Dockerfile"
    click EnvConfig "https://github.com/eusholli/ttv-ai-clipper/blob/main/.env.example"
    click DevConfig "https://github.com/eusholli/ttv-ai-clipper/blob/main/.devcontainer/devcontainer.json"
    click BuildScripts "https://github.com/eusholli/ttv-ai-clipper/blob/main/build.sh"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef external fill:#FFC107,color:black
    classDef infra fill:#9E9E9E,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend Component]:::frontend
        Backend[Backend Service]:::backend
        External[External Service]:::external
        Infrastructure[Infrastructure]:::infra
    end
```
