# glfzr/qianbi-novel architecture

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

- Interactive diagram: https://gitdiagram.com/glfzr/qianbi-novel
- Repository: https://github.com/glfzr/qianbi-novel

## Overview

千笔一文是面向长篇网文创作的本地桌面应用，作者可与 AI 分阶段共写，也可运行自动写作流水线。主要工作流从项目与设定出发，经过大纲、章节细纲、正文生成、扫描与审校、设定清算，最后锁定章节并更新追踪记忆。共写决策门、条目化世界书和模型槽位路由支撑这一流程；外部文档导入是独立能力分支。说明依据 README 与所给源码片段；未采样实现的细节和调用关系不作推断。

Main entry points: [`app/core/stages.py`](https://github.com/glfzr/qianbi-novel/blob/main/app/core/stages.py) (阶段生成), [`app/core/orchestrator.py`](https://github.com/glfzr/qianbi-novel/blob/main/app/core/orchestrator.py) (流程调度), [`app/ui/bridge.py`](https://github.com/glfzr/qianbi-novel/blob/main/app/ui/bridge.py) (界面桥接), [`app/importdoc.py`](https://github.com/glfzr/qianbi-novel/blob/main/app/importdoc.py) (文档导入)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["作者交互"]
  node_desktop["桌面应用<br/>[main.py]"]
  node_bridge["界面桥接<br/>[bridge.py]"]
end

subgraph group_workflow["创作流程"]
  node_orchestrator["流程调度<br/>[orchestrator.py]"]
  node_stages["阶段生成<br/>[stages.py]"]
  node_cowriting["共写阶段<br/>[co_writing.py]"]
  node_gates["作者决策门<br/>[gates.py]"]
  node_importdoc["文档导入<br/>[importdoc.py]"]
  node_preset["题材预设<br/>[__init__.py]"]
end

subgraph group_quality["一致性与审校"]
  node_scan["确定性预检<br/>[scan.py]"]
  node_mustscan["must 规则复检<br/>[mustscan.py]"]
  node_review["终审与引证<br/>[review.py]"]
end

subgraph group_memory["项目记忆"]
  node_worldbook["条目化世界书<br/>[wb.py]"]
  node_project["书稿项目文件<br/>[project.py]"]
  node_state["流水线状态<br/>[state.py]"]
  node_tracking["追踪与记忆<br/>[tracking_store.py]"]
  node_backflow["剧情反哺<br/>[memory.py]"]
end

subgraph group_models["模型服务"]
  node_router["模型槽位路由<br/>[router.py]"]
  node_client["LLM 客户端<br/>[client.py]"]
end

node_author(("作者"))
node_provider{{"兼容模型服务"}}

node_author -->|"操作"| node_desktop
node_desktop -->|"承载界面"| node_bridge
node_bridge -->|"启动与控制"| node_orchestrator
node_bridge -->|"共写交互"| node_cowriting
node_bridge -->|"导入文档"| node_importdoc
node_orchestrator -->|"执行阶段"| node_stages
node_orchestrator -->|"等待确认"| node_gates
node_orchestrator -->|"读写进度"| node_state
node_stages -->|"读取与落稿"| node_project
node_stages -->|"组装设定"| node_worldbook
node_stages -->|"读取预设"| node_preset
node_stages -->|"执行预检"| node_scan
node_stages -->|"复检规则"| node_mustscan
node_stages -->|"请求终审"| node_review
node_stages -->|"更新追踪"| node_tracking
node_stages -->|"请求模型"| node_router
node_review -->|"生成审校请求"| node_router
node_router -->|"取得客户端"| node_client
node_client -->|"发送请求"| node_provider
node_importdoc -->|"请求拆解"| node_client
node_importdoc -->|"确认后写入"| node_project
node_backflow -->|"回写新设定"| node_worldbook
node_backflow -->|"更新记忆"| node_tracking
node_orchestrator -.->|"触发反哺"| node_backflow

click node_desktop "https://github.com/glfzr/qianbi-novel/blob/main/app/main.py"
click node_bridge "https://github.com/glfzr/qianbi-novel/blob/main/app/ui/bridge.py"
click node_orchestrator "https://github.com/glfzr/qianbi-novel/blob/main/app/core/orchestrator.py"
click node_stages "https://github.com/glfzr/qianbi-novel/blob/main/app/core/stages.py"
click node_cowriting "https://github.com/glfzr/qianbi-novel/blob/main/app/core/co_writing.py"
click node_gates "https://github.com/glfzr/qianbi-novel/blob/main/app/core/gates.py"
click node_importdoc "https://github.com/glfzr/qianbi-novel/blob/main/app/importdoc.py"
click node_worldbook "https://github.com/glfzr/qianbi-novel/blob/main/app/wb.py"
click node_project "https://github.com/glfzr/qianbi-novel/blob/main/app/project.py"
click node_state "https://github.com/glfzr/qianbi-novel/blob/main/app/core/state.py"
click node_tracking "https://github.com/glfzr/qianbi-novel/blob/main/app/core/tracking_store.py"
click node_backflow "https://github.com/glfzr/qianbi-novel/blob/main/app/core/memory.py"
click node_preset "https://github.com/glfzr/qianbi-novel/blob/main/app/presets/__init__.py"
click node_scan "https://github.com/glfzr/qianbi-novel/blob/main/app/core/scan.py"
click node_mustscan "https://github.com/glfzr/qianbi-novel/blob/main/app/mustscan.py"
click node_review "https://github.com/glfzr/qianbi-novel/blob/main/app/prompts/review.py"
click node_router "https://github.com/glfzr/qianbi-novel/blob/main/app/llm/router.py"
click node_client "https://github.com/glfzr/qianbi-novel/blob/main/app/llm/client.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_desktop,node_bridge toneBlue
class node_orchestrator,node_stages,node_cowriting,node_gates,node_importdoc,node_preset toneAmber
class node_scan,node_mustscan,node_review toneMint
class node_worldbook,node_project,node_state,node_tracking,node_backflow toneRose
class node_router,node_client,node_author,node_provider toneIndigo
```

## Components

### 作者交互

- [桌面应用](https://github.com/glfzr/qianbi-novel/blob/main/app/main.py): `app/main.py`
- [界面桥接](https://github.com/glfzr/qianbi-novel/blob/main/app/ui/bridge.py): `app/ui/bridge.py`

### 创作流程

- [流程调度](https://github.com/glfzr/qianbi-novel/blob/main/app/core/orchestrator.py): `app/core/orchestrator.py`
- [阶段生成](https://github.com/glfzr/qianbi-novel/blob/main/app/core/stages.py): `app/core/stages.py`
- [共写阶段](https://github.com/glfzr/qianbi-novel/blob/main/app/core/co_writing.py): `app/core/co_writing.py`
- [作者决策门](https://github.com/glfzr/qianbi-novel/blob/main/app/core/gates.py): `app/core/gates.py`
- [文档导入](https://github.com/glfzr/qianbi-novel/blob/main/app/importdoc.py): `app/importdoc.py`
- [题材预设](https://github.com/glfzr/qianbi-novel/blob/main/app/presets/__init__.py): `app/presets/__init__.py`

### 一致性与审校

- [确定性预检](https://github.com/glfzr/qianbi-novel/blob/main/app/core/scan.py): `app/core/scan.py`
- [must 规则复检](https://github.com/glfzr/qianbi-novel/blob/main/app/mustscan.py): `app/mustscan.py`
- [终审与引证](https://github.com/glfzr/qianbi-novel/blob/main/app/prompts/review.py): `app/prompts/review.py`

### 项目记忆

- [条目化世界书](https://github.com/glfzr/qianbi-novel/blob/main/app/wb.py): `app/wb.py`
- [书稿项目文件](https://github.com/glfzr/qianbi-novel/blob/main/app/project.py): `app/project.py`
- [流水线状态](https://github.com/glfzr/qianbi-novel/blob/main/app/core/state.py): `app/core/state.py`
- [追踪与记忆](https://github.com/glfzr/qianbi-novel/blob/main/app/core/tracking_store.py): `app/core/tracking_store.py`
- [剧情反哺](https://github.com/glfzr/qianbi-novel/blob/main/app/core/memory.py): `app/core/memory.py`

### 模型服务

- [模型槽位路由](https://github.com/glfzr/qianbi-novel/blob/main/app/llm/router.py): `app/llm/router.py`
- [LLM 客户端](https://github.com/glfzr/qianbi-novel/blob/main/app/llm/client.py): `app/llm/client.py`

### Other components

- **作者**
- **兼容模型服务**

## Connections

- 作者 → 桌面应用: 操作
- 桌面应用 → 界面桥接: 承载界面
- 界面桥接 → 流程调度: 启动与控制
- 界面桥接 → 共写阶段: 共写交互
- 界面桥接 → 文档导入: 导入文档
- 流程调度 → 阶段生成: 执行阶段
- 流程调度 → 作者决策门: 等待确认
- 流程调度 → 流水线状态: 读写进度
- 阶段生成 → 书稿项目文件: 读取与落稿
- 阶段生成 → 条目化世界书: 组装设定
- 阶段生成 → 题材预设: 读取预设
- 阶段生成 → 确定性预检: 执行预检
- 阶段生成 → must 规则复检: 复检规则
- 阶段生成 → 终审与引证: 请求终审
- 阶段生成 → 追踪与记忆: 更新追踪
- 阶段生成 → 模型槽位路由: 请求模型
- 终审与引证 → 模型槽位路由: 生成审校请求
- 模型槽位路由 → LLM 客户端: 取得客户端
- LLM 客户端 → 兼容模型服务: 发送请求
- 文档导入 → LLM 客户端: 请求拆解
- 文档导入 → 书稿项目文件: 确认后写入
- 剧情反哺 → 条目化世界书: 回写新设定
- 剧情反哺 → 追踪与记忆: 更新记忆
- 流程调度 → 剧情反哺: 触发反哺
