# lihuithe/podlm-public architecture

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

- Interactive diagram: https://gitdiagram.com/lihuithe/podlm-public
- Repository: https://github.com/lihuithe/podlm-public

## Overview

##### Project Type and Purpose
- This is a full‑stack Python web application that:
- Presents a simple HTML/JS frontend (index.html, list.html, del.html)
- Exposes HTTP endpoints (api.py)
- Runs a background task processor (server.py / server_pro.py)
- Invokes an LLM + TTS service (via ffmpeg)
- Persists task metadata locally (task_list.json)
- Optionally publishes final audio to 小宇宙 via their API

##### File Structure
- Top‐level scripts:
- api.py – the Flask/FastAPI (or similar) web/API server
- server.py – multi‑threaded task executor
- server_pro.py – same as server.py with extra Xiao宇宙 publishing logic
- config.demo.py – template for config.py (LLM & TTS credentials, endpoints)
- Static/UI assets:
- index.html, list.html, del.html
- resources/css/styles.css
- resources/js/manage.js
- Dependencies & config:
- requirements.txt
- config.py (copied from config.demo.py)
- Storage:
- task_list.json (maintains records of all conversions)

##### README for Additional Insights
- Long‑running services: api.py and server(.py|_pro).py must both run concurrently.
- External prerequisites: ffmpeg in PATH, LLM & TTS service endpoints.
- Access patterns: browser → API → background worker → LLM/TTS → output → UI / external publish.

a. Frontend (Client‑side)
- Components: index.html, list.html, del.html + CSS/JS
- Technology: HTML5, CSS, vanilla JS or jQuery
b. API Layer
- Component: api.py (Flask/FastAPI)
- Responsibilities:
– Receives user requests (trigger conversion, list tasks, delete tasks)
– Stores/reads task metadata in task_list.json
– Returns status to frontend
c. Task Processor
- Component: server.py / server_pro.py
- Responsibilities:
– Polls or listens for new tasks
– Spawns threads to:
1. Fetch & parse URL content via LLM
2. Generate audio via TTS service + ffmpeg
3. Save resulting audio file
4. Update task_list.json
5. (server_pro only) Push audio file to 小宇宙 API
d. External Services
- LLM Service (e.g., OpenAI, local model endpoint)
- TTS Service (e.g., Azure Cognitive, Google Cloud TTS)
- 小宇宙 Publishing API (only in server_pro.py)
e. Local Storage
- task_list.json (JSON file acting as simple DB)
- Audio file directory (not shown but implied)

##### Architectural Patterns / Design Principles
- Layered separation:
1. Presentation (Frontend)
2. API (api.py)
3. Worker / Business Logic (server.py)
4. Persistence (task_list.json + file storage)
5. External Integration (LLM, TTS, Xiao宇宙)
- Async / multi‑threaded processing for long‑running tasks
- Configuration externalization (config.py)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["User Browser"]:::external
        FrontendHTML["HTML Pages: index.html, list.html, del.html"]:::frontend
        FrontendCSS["CSS: resources/css/styles.css"]:::frontend
        FrontendJS["JS: resources/js/manage.js"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        APIServer["API Server: api.py"]:::backend
        Config["Config Template: config.demo.py"]:::backend
        Dependencies["Dependencies: requirements.txt"]:::backend
    end

    %% Storage
    subgraph "Storage"
        direction TB
        TaskDB["task_list.json"]:::storage
        AudioStore["Local Audio Storage"]:::storage
    end

    %% Worker Layer
    subgraph "Task Worker"
        direction TB
        WorkerBasic["Background Worker: server.py"]:::worker
        WorkerPro["Worker with Publishing: server_pro.py"]:::worker
    end

    %% External Services
    subgraph "External Services"
        direction TB
        LLM["LLM Service"]:::external
        TTS["TTS Service"]:::external
        FFMPEG["ffmpeg"]:::external
        XiaoAPI["小宇宙 Publishing API"]:::external
    end

    %% Data Flow
    Browser --> FrontendHTML
    Browser --> FrontendCSS
    Browser --> FrontendJS
    FrontendHTML --> APIServer
    FrontendCSS --> APIServer
    FrontendJS --> APIServer
    APIServer --> TaskDB
    TaskDB --> APIServer
    APIServer --> WorkerBasic
    APIServer --> WorkerPro
    WorkerBasic --> LLM
    WorkerBasic --> TTS
    WorkerBasic --> FFMPEG
    WorkerBasic --> AudioStore
    WorkerBasic --> APIServer
    WorkerPro --> LLM
    WorkerPro --> TTS
    WorkerPro --> FFMPEG
    WorkerPro --> AudioStore
    WorkerPro -- Conditional Publish --> XiaoAPI
    XiaoAPI -.-> APIServer

    %% Click Events
    click FrontendHTML "https://github.com/lihuithe/podlm-public/blob/main/index.html"
    click FrontendHTML "https://github.com/lihuithe/podlm-public/blob/main/list.html"
    click FrontendHTML "https://github.com/lihuithe/podlm-public/blob/main/del.html"
    click FrontendCSS "https://github.com/lihuithe/podlm-public/blob/main/resources/css/styles.css"
    click FrontendJS "https://github.com/lihuithe/podlm-public/blob/main/resources/js/manage.js"
    click APIServer "https://github.com/lihuithe/podlm-public/blob/main/api.py"
    click Config "https://github.com/lihuithe/podlm-public/blob/main/config.demo.py"
    click WorkerBasic "https://github.com/lihuithe/podlm-public/blob/main/server.py"
    click WorkerPro "https://github.com/lihuithe/podlm-public/blob/main/server_pro.py"
    click Dependencies "https://github.com/lihuithe/podlm-public/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#deebf7,stroke:#3182bd,color:#000;
    classDef backend fill:#d5f5e3,stroke:#27ae60,color:#000;
    classDef worker fill:#fad7a0,stroke:#d35400,color:#000;
    classDef storage fill:#f9e79f,stroke:#b7950b,color:#000,shape:cylinder;
    classDef external fill:#f4f6f7,stroke:#7f8c8d,stroke-dasharray: 5 5,color:#000;
```
