# hkuds/deeptutor architecture

> Architecture diagram of the GitHub repository hkuds/deeptutor, 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/hkuds/deeptutor
- Repository: https://github.com/hkuds/deeptutor
- Video tour (about a minute): https://gitdiagram.com/hkuds/deeptutor/video

## Overview

DeepTutor is a lifelong personalized tutoring product, exposed through a web client and desktop app. The main workflow is a learner request entering the application, being handled by the shared turn runtime and tutoring capabilities, then producing a streamed response or a learning artifact. The README also highlights reading, mastery, video lessons, and modular capabilities. The map preserves those product branches; several are documented or present in the tree but not sampled, so their links are marked unverified rather than asserted as observed calls.

Main entry points: [`deeptutor/runtime/orchestrator.py`](https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/orchestrator.py) (Chat orchestrator), [`deeptutor/api/main.py`](https://github.com/hkuds/deeptutor/blob/main/deeptutor/api/main.py) (HTTP API), [`deeptutor/agents/question/pipeline.py`](https://github.com/hkuds/deeptutor/blob/main/deeptutor/agents/question/pipeline.py) (Question pipeline), [`deeptutor/app/service.py`](https://github.com/hkuds/deeptutor/blob/main/deeptutor/app/service.py) (App service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_web["Web client"]
  node_desktop["Desktop shell<br/>[main.mjs]"]
end

subgraph group_application["Application runtime"]
  node_api["HTTP API<br/>[main.py]"]
  node_app_service["App service<br/>[service.py]"]
  node_turn_engine["Turn engine<br/>[turn_engine.py]"]
  node_orchestrator["Chat orchestrator<br/>[orchestrator.py]"]
  node_tool_dispatch["Tool dispatch<br/>[tool_dispatch.py]"]
  node_stream_bus["Stream bus<br/>[stream_bus.py]"]
end

subgraph group_tutoring["Tutoring capabilities"]
  node_question_pipeline["Question pipeline<br/>[pipeline.py]"]
  node_tool_composition["Tool composition"]
  node_agent_loop["Chat and agent loops"]
  node_research["Research tools"]
  node_visual_learning["Visual and video lessons"]
end

subgraph group_learning["Learning and content"]
  node_reading["Reading experience"]
  node_knowledge[("Knowledge bases<br/>[manager.py]")]
  node_learning_service["Mastery learning<br/>[service.py]"]
  node_learning_store[("Learning records<br/>[storage.py]")]
  node_book["Interactive books<br/>[engine.py]"]
  node_notes["Notes and blocks<br/>[blocks.py]"]
end

subgraph group_platform["Identity and integrations"]
  node_auth["Authentication<br/>[auth.py]"]
  node_config["Model configuration<br/>[loader.py]"]
  node_workspace_paths["Workspace paths<br/>[path_service.py]"]
  node_file_io["File access<br/>[file_io.py]"]
  node_session_handoff["Session handoff<br/>[session_handoff.py]"]
  node_partners["Partner channels<br/>[manager.py]"]
end

node_learner(("Learner"))

node_learner -.->|"uses"| node_web
node_learner -.->|"uses"| node_desktop
node_web -.->|"requests"| node_api
node_desktop -.->|"hosts"| node_web
node_api -.->|"delegates to"| node_app_service
node_app_service -.->|"executes turns"| node_turn_engine
node_turn_engine -->|"invokes"| node_orchestrator
node_turn_engine -.->|"yields events"| node_stream_bus
node_orchestrator -.->|"dispatches tools"| node_tool_dispatch
node_orchestrator -.->|"publishes events"| node_stream_bus
node_question_pipeline -->|"uses"| node_tool_dispatch
node_question_pipeline -->|"streams through"| node_stream_bus
node_question_pipeline -->|"uses"| node_tool_composition
node_agent_loop -.->|"uses"| node_tool_composition
node_orchestrator -.->|"routes turns"| node_agent_loop
node_orchestrator -.->|"routes questions"| node_question_pipeline
node_orchestrator -.->|"routes research"| node_research
node_orchestrator -.->|"routes creation"| node_visual_learning
node_orchestrator -.->|"routes reading"| node_reading
node_orchestrator -.->|"uses retrieval"| node_knowledge
node_orchestrator -.->|"uses mastery"| node_learning_service
node_learning_service -.->|"persists records"| node_learning_store
node_learning_store -->|"resolves location"| node_workspace_paths
node_learning_store -->|"uses"| node_file_io
node_book -.->|"creates content"| node_notes
node_api -.->|"authenticates"| node_auth
node_api -.->|"coordinates sessions"| node_session_handoff
node_api -.->|"exposes integrations"| node_partners
node_app_service -.->|"loads settings"| node_config

click node_web "https://github.com/hkuds/deeptutor/tree/main/web"
click node_desktop "https://github.com/hkuds/deeptutor/blob/main/apps/desktop/src/main.mjs"
click node_api "https://github.com/hkuds/deeptutor/blob/main/deeptutor/api/main.py"
click node_app_service "https://github.com/hkuds/deeptutor/blob/main/deeptutor/app/service.py"
click node_turn_engine "https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/turn_engine.py"
click node_orchestrator "https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/orchestrator.py"
click node_tool_dispatch "https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/agentic/tool_dispatch.py"
click node_stream_bus "https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/stream_bus.py"
click node_question_pipeline "https://github.com/hkuds/deeptutor/blob/main/deeptutor/agents/question/pipeline.py"
click node_tool_composition "https://github.com/hkuds/deeptutor/blob/main/deeptutor/agents/_shared/tool_composition.py"
click node_agent_loop "https://github.com/hkuds/deeptutor/tree/main/deeptutor/agents/loop"
click node_research "https://github.com/hkuds/deeptutor/tree/main/deeptutor/agents/research"
click node_visual_learning "https://github.com/hkuds/deeptutor/tree/main/deeptutor/agents/video_lesson"
click node_reading "https://github.com/hkuds/deeptutor/tree/main/deeptutor/reading"
click node_knowledge "https://github.com/hkuds/deeptutor/blob/main/deeptutor/knowledge/manager.py"
click node_learning_service "https://github.com/hkuds/deeptutor/blob/main/deeptutor/learning/service.py"
click node_learning_store "https://github.com/hkuds/deeptutor/blob/main/deeptutor/learning/storage.py"
click node_book "https://github.com/hkuds/deeptutor/blob/main/deeptutor/book/engine.py"
click node_notes "https://github.com/hkuds/deeptutor/blob/main/deeptutor/notes/blocks.py"
click node_auth "https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/auth.py"
click node_config "https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/config/loader.py"
click node_workspace_paths "https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/path_service.py"
click node_file_io "https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/file_io.py"
click node_session_handoff "https://github.com/hkuds/deeptutor/blob/main/deeptutor/multi_user/session_handoff.py"
click node_partners "https://github.com/hkuds/deeptutor/blob/main/deeptutor/partners/channels/manager.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_web,node_desktop toneBlue
class node_api,node_app_service,node_turn_engine,node_orchestrator,node_tool_dispatch,node_stream_bus toneAmber
class node_question_pipeline,node_tool_composition,node_agent_loop,node_research,node_visual_learning toneMint
class node_reading,node_knowledge,node_learning_service,node_learning_store,node_book,node_notes toneRose
class node_auth,node_config,node_workspace_paths,node_file_io,node_session_handoff,node_partners,node_learner toneIndigo
```

## Components

### User interfaces

- [Web client](https://github.com/hkuds/deeptutor/tree/main/web): `web`
- [Desktop shell](https://github.com/hkuds/deeptutor/blob/main/apps/desktop/src/main.mjs): `apps/desktop/src/main.mjs`

### Application runtime

- [HTTP API](https://github.com/hkuds/deeptutor/blob/main/deeptutor/api/main.py): `deeptutor/api/main.py`
- [App service](https://github.com/hkuds/deeptutor/blob/main/deeptutor/app/service.py): `deeptutor/app/service.py`
- [Turn engine](https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/turn_engine.py): `deeptutor/runtime/turn_engine.py`
- [Chat orchestrator](https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/orchestrator.py): `deeptutor/runtime/orchestrator.py`
- [Tool dispatch](https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/agentic/tool_dispatch.py): `deeptutor/runtime/agentic/tool_dispatch.py`
- [Stream bus](https://github.com/hkuds/deeptutor/blob/main/deeptutor/runtime/stream_bus.py): `deeptutor/runtime/stream_bus.py`

### Tutoring capabilities

- [Question pipeline](https://github.com/hkuds/deeptutor/blob/main/deeptutor/agents/question/pipeline.py): `deeptutor/agents/question/pipeline.py`
- [Tool composition](https://github.com/hkuds/deeptutor/blob/main/deeptutor/agents/_shared/tool_composition.py): `deeptutor/agents/_shared/tool_composition.py`
- [Chat and agent loops](https://github.com/hkuds/deeptutor/tree/main/deeptutor/agents/loop): `deeptutor/agents/loop`
- [Research tools](https://github.com/hkuds/deeptutor/tree/main/deeptutor/agents/research): `deeptutor/agents/research`
- [Visual and video lessons](https://github.com/hkuds/deeptutor/tree/main/deeptutor/agents/video_lesson): `deeptutor/agents/video_lesson`

### Learning and content

- [Reading experience](https://github.com/hkuds/deeptutor/tree/main/deeptutor/reading): `deeptutor/reading`
- [Knowledge bases](https://github.com/hkuds/deeptutor/blob/main/deeptutor/knowledge/manager.py): `deeptutor/knowledge/manager.py`
- [Mastery learning](https://github.com/hkuds/deeptutor/blob/main/deeptutor/learning/service.py): `deeptutor/learning/service.py`
- [Learning records](https://github.com/hkuds/deeptutor/blob/main/deeptutor/learning/storage.py): `deeptutor/learning/storage.py`
- [Interactive books](https://github.com/hkuds/deeptutor/blob/main/deeptutor/book/engine.py): `deeptutor/book/engine.py`
- [Notes and blocks](https://github.com/hkuds/deeptutor/blob/main/deeptutor/notes/blocks.py): `deeptutor/notes/blocks.py`

### Identity and integrations

- [Authentication](https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/auth.py): `deeptutor/services/auth.py`
- [Model configuration](https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/config/loader.py): `deeptutor/services/config/loader.py`
- [Workspace paths](https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/path_service.py): `deeptutor/services/path_service.py`
- [File access](https://github.com/hkuds/deeptutor/blob/main/deeptutor/services/file_io.py): `deeptutor/services/file_io.py`
- [Session handoff](https://github.com/hkuds/deeptutor/blob/main/deeptutor/multi_user/session_handoff.py): `deeptutor/multi_user/session_handoff.py`
- [Partner channels](https://github.com/hkuds/deeptutor/blob/main/deeptutor/partners/channels/manager.py): `deeptutor/partners/channels/manager.py`

### Other components

- **Learner**

## Connections

- Learner → Web client: uses
- Learner → Desktop shell: uses
- Web client → HTTP API: requests
- Desktop shell → Web client: hosts
- HTTP API → App service: delegates to
- App service → Turn engine: executes turns
- Turn engine → Chat orchestrator: invokes (evidence: `deeptutor/runtime/turn_engine.py`)
- Turn engine → Stream bus: yields events
- Chat orchestrator → Tool dispatch: dispatches tools
- Chat orchestrator → Stream bus: publishes events
- Question pipeline → Tool dispatch: uses (evidence: `deeptutor/agents/question/pipeline.py`)
- Question pipeline → Stream bus: streams through (evidence: `deeptutor/agents/question/pipeline.py`)
- Question pipeline → Tool composition: uses (evidence: `deeptutor/agents/question/pipeline.py`)
- Chat and agent loops → Tool composition: uses
- Chat orchestrator → Chat and agent loops: routes turns
- Chat orchestrator → Question pipeline: routes questions
- Chat orchestrator → Research tools: routes research
- Chat orchestrator → Visual and video lessons: routes creation
- Chat orchestrator → Reading experience: routes reading
- Chat orchestrator → Knowledge bases: uses retrieval
- Chat orchestrator → Mastery learning: uses mastery
- Mastery learning → Learning records: persists records
- Learning records → Workspace paths: resolves location (evidence: `deeptutor/learning/storage.py`)
- Learning records → File access: uses (evidence: `deeptutor/learning/storage.py`)
- Interactive books → Notes and blocks: creates content
- HTTP API → Authentication: authenticates
- HTTP API → Session handoff: coordinates sessions
- HTTP API → Partner channels: exposes integrations
- App service → Model configuration: loads settings
