# linyqh/narratoai architecture

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

- Interactive diagram: https://gitdiagram.com/linyqh/narratoai
- Repository: https://github.com/linyqh/narratoai

## Overview

NarratoAI is a Streamlit-based AI video-narration and editing application. Users configure models and media settings, provide video or subtitles, generate narration or short-drama scripts, then produce voiceover, subtitles, edited video, and optionally a Jianying draft. The README documents these end-to-end capabilities; source-index references show selected implementation links, but many runtime modules were not sampled, so unsupported call relationships are omitted.

Main entry points: [`webui.py`](https://github.com/linyqh/narratoai/blob/main/webui.py) (Web application), [`webui/tools/generate_short_summary.py`](https://github.com/linyqh/narratoai/blob/main/webui/tools/generate_short_summary.py) (Short-drama tool), [`app/services/generate_video.py`](https://github.com/linyqh/narratoai/blob/main/app/services/generate_video.py) (Video generation), [`webui/components/audio_settings.py`](https://github.com/linyqh/narratoai/blob/main/webui/components/audio_settings.py) (Audio settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_webui["Web application<br/>[webui.py]"]
  node_settings["Model settings<br/>[basic_settings.py]"]
  node_audio_settings["Audio settings<br/>[audio_settings.py]"]
  node_script_settings["Script settings<br/>[script_settings.py]"]
end

subgraph group_scripts["Script generation"]
  node_short_tool["Short-drama tool"]
  node_short_pipeline["Short-drama scripts"]
  node_short_edit["Short-drama editing"]
  node_doc_tool["Documentary tool"]
  node_frame_analysis["Frame analysis"]
  node_narration["Narration generation"]
  node_subtitle_analysis["Subtitle analysis"]
end

subgraph group_media["Media production"]
  node_asr["Subtitle transcription"]
  node_subtitle_text["Subtitle processing<br/>[subtitle_text.py]"]
  node_video_gen["Video generation<br/>[generate_video.py]"]
  node_material["Video materials<br/>[material.py]"]
  node_voice["Voice synthesis<br/>[voice.py]"]
  node_audio_merge["Audio assembly<br/>[audio_merger.py]"]
  node_draft["Jianying export<br/>[jianying_task.py]"]
  node_music["Sonilo music<br/>[sonilo.py]"]
end

subgraph group_services["Shared services"]
  node_llm["Unified LLM<br/>[unified_service.py]"]
  node_llm_manager["Provider manager<br/>[manager.py]"]
  node_config["Application config<br/>[config.py]"]
  node_schema["Data schemas<br/>[schema.py]"]
  node_ffmpeg["FFmpeg processing<br/>[ffmpeg_utils.py]"]
  node_search["Web research<br/>[tavily_search.py]"]
end

node_creator(("Content creator"))
node_subtitle_provider{{"ASR service"}}
node_model_provider{{"LLM provider"}}

node_creator -->|"submits media"| node_webui
node_webui -->|"renders settings"| node_settings
node_webui -->|"renders settings"| node_audio_settings
node_webui -->|"renders settings"| node_script_settings
node_webui -->|"offers scripts"| node_short_tool
node_script_settings -->|"invokes"| node_short_tool
node_short_tool -->|"generates narration"| node_short_pipeline
node_short_tool -->|"requests research"| node_search
node_short_tool -->|"uses subtitles"| node_subtitle_text
node_webui -->|"offers generation"| node_doc_tool
node_doc_tool -->|"analyzes footage"| node_frame_analysis
node_frame_analysis -->|"uses generation"| node_narration
node_frame_analysis -.->|"analyzes frames"| node_model_provider
node_short_pipeline -->|"uses subtitles"| node_subtitle_text
node_short_edit -->|"analyzes subtitles"| node_subtitle_analysis
node_short_tool -->|"starts editing scripts"| node_short_edit
node_llm -->|"gets providers"| node_llm_manager
node_settings -->|"updates settings"| node_config
node_llm_manager -->|"reads provider config"| node_config
node_llm -.->|"sends prompts"| node_model_provider
node_webui -->|"uses data schema"| node_schema
node_webui -->|"starts video work"| node_video_gen
node_video_gen -->|"uses materials"| node_material
node_audio_settings -->|"configures voice"| node_voice
node_voice -.->|"assembles audio"| node_audio_merge
node_video_gen -.->|"processes media"| node_ffmpeg
node_video_gen -.->|"exports draft"| node_draft
node_audio_settings -->|"configures music"| node_music
node_asr -.->|"transcribes audio"| node_subtitle_provider
node_creator -.->|"requests transcription"| node_asr

click node_webui "https://github.com/linyqh/narratoai/blob/main/webui.py"
click node_settings "https://github.com/linyqh/narratoai/blob/main/webui/components/basic_settings.py"
click node_audio_settings "https://github.com/linyqh/narratoai/blob/main/webui/components/audio_settings.py"
click node_script_settings "https://github.com/linyqh/narratoai/blob/main/webui/components/script_settings.py"
click node_short_tool "https://github.com/linyqh/narratoai/blob/main/webui/tools/generate_short_summary.py"
click node_short_pipeline "https://github.com/linyqh/narratoai/blob/main/app/services/SDE/short_drama_explanation.py"
click node_short_edit "https://github.com/linyqh/narratoai/blob/main/app/services/SDP/generate_script_short.py"
click node_doc_tool "https://github.com/linyqh/narratoai/blob/main/webui/tools/generate_script_docu.py"
click node_frame_analysis "https://github.com/linyqh/narratoai/blob/main/app/services/documentary/frame_analysis_service.py"
click node_narration "https://github.com/linyqh/narratoai/blob/main/app/services/generate_narration_script.py"
click node_llm "https://github.com/linyqh/narratoai/blob/main/app/services/llm/unified_service.py"
click node_llm_manager "https://github.com/linyqh/narratoai/blob/main/app/services/llm/manager.py"
click node_config "https://github.com/linyqh/narratoai/blob/main/app/config/config.py"
click node_schema "https://github.com/linyqh/narratoai/blob/main/app/models/schema.py"
click node_asr "https://github.com/linyqh/narratoai/blob/main/app/services/fun_asr_subtitle.py"
click node_subtitle_text "https://github.com/linyqh/narratoai/blob/main/app/services/subtitle_text.py"
click node_video_gen "https://github.com/linyqh/narratoai/blob/main/app/services/generate_video.py"
click node_material "https://github.com/linyqh/narratoai/blob/main/app/services/material.py"
click node_voice "https://github.com/linyqh/narratoai/blob/main/app/services/voice.py"
click node_audio_merge "https://github.com/linyqh/narratoai/blob/main/app/services/audio_merger.py"
click node_ffmpeg "https://github.com/linyqh/narratoai/blob/main/app/utils/ffmpeg_utils.py"
click node_draft "https://github.com/linyqh/narratoai/blob/main/app/services/jianying_task.py"
click node_music "https://github.com/linyqh/narratoai/blob/main/app/services/sonilo.py"
click node_search "https://github.com/linyqh/narratoai/blob/main/app/services/tavily_search.py"
click node_subtitle_analysis "https://github.com/linyqh/narratoai/blob/main/app/services/SDP/utils/step1_subtitle_analyzer_openai.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_settings,node_audio_settings,node_script_settings toneBlue
class node_short_tool,node_short_pipeline,node_short_edit,node_doc_tool,node_frame_analysis,node_narration,node_subtitle_analysis toneAmber
class node_asr,node_subtitle_text,node_video_gen,node_material,node_voice,node_audio_merge,node_draft,node_music toneMint
class node_llm,node_llm_manager,node_config,node_schema,node_ffmpeg,node_search toneRose
class node_creator,node_subtitle_provider,node_model_provider toneIndigo
```

## Components

### User interface

- [Web application](https://github.com/linyqh/narratoai/blob/main/webui.py): `webui.py`
- [Model settings](https://github.com/linyqh/narratoai/blob/main/webui/components/basic_settings.py): `webui/components/basic_settings.py`
- [Audio settings](https://github.com/linyqh/narratoai/blob/main/webui/components/audio_settings.py): `webui/components/audio_settings.py`
- [Script settings](https://github.com/linyqh/narratoai/blob/main/webui/components/script_settings.py): `webui/components/script_settings.py`

### Script generation

- [Short-drama tool](https://github.com/linyqh/narratoai/blob/main/webui/tools/generate_short_summary.py): `webui/tools/generate_short_summary.py`
- [Short-drama scripts](https://github.com/linyqh/narratoai/blob/main/app/services/SDE/short_drama_explanation.py): `app/services/SDE/short_drama_explanation.py`
- [Short-drama editing](https://github.com/linyqh/narratoai/blob/main/app/services/SDP/generate_script_short.py): `app/services/SDP/generate_script_short.py`
- [Documentary tool](https://github.com/linyqh/narratoai/blob/main/webui/tools/generate_script_docu.py): `webui/tools/generate_script_docu.py`
- [Frame analysis](https://github.com/linyqh/narratoai/blob/main/app/services/documentary/frame_analysis_service.py): `app/services/documentary/frame_analysis_service.py`
- [Narration generation](https://github.com/linyqh/narratoai/blob/main/app/services/generate_narration_script.py): `app/services/generate_narration_script.py`
- [Subtitle analysis](https://github.com/linyqh/narratoai/blob/main/app/services/SDP/utils/step1_subtitle_analyzer_openai.py): `app/services/SDP/utils/step1_subtitle_analyzer_openai.py`

### Media production

- [Subtitle transcription](https://github.com/linyqh/narratoai/blob/main/app/services/fun_asr_subtitle.py): `app/services/fun_asr_subtitle.py`
- [Subtitle processing](https://github.com/linyqh/narratoai/blob/main/app/services/subtitle_text.py): `app/services/subtitle_text.py`
- [Video generation](https://github.com/linyqh/narratoai/blob/main/app/services/generate_video.py): `app/services/generate_video.py`
- [Video materials](https://github.com/linyqh/narratoai/blob/main/app/services/material.py): `app/services/material.py`
- [Voice synthesis](https://github.com/linyqh/narratoai/blob/main/app/services/voice.py): `app/services/voice.py`
- [Audio assembly](https://github.com/linyqh/narratoai/blob/main/app/services/audio_merger.py): `app/services/audio_merger.py`
- [Jianying export](https://github.com/linyqh/narratoai/blob/main/app/services/jianying_task.py): `app/services/jianying_task.py`
- [Sonilo music](https://github.com/linyqh/narratoai/blob/main/app/services/sonilo.py): `app/services/sonilo.py`

### Shared services

- [Unified LLM](https://github.com/linyqh/narratoai/blob/main/app/services/llm/unified_service.py): `app/services/llm/unified_service.py`
- [Provider manager](https://github.com/linyqh/narratoai/blob/main/app/services/llm/manager.py): `app/services/llm/manager.py`
- [Application config](https://github.com/linyqh/narratoai/blob/main/app/config/config.py): `app/config/config.py`
- [Data schemas](https://github.com/linyqh/narratoai/blob/main/app/models/schema.py): `app/models/schema.py`
- [FFmpeg processing](https://github.com/linyqh/narratoai/blob/main/app/utils/ffmpeg_utils.py): `app/utils/ffmpeg_utils.py`
- [Web research](https://github.com/linyqh/narratoai/blob/main/app/services/tavily_search.py): `app/services/tavily_search.py`

### Other components

- **Content creator**
- **ASR service**
- **LLM provider**

## Connections

- Content creator → Web application: submits media (evidence: `README.md`)
- Web application → Model settings: renders settings (evidence: `webui.py`)
- Web application → Audio settings: renders settings (evidence: `webui.py`)
- Web application → Script settings: renders settings (evidence: `webui.py`)
- Web application → Short-drama tool: offers scripts
- Script settings → Short-drama tool: invokes (evidence: `webui/components/script_settings.py`)
- Short-drama tool → Short-drama scripts: generates narration (evidence: `webui/tools/generate_short_summary.py`)
- Short-drama tool → Web research: requests research (evidence: `webui/tools/generate_short_summary.py`)
- Short-drama tool → Subtitle processing: uses subtitles (evidence: `webui/tools/generate_short_summary.py`)
- Web application → Documentary tool: offers generation (evidence: `webui.py`)
- Documentary tool → Frame analysis: analyzes footage (evidence: `webui/tools/generate_script_docu.py`)
- Frame analysis → Narration generation: uses generation (evidence: `app/services/documentary/frame_analysis_service.py`)
- Frame analysis → LLM provider: analyzes frames
- Short-drama scripts → Subtitle processing: uses subtitles (evidence: `app/services/SDE/short_drama_explanation.py`)
- Short-drama editing → Subtitle analysis: analyzes subtitles (evidence: `app/services/SDP/generate_script_short.py`)
- Short-drama tool → Short-drama editing: starts editing scripts (evidence: `webui/tools/generate_script_short.py`)
- Unified LLM → Provider manager: gets providers (evidence: `app/services/llm/unified_service.py`)
- Model settings → Application config: updates settings (evidence: `webui/components/basic_settings.py`)
- Provider manager → Application config: reads provider config (evidence: `app/services/llm/manager.py`)
- Unified LLM → LLM provider: sends prompts
- Web application → Data schemas: uses data schema (evidence: `webui.py`)
- Web application → Video generation: starts video work
- Video generation → Video materials: uses materials
- Audio settings → Voice synthesis: configures voice (evidence: `webui/components/audio_settings.py`)
- Voice synthesis → Audio assembly: assembles audio
- Video generation → FFmpeg processing: processes media
- Video generation → Jianying export: exports draft
- Audio settings → Sonilo music: configures music (evidence: `webui/components/audio_settings.py`)
- Subtitle transcription → ASR service: transcribes audio
- Content creator → Subtitle transcription: requests transcription
