# ksy1022/zzongai_song architecture

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

- Interactive diagram: https://gitdiagram.com/ksy1022/zzongai_song
- Repository: https://github.com/ksy1022/zzongai_song

## Overview

ZZongAI turns study material into learning lyrics, a melody guide, and optionally a generated song. The web backend accepts image/text and file-based requests; image and PDF processing support input extraction, while the documented RAG workflow queries a nursery-rhyme collection and coordinates query, retrieval, reasoning, generation, and self-review. The workflow can submit a song request and return audio results. Relationships for sampled modules are cited; some documented capabilities and unsampled server integrations are shown only at the level supported by the README or source index.

Main entry points: [`src/core/workflow.py`](https://github.com/ksy1022/zzongai_song/blob/main/src/core/workflow.py) (Pipeline Workflow), [`src/server.py`](https://github.com/ksy1022/zzongai_song/blob/main/src/server.py) (FastAPI Backend), [`src/rag/orchestrator.py`](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/orchestrator.py) (RAG Orchestrator), [`src/run_pipeline.py`](https://github.com/ksy1022/zzongai_song/blob/main/src/run_pipeline.py) (CLI Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_webui["Web Interface<br/>[main.js]"]
  node_api["FastAPI Backend<br/>[server.py]"]
  node_logger["Generation Logging<br/>[logger.py]"]
end

subgraph group_input["Study Input"]
  node_image["Image Text Extraction<br/>[vision_to_query.py]"]
  node_image_analysis["Image Analysis<br/>[image_analyzer.py]"]
  node_pdf["PDF Processing<br/>[pdf_processor.py]"]
  node_workflow["Pipeline Workflow<br/>[workflow.py]"]
  node_cli["CLI Entry<br/>[run_pipeline.py]"]
end

subgraph group_rag["RAG and Lyrics"]
  node_ragflow["RAG Orchestrator<br/>[orchestrator.py]"]
  node_query["Query Agent<br/>[query_agent.py]"]
  node_retriever["Retriever Agent<br/>[retriever_agent.py]"]
  node_vectordb[("Nursery Rhyme Index<br/>[vector_db.py]")]
  node_reasoner["Reasoner Agent<br/>[reasoner_agent.py]"]
  node_generator["Lyrics Generator<br/>[generator_agent.py]"]
  node_selfrag["Lyrics Review<br/>[self_rag_agent.py]"]
end

subgraph group_song["Song Generation"]
  node_lyrics_extract["Lyrics Extractor"]
  node_prompt["Song Prompt Builder<br/>[compose_prompt.py]"]
  node_suno_client["Suno Client<br/>[suno_client.py]"]
  node_audio["Audio Saving<br/>[mureka_utils.py]"]
end

node_learner(("Learner"))
node_suno{{"Suno AI"}}

node_learner -.->|"submits material"| node_webui
node_webui -.->|"sends requests"| node_api
node_api -.->|"runs pipeline"| node_workflow
node_api -.->|"analyzes images"| node_image_analysis
node_api -.->|"processes files"| node_pdf
node_api -->|"generates lyrics"| node_ragflow
node_api -.->|"records events"| node_logger
node_cli -->|"runs pipeline"| node_workflow
node_workflow -->|"extracts text"| node_image
node_workflow -->|"creates guide"| node_generator
node_workflow -->|"builds payload"| node_prompt
node_workflow -->|"requests song"| node_suno_client
node_workflow -->|"extracts lyrics"| node_lyrics_extract
node_ragflow -->|"interprets input"| node_query
node_ragflow -->|"retrieves examples"| node_retriever
node_ragflow -->|"builds guidance"| node_reasoner
node_ragflow -->|"generates lyrics"| node_generator
node_ragflow -->|"reviews lyrics"| node_selfrag
node_retriever -->|"searches index"| node_vectordb
node_suno_client -->|"creates and polls"| node_suno
node_cli -->|"saves audio"| node_audio

click node_webui "https://github.com/ksy1022/zzongai_song/blob/main/web/static/main.js"
click node_api "https://github.com/ksy1022/zzongai_song/blob/main/src/server.py"
click node_logger "https://github.com/ksy1022/zzongai_song/blob/main/dashboard_logs/logger.py"
click node_image "https://github.com/ksy1022/zzongai_song/blob/main/src/processors/vision_to_query.py"
click node_image_analysis "https://github.com/ksy1022/zzongai_song/blob/main/src/processors/image_analyzer.py"
click node_pdf "https://github.com/ksy1022/zzongai_song/blob/main/src/processors/pdf_processor.py"
click node_workflow "https://github.com/ksy1022/zzongai_song/blob/main/src/core/workflow.py"
click node_cli "https://github.com/ksy1022/zzongai_song/blob/main/src/run_pipeline.py"
click node_ragflow "https://github.com/ksy1022/zzongai_song/blob/main/src/rag/orchestrator.py"
click node_query "https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/query_agent.py"
click node_retriever "https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/retriever_agent.py"
click node_vectordb "https://github.com/ksy1022/zzongai_song/blob/main/src/rag/vector_db.py"
click node_reasoner "https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/reasoner_agent.py"
click node_generator "https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/generator_agent.py"
click node_selfrag "https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/self_rag_agent.py"
click node_lyrics_extract "https://github.com/ksy1022/zzongai_song/blob/main/src/lyrics/lyrics_extractor.py"
click node_prompt "https://github.com/ksy1022/zzongai_song/blob/main/src/lyrics/compose_prompt.py"
click node_suno_client "https://github.com/ksy1022/zzongai_song/blob/main/src/clients/suno_client.py"
click node_audio "https://github.com/ksy1022/zzongai_song/blob/main/src/core/mureka_utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webui,node_api,node_logger toneBlue
class node_image,node_image_analysis,node_pdf,node_workflow,node_cli toneAmber
class node_ragflow,node_query,node_retriever,node_vectordb,node_reasoner,node_generator,node_selfrag toneMint
class node_lyrics_extract,node_prompt,node_suno_client,node_audio toneRose
class node_learner,node_suno toneIndigo
```

## Components

### User Interface

- [Web Interface](https://github.com/ksy1022/zzongai_song/blob/main/web/static/main.js): `web/static/main.js`
- [FastAPI Backend](https://github.com/ksy1022/zzongai_song/blob/main/src/server.py): `src/server.py`
- [Generation Logging](https://github.com/ksy1022/zzongai_song/blob/main/dashboard_logs/logger.py): `dashboard_logs/logger.py`

### Study Input

- [Image Text Extraction](https://github.com/ksy1022/zzongai_song/blob/main/src/processors/vision_to_query.py): `src/processors/vision_to_query.py`
- [Image Analysis](https://github.com/ksy1022/zzongai_song/blob/main/src/processors/image_analyzer.py): `src/processors/image_analyzer.py`
- [PDF Processing](https://github.com/ksy1022/zzongai_song/blob/main/src/processors/pdf_processor.py): `src/processors/pdf_processor.py`
- [Pipeline Workflow](https://github.com/ksy1022/zzongai_song/blob/main/src/core/workflow.py): `src/core/workflow.py`
- [CLI Entry](https://github.com/ksy1022/zzongai_song/blob/main/src/run_pipeline.py): `src/run_pipeline.py`

### RAG and Lyrics

- [RAG Orchestrator](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/orchestrator.py): `src/rag/orchestrator.py`
- [Query Agent](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/query_agent.py): `src/rag/agents/query_agent.py`
- [Retriever Agent](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/retriever_agent.py): `src/rag/agents/retriever_agent.py`
- [Nursery Rhyme Index](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/vector_db.py): `src/rag/vector_db.py`
- [Reasoner Agent](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/reasoner_agent.py): `src/rag/agents/reasoner_agent.py`
- [Lyrics Generator](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/generator_agent.py): `src/rag/agents/generator_agent.py`
- [Lyrics Review](https://github.com/ksy1022/zzongai_song/blob/main/src/rag/agents/self_rag_agent.py): `src/rag/agents/self_rag_agent.py`

### Song Generation

- [Lyrics Extractor](https://github.com/ksy1022/zzongai_song/blob/main/src/lyrics/lyrics_extractor.py): `src/lyrics/lyrics_extractor.py`
- [Song Prompt Builder](https://github.com/ksy1022/zzongai_song/blob/main/src/lyrics/compose_prompt.py): `src/lyrics/compose_prompt.py`
- [Suno Client](https://github.com/ksy1022/zzongai_song/blob/main/src/clients/suno_client.py): `src/clients/suno_client.py`
- [Audio Saving](https://github.com/ksy1022/zzongai_song/blob/main/src/core/mureka_utils.py): `src/core/mureka_utils.py`

### Other components

- **Learner**
- **Suno AI**

## Connections

- Learner → Web Interface: submits material (evidence: `README.md`)
- Web Interface → FastAPI Backend: sends requests
- FastAPI Backend → Pipeline Workflow: runs pipeline (evidence: `src/server.py`)
- FastAPI Backend → Image Analysis: analyzes images (evidence: `src/server.py`)
- FastAPI Backend → PDF Processing: processes files (evidence: `src/server.py`)
- FastAPI Backend → RAG Orchestrator: generates lyrics (evidence: `src/server.py`)
- FastAPI Backend → Generation Logging: records events (evidence: `src/server.py`)
- CLI Entry → Pipeline Workflow: runs pipeline (evidence: `src/run_pipeline.py`)
- Pipeline Workflow → Image Text Extraction: extracts text (evidence: `src/core/workflow.py`)
- Pipeline Workflow → Lyrics Generator: creates guide (evidence: `src/core/workflow.py`)
- Pipeline Workflow → Song Prompt Builder: builds payload (evidence: `src/core/workflow.py`)
- Pipeline Workflow → Suno Client: requests song (evidence: `src/core/workflow.py`)
- Pipeline Workflow → Lyrics Extractor: extracts lyrics (evidence: `src/core/workflow.py`)
- RAG Orchestrator → Query Agent: interprets input (evidence: `src/rag/orchestrator.py`)
- RAG Orchestrator → Retriever Agent: retrieves examples (evidence: `src/rag/orchestrator.py`)
- RAG Orchestrator → Reasoner Agent: builds guidance (evidence: `src/rag/orchestrator.py`)
- RAG Orchestrator → Lyrics Generator: generates lyrics (evidence: `src/rag/orchestrator.py`)
- RAG Orchestrator → Lyrics Review: reviews lyrics (evidence: `src/rag/orchestrator.py`)
- Retriever Agent → Nursery Rhyme Index: searches index (evidence: `src/rag/agents/retriever_agent.py`)
- Suno Client → Suno AI: creates and polls (evidence: `src/clients/suno_client.py`)
- CLI Entry → Audio Saving: saves audio (evidence: `src/run_pipeline.py`)
