# hlh-syd/moji-paper-agent architecture

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

- Interactive diagram: https://gitdiagram.com/hlh-syd/moji-paper-agent
- Repository: https://github.com/hlh-syd/moji-paper-agent

## Overview

墨记 is a Chinese research-paper writing agent. Its main workflow starts with registering and profiling a research workspace, optionally building a project understanding, then generating an outline, writing sections with retrieved evidence, reviewing the completed paper, and exporting a DOCX. Separate capabilities include multi-user isolation, chat, multimodal reference-paper retrieval, knowledge-base construction, and observability. The README documents the product workflow and capabilities; source excerpts and the index support selected internal relationships, while many web/API implementation details were not sampled.

Main entry points: [`src/web_api.py`](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/web_api.py) (Web API), [`src/outline_generator.py`](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/outline_generator.py) (Outline Generator), [`src/section_writer.py`](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/section_writer.py) (Section Writer), [`src/rag_anything_engine.py`](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/rag_anything_engine.py) (Multimodal RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product_flow["Research and Writing"]
  node_project_profile["Project Profiler<br/>[project_indexer.py]"]
  node_project_understanding["Project Understanding<br/>[project_analyst.py]"]
  node_domain_adaptation["Domain Adaptation<br/>[domain.py]"]
  node_outline["Outline Generator"]
  node_section_writer["Section Writer<br/>[section_writer.py]"]
  node_chat["Conversation Manager"]
end

subgraph group_knowledge["Evidence and Knowledge"]
  node_reference_manager["Reference Manager"]
  node_reference_parser["Reference Parser"]
  node_multimodal_rag["Multimodal RAG"]
  node_vector_store[("Vector Store<br/>[vector_store.py]")]
  node_kb_builders["Knowledge Builders"]
  node_vision["Vision Agent<br/>[vision_agent.py]"]
end

subgraph group_platform["Application Platform"]
  node_workbench["Web Workbench<br/>[app.js]"]
  node_api["Web API<br/>[web_api.py]"]
  node_llm["LLM Manager<br/>[llm_manager.py]"]
  node_auth["RBAC Authentication<br/>[auth.py]"]
  node_workspace[("Workspace Storage<br/>[workspace_store.py]")]
end

subgraph group_quality["Quality and Operations"]
  node_paper_review["Paper Review<br/>[paper_checks.py]"]
  node_paper_actions["Paper Actions<br/>[paper_actions.py]"]
  node_observability["Observability<br/>[observability.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"uses"| node_workbench
node_workbench -->|"requests"| node_api
node_api -->|"registers projects"| node_project_profile
node_api -->|"starts understanding"| node_project_understanding
node_api -->|"generates outlines"| node_outline
node_api -->|"generates sections"| node_section_writer
node_api -->|"runs review"| node_paper_review
node_api -->|"exports papers"| node_paper_actions
node_project_profile -->|"detects domain"| node_domain_adaptation
node_project_understanding -->|"informs writing"| node_outline
node_domain_adaptation -->|"sets structure"| node_outline
node_outline -->|"guides sections"| node_section_writer
node_section_writer -->|"supplies draft"| node_paper_review
node_paper_review -->|"enables export"| node_paper_actions
node_api -->|"parses references"| node_reference_parser
node_api -->|"routes RAG"| node_multimodal_rag
node_section_writer -->|"retrieves evidence"| node_multimodal_rag
node_multimodal_rag -.->|"uses papers"| node_reference_manager
node_api -->|"serves chat"| node_chat
node_chat -->|"uses models"| node_llm
node_outline -->|"retrieves knowledge"| node_vector_store
node_kb_builders -->|"indexes documents"| node_vector_store
node_api -->|"enforces access"| node_auth
node_api -.->|"manages workspace"| node_workspace
node_api -->|"records traces"| node_observability
node_api -->|"invokes vision"| node_vision
node_multimodal_rag -.->|"uses model functions"| node_llm

click node_workbench "https://github.com/hlh-syd/moji-paper-agent/blob/main/static/js/app.js"
click node_api "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/web_api.py"
click node_project_profile "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/project_indexer.py"
click node_project_understanding "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/project_analyst.py"
click node_domain_adaptation "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/domain.py"
click node_outline "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/outline_generator.py"
click node_section_writer "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/section_writer.py"
click node_paper_review "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/paper_checks.py"
click node_paper_actions "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/paper_actions.py"
click node_reference_manager "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/reference_manager.py"
click node_reference_parser "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/reference_parser.py"
click node_multimodal_rag "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/rag_anything_engine.py"
click node_vector_store "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/vector_store.py"
click node_kb_builders "https://github.com/hlh-syd/moji-paper-agent/tree/main/ingestion"
click node_chat "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/conversation_manager.py"
click node_llm "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/llm_manager.py"
click node_auth "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/auth.py"
click node_workspace "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/workspace_store.py"
click node_observability "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/observability.py"
click node_vision "https://github.com/hlh-syd/moji-paper-agent/blob/main/src/vision_agent.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_project_profile,node_project_understanding,node_domain_adaptation,node_outline,node_section_writer,node_chat toneBlue
class node_reference_manager,node_reference_parser,node_multimodal_rag,node_vector_store,node_kb_builders,node_vision toneAmber
class node_workbench,node_api,node_llm,node_auth,node_workspace toneMint
class node_paper_review,node_paper_actions,node_observability toneRose
class node_researcher toneIndigo
```

## Components

### Research and Writing

- [Project Profiler](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/project_indexer.py): `src/project_indexer.py`
- [Project Understanding](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/project_analyst.py): `src/project_analyst.py`
- [Domain Adaptation](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/domain.py): `src/domain.py`
- [Outline Generator](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/outline_generator.py): `src/outline_generator.py`
- [Section Writer](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/section_writer.py): `src/section_writer.py`
- [Conversation Manager](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/conversation_manager.py): `src/conversation_manager.py`

### Evidence and Knowledge

- [Reference Manager](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/reference_manager.py): `src/reference_manager.py`
- [Reference Parser](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/reference_parser.py): `src/reference_parser.py`
- [Multimodal RAG](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/rag_anything_engine.py): `src/rag_anything_engine.py`
- [Vector Store](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/vector_store.py): `src/vector_store.py`
- [Knowledge Builders](https://github.com/hlh-syd/moji-paper-agent/tree/main/ingestion): `ingestion`
- [Vision Agent](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/vision_agent.py): `src/vision_agent.py`

### Application Platform

- [Web Workbench](https://github.com/hlh-syd/moji-paper-agent/blob/main/static/js/app.js): `static/js/app.js`
- [Web API](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/web_api.py): `src/web_api.py`
- [LLM Manager](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/llm_manager.py): `src/llm_manager.py`
- [RBAC Authentication](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/auth.py): `src/auth.py`
- [Workspace Storage](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/workspace_store.py): `src/workspace_store.py`

### Quality and Operations

- [Paper Review](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/paper_checks.py): `src/paper_checks.py`
- [Paper Actions](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/paper_actions.py): `src/paper_actions.py`
- [Observability](https://github.com/hlh-syd/moji-paper-agent/blob/main/src/observability.py): `src/observability.py`

### Other components

- **Researcher**

## Connections

- Researcher → Web Workbench: uses (evidence: `README.md`)
- Web Workbench → Web API: requests (evidence: `README.md`)
- Web API → Project Profiler: registers projects (evidence: `README.md`)
- Web API → Project Understanding: starts understanding (evidence: `README.md`)
- Web API → Outline Generator: generates outlines (evidence: `README.md`)
- Web API → Section Writer: generates sections (evidence: `README.md`)
- Web API → Paper Review: runs review (evidence: `README.md`)
- Web API → Paper Actions: exports papers (evidence: `README.md`)
- Project Profiler → Domain Adaptation: detects domain (evidence: `README.md`)
- Project Understanding → Outline Generator: informs writing (evidence: `README.md`)
- Domain Adaptation → Outline Generator: sets structure (evidence: `README.md`)
- Outline Generator → Section Writer: guides sections (evidence: `README.md`)
- Section Writer → Paper Review: supplies draft (evidence: `README.md`)
- Paper Review → Paper Actions: enables export (evidence: `README.md`)
- Web API → Reference Parser: parses references (evidence: `src/web_api.py`)
- Web API → Multimodal RAG: routes RAG (evidence: `src/web_api.py`)
- Section Writer → Multimodal RAG: retrieves evidence (evidence: `src/section_writer.py`)
- Multimodal RAG → Reference Manager: uses papers
- Web API → Conversation Manager: serves chat (evidence: `src/web_api.py`)
- Conversation Manager → LLM Manager: uses models (evidence: `src/conversation_manager.py`)
- Outline Generator → Vector Store: retrieves knowledge (evidence: `src/outline_generator.py`)
- Knowledge Builders → Vector Store: indexes documents (evidence: `ingestion/build_writing_kb.py`)
- Web API → RBAC Authentication: enforces access (evidence: `README.md`)
- Web API → Workspace Storage: manages workspace (evidence: `src/web_api.py`)
- Web API → Observability: records traces (evidence: `README.md`)
- Web API → Vision Agent: invokes vision (evidence: `src/web_api.py`)
- Multimodal RAG → LLM Manager: uses model functions
