# halfprice06/longslop architecture

> Architecture diagram of the GitHub repository halfprice06/longslop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/halfprice06/longslop
- Repository: https://github.com/halfprice06/longslop

## Overview

##### Main Components Overview

a) Client Layer:
- Frontend components (HTML, CSS, JS) that handle user interactions
- SSE (Server-Sent Events) connection

b) API Layer:
- FastAPI server as the central coordinator
- Route handlers for article generation

c) Service Layer:
- LLM Service (OpenAI/Anthropic integration)
- Audio Service (ElevenLabs integration)
- Image Service (based on file structure)

d) Data Layer:
- SQLite database for logging
- Constants storage (writing styles, forbidden words)

##### Component Relationships

- Frontend → FastAPI (HTTP/SSE)
- FastAPI → Service Layer (internal calls)
- Service Layer → External APIs (OpenAI/Anthropic, ElevenLabs)
- Service Layer → Database (logging)

##### Detailed Component Breakdown

For each major component, include these details:

Frontend Section:
**[Frontend UI]**
- index.html
- script.js (SSE handler)
- style.css (Tailwind)

API Layer:
**[FastAPI Server]**
- Route Handlers
- Schema Validation
- SSE Streaming

Service Layer:
**[LLM Service]**
- Content Generation
- Style Enforcement
- Plan/Outline Creation

**[Audio Service]**
- Text-to-Speech
- Audio Processing

**[Image Service]**
- Image Processing

Data Layer:
**[SQLite Database]**
- LLM Call Logs

**[Constants]**
- Writing Styles
- Forbidden Words
- Scene Scripts

##### Data Flow Visualization

- → Synchronous requests
- ⇢ Asynchronous operations
- ⇄ Bi-directional communication (SSE)

##### Technical Details

Small notes indicating:
- Python 3.9+
- FastAPI framework
- SQLite database
- External API dependencies
- Environment variables

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI["Frontend UI"]
        SSE["SSE Handler"]
        UI --> SSE
    end

    subgraph API
        FastAPI["FastAPI Server"]
        Routes["Route Handlers"]
        Schemas["Schema Validation"]
        FastAPI --> Routes
        FastAPI --> Schemas
    end

    subgraph Services
        LLM["LLM Service"]
        Audio["Audio Service"]
        Image["Image Service"]
    end

    subgraph Data
        DB[(SQLite Database)]
        Constants["Constants Storage"]
    end

    subgraph External
        OpenAI["OpenAI/Anthropic API"]
        ElevenLabs["ElevenLabs API"]
    end

    %% Main Flow
    UI --> FastAPI
    SSE <-.-> FastAPI
    Routes --> LLM
    Routes --> Audio
    Routes --> Image
    
    %% Service Connections
    LLM --> OpenAI
    Audio --> ElevenLabs
    LLM --> DB
    Audio --> DB
    Image --> DB
    
    %% Data Access
    LLM --> Constants
    Audio --> Constants
    Image --> Constants

    %% Click Events
    click UI "https://github.com/halfprice06/longslop/blob/main/frontend/index.html"
    click SSE "https://github.com/halfprice06/longslop/blob/main/frontend/script.js"
    click FastAPI "https://github.com/halfprice06/longslop/blob/main/main.py"
    click Routes "https://github.com/halfprice06/longslop/blob/main/app/routes/article_routes.py"
    click Schemas "https://github.com/halfprice06/longslop/blob/main/app/schemas.py"
    click LLM "https://github.com/halfprice06/longslop/blob/main/app/services/llm_service.py"
    click Audio "https://github.com/halfprice06/longslop/blob/main/app/services/audio_service.py"
    click Image "https://github.com/halfprice06/longslop/blob/main/app/services/image_service.py"
    click DB "https://github.com/halfprice06/longslop/blob/main/app/database.py"
    click Constants "https://github.com/halfprice06/longslop/tree/main/app/constants"

    %% Styling
    classDef frontend fill:#a2d2ff
    classDef api fill:#bde0fe
    classDef service fill:#ffafcc
    classDef data fill:#ffc8dd
    classDef external fill:#cdb4db
    
    class UI,SSE frontend
    class FastAPI,Routes,Schemas api
    class LLM,Audio,Image service
    class DB,Constants data
    class OpenAI,ElevenLabs external

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        APIComp["API Component"]:::api
        ServiceComp["Service Component"]:::service
        DataComp["Data Component"]:::data
        ExtComp["External Service"]:::external
        
        Flow1["--> Sync Request"]
        Flow2["-.-> Async/SSE"]
    end
```
