# uittorio/mentor-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/uittorio/mentor-plugin
- Repository: https://github.com/uittorio/mentor-plugin

## Overview

1. **Repository shape**
   This is a multi-crate Rust workspace centered on a “mentor mode” learning system. The core architecture is split into:
   - agent-side skills and plugin packaging,
   - an MCP server that exposes learning operations,
   - a reusable learning library,
   - a dashboard for viewing progress,
   - and migrations/install scripts around those pieces.

2. **Agent integration layer**
   The `claude-plugin` and `opencode-plugin` directories package the same mentoring experience for two coding agents: Claude Code and OpenCode. The `mentor+` skill changes the agent’s behavior to Socratic guidance, while `mentor+-summarise` post-processes a session at the end. These are not the knowledge system itself; they are the front-end interaction layer that drives the system through tools and files.

3. **MCP server as the orchestration boundary**
   `knowledge/mcp` is the runtime service the agent talks to. Its job is to translate high-level mentoring actions into storage and review operations. The exposed tools are:
   - `create_session`
   - `get_topics`
   - `get_topic_candidates`
   - `topic_depth`
   - `review_topic`
   
   This is the main integration point between the agent and the learning backend.

4. **Learning domain core**
   `knowledge/learning` is the shared domain library. It contains the primary concepts:
   - `topic`
   - `session`
   - `session_storage` / `topic_storage`
   - `sm2` spaced repetition logic
   - `trigram_similarity` for fuzzy topic matching
   - `storage_error`
   
   This crate is where the learning rules live, independent of any UI or transport.

5. **Persistence model**
   The repository uses two kinds of storage concerns:
   - **structured learning data** in SQLite, via `knowledge/learning/src/sqlite`
   - **session draft files** in markdown, via `knowledge/learning/src/file_storage`
   
   The SQLite side stores topics, sessions, and review state; the file side stores the human-readable session narrative that the summariser later edits.

6. **Data flow at session start**
   A typical session starts with the agent asking the MCP server for topic context. The backend can:
   - find known topics with fuzzy matching,
   - compute which topics are due for review,
   - and determine how deep the agent should go on each topic via `topic_depth`.
   
   This is the “what should I ask about now?” decision path.

7. **Data flow during the session**
   As the conversation progresses, the agent records outcomes back through `review_topic`. That updates the spaced-repetition state, including intervals and future review timing. This is the feedback loop that makes the mentor remember what the user knows and struggles with across sessions.

8. **Session draft and summarisation flow**
   Each session has a running markdown draft file. The `mentor+-summarise` skill reads that draft near the end of a session, enriches it with conversation context, git history, and referenced files, then prepends a structured summary. This is a file-based workflow, separate from the SQLite knowledge store.

9. **Dashboard subsystem**
   `knowledge/dashboard` is a separate Rust binary for visualising historical topics and sessions. It is the reporting/read-only side of the system, likely reading from the same persisted knowledge data to show progress over time. Architecturally, it is downstream of the learning storage layer, not part of the agent interaction loop.

10. **Schema and lifecycle support**
   `knowledge/migrations` owns database schema evolution for the SQLite-backed store. The top-level scripts and install tests support packaging and deployment:
   - `scripts/install-dashboard.sh`
   - `scripts/mcp-server.sh`
   - `scripts/release.sh`
   - `tests_installs/*`
   
   These are operational glue, but they matter because the system is split across agent plugins, a background MCP service, and a local persistence store.

11. **Key architectural boundary**
   The most important boundary in this repo is between:
   - **behavioral guidance** in the agent skill,
   - **stateful knowledge tracking** in the MCP + learning crates,
   - and **presentation/reporting** in the dashboard and summariser.
   
   That separation is what lets the mentoring behavior stay portable across agents while the learning state remains centralized and persistent.

Main entry points: [`knowledge/learning/src/lib.rs`](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/lib.rs) (Learning lib), [`knowledge/mcp/src/main.rs`](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/main.rs) (MCP server), [`knowledge/learning/src/session_storage.rs`](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/session_storage.rs) (Storage API), [`knowledge/learning/src/sqlite/mod.rs`](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/sqlite/mod.rs) (SQLite store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent_plugins["Agent plugins"]
  node_claude_plugin["Claude plugin<br/>plugin package"]
  node_opencode_plugin["OpenCode plugin<br/>plugin package"]
  node_mentor_skill["Mentor skill<br/>agent skill<br/>[SKILL.md]"]
  node_summarise_skill["Summarise skill<br/>postprocess skill<br/>[SKILL.md]"]
end

subgraph group_learning_backend["Learning backend"]
  node_mcp_server["MCP server<br/>runtime service<br/>[main.rs]"]
  node_tool_service["Tool service<br/>tool router<br/>[tool_service.rs]"]
  node_session_tool["Session tools<br/>mcp tools<br/>[create_session.rs]"]
  node_topic_tools["Topic tools<br/>mcp tools<br/>[get_topics.rs]"]
  node_learning_lib["Learning lib<br/>domain library<br/>[lib.rs]"]
  node_topic_model["Topic model<br/>domain model<br/>[topic.rs]"]
  node_session_model["Session model<br/>domain model<br/>[session.rs]"]
  node_storage_api["Storage API<br/>abstraction<br/>[session_storage.rs]"]
  node_spaced_repetition["SM2 logic<br/>ranking logic<br/>[sm2.rs]"]
  node_topic_match["Topic matching<br/>similarity logic"]
  node_sqlite_store[("SQLite store<br/>persistence<br/>[mod.rs]")]
  node_file_store["File storage<br/>draft storage<br/>[mod.rs]"]
  node_dashboard_app["Dashboard<br/>reporting app<br/>[main.rs]"]
end

subgraph group_ops["Ops & packaging"]
  node_migration_tool["Migrations<br/>schema tool<br/>[main.rs]"]
  node_install_scripts["Install scripts<br/>shell ops"]
  node_release_flow["Release flow<br/>shell ops<br/>[release.sh]"]
  node_install_tests["Install tests<br/>validation scripts"]
end

node_claude_plugin -->|"packages"| node_mentor_skill
node_claude_plugin -->|"packages"| node_summarise_skill
node_opencode_plugin -->|"mirrors"| node_mentor_skill
node_opencode_plugin -->|"mirrors"| node_summarise_skill
node_mentor_skill -->|"uses tools"| node_mcp_server
node_summarise_skill -->|"edits draft"| node_file_store
node_mcp_server -->|"routes"| node_tool_service
node_tool_service -->|"executes"| node_session_tool
node_tool_service -->|"executes"| node_topic_tools
node_mcp_server -->|"depends on"| node_learning_lib
node_session_tool -->|"updates"| node_storage_api
node_topic_tools -->|"matches"| node_topic_match
node_topic_tools -->|"scores"| node_spaced_repetition
node_learning_lib -->|"defines"| node_topic_model
node_learning_lib -->|"defines"| node_session_model
node_learning_lib -->|"abstracts"| node_storage_api
node_storage_api -->|"backed by"| node_sqlite_store
node_storage_api -->|"backed by"| node_file_store
node_sqlite_store -->|"evolves with"| node_migration_tool
node_dashboard_app -->|"reads"| node_sqlite_store
node_migration_tool -->|"migrates"| node_sqlite_store
node_install_scripts -->|"installs"| node_dashboard_app
node_release_flow -->|"launches"| node_mcp_server
node_install_tests -->|"verifies"| node_dashboard_app

click node_claude_plugin "https://github.com/uittorio/mentor-plugin/tree/main/claude-plugin"
click node_opencode_plugin "https://github.com/uittorio/mentor-plugin/tree/main/opencode-plugin"
click node_mentor_skill "https://github.com/uittorio/mentor-plugin/blob/main/claude-plugin/skills/mentor+/SKILL.md"
click node_summarise_skill "https://github.com/uittorio/mentor-plugin/blob/main/claude-plugin/skills/mentor+-summarise/SKILL.md"
click node_mcp_server "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/main.rs"
click node_tool_service "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/tool_service.rs"
click node_session_tool "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/create_session.rs"
click node_topic_tools "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/get_topics.rs"
click node_learning_lib "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/lib.rs"
click node_topic_model "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/topic.rs"
click node_session_model "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/session.rs"
click node_storage_api "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/session_storage.rs"
click node_spaced_repetition "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/sm2.rs"
click node_topic_match "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/trigram_similarity.rs"
click node_sqlite_store "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/sqlite/mod.rs"
click node_file_store "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/file_storage/mod.rs"
click node_dashboard_app "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/dashboard/src/main.rs"
click node_migration_tool "https://github.com/uittorio/mentor-plugin/blob/main/knowledge/migrations/src/main.rs"
click node_install_scripts "https://github.com/uittorio/mentor-plugin/blob/main/scripts/install-dashboard.sh"
click node_release_flow "https://github.com/uittorio/mentor-plugin/blob/main/scripts/release.sh"
click node_install_tests "https://github.com/uittorio/mentor-plugin/blob/main/tests_installs/dashboard_install_tests.sh"

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_claude_plugin,node_opencode_plugin,node_mentor_skill,node_summarise_skill toneBlue
class node_mcp_server,node_tool_service,node_session_tool,node_topic_tools,node_learning_lib,node_topic_model,node_session_model,node_storage_api,node_spaced_repetition,node_topic_match,node_sqlite_store,node_file_store,node_dashboard_app toneAmber
class node_migration_tool,node_install_scripts,node_release_flow,node_install_tests toneMint
```

## Components

### Agent plugins

Packaged mentoring behavior for Claude Code and OpenCode.

- [Claude plugin](https://github.com/uittorio/mentor-plugin/tree/main/claude-plugin): plugin package · Claude Code packaging for mentor mode. · `claude-plugin`
- [OpenCode plugin](https://github.com/uittorio/mentor-plugin/tree/main/opencode-plugin): plugin package · OpenCode packaging for mentor mode. · `opencode-plugin`
- [Mentor skill](https://github.com/uittorio/mentor-plugin/blob/main/claude-plugin/skills/mentor+/SKILL.md): agent skill · Socratic guidance behavior for the agent. · `claude-plugin/skills/mentor+/SKILL.md`
- [Summarise skill](https://github.com/uittorio/mentor-plugin/blob/main/claude-plugin/skills/mentor+-summarise/SKILL.md): postprocess skill · End-of-session draft enrichment and summary. · `claude-plugin/skills/mentor+-summarise/SKILL.md`

### Learning backend

Central stateful knowledge system and its services.

- [MCP server](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/main.rs): runtime service · Agent-facing orchestration boundary. · `knowledge/mcp/src/main.rs`
- [Tool service](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/tool_service.rs): tool router · Dispatches learning operations to tool handlers. · `knowledge/mcp/src/tool_service.rs`
- [Session tools](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/create_session.rs): mcp tools · Session creation and topic review operations. · `knowledge/mcp/src/create_session.rs`
- [Topic tools](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/mcp/src/get_topics.rs): mcp tools · Topic lookup, depth, and candidate selection. · `knowledge/mcp/src/get_topics.rs`
- [Learning lib](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/lib.rs): domain library · Shared learning rules and persistence abstractions. · `knowledge/learning/src/lib.rs`
- [Topic model](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/topic.rs): domain model · Topics and session concepts. · `knowledge/learning/src/topic.rs`
- [Session model](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/session.rs): domain model · Session state and lifecycle data. · `knowledge/learning/src/session.rs`
- [Storage API](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/session_storage.rs): abstraction · Session/topic storage traits and errors. · `knowledge/learning/src/session_storage.rs`
- [SM2 logic](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/sm2.rs): ranking logic · Review intervals and future scheduling. · `knowledge/learning/src/sm2.rs`
- [Topic matching](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/trigram_similarity.rs): similarity logic · Fuzzy matching for candidate topics. · `knowledge/learning/src/trigram_similarity.rs`
- [SQLite store](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/sqlite/mod.rs): persistence · Structured learning data persistence. · `knowledge/learning/src/sqlite/mod.rs`
- [File storage](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/learning/src/file_storage/mod.rs): draft storage · Markdown session draft persistence. · `knowledge/learning/src/file_storage/mod.rs`
- [Dashboard](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/dashboard/src/main.rs): reporting app · Read-only progress and history UI. · `knowledge/dashboard/src/main.rs`

### Ops & packaging

Install, release, and schema lifecycle support.

- [Migrations](https://github.com/uittorio/mentor-plugin/blob/main/knowledge/migrations/src/main.rs): schema tool · Database schema evolution entrypoint. · `knowledge/migrations/src/main.rs`
- [Install scripts](https://github.com/uittorio/mentor-plugin/blob/main/scripts/install-dashboard.sh): shell ops · Packaging and local installation scripts. · `scripts/install-dashboard.sh`
- [Release flow](https://github.com/uittorio/mentor-plugin/blob/main/scripts/release.sh): shell ops · Release and server launcher scripts. · `scripts/release.sh`
- [Install tests](https://github.com/uittorio/mentor-plugin/blob/main/tests_installs/dashboard_install_tests.sh): validation scripts · Smoke tests for dashboard and OpenCode installs. · `tests_installs/dashboard_install_tests.sh`

## Connections

- Claude plugin → Mentor skill: packages · Ships the mentor behavior as a Claude plugin.
- Claude plugin → Summarise skill: packages · Ships the session summariser skill.
- OpenCode plugin → Mentor skill: mirrors · Provides the same guidance behavior for OpenCode.
- OpenCode plugin → Summarise skill: mirrors · Provides the same summarisation flow for OpenCode.
- Mentor skill → MCP server: uses tools · Agent guidance is driven through MCP operations.
- Summarise skill → File storage: edits draft · Reads and prepends the session markdown draft.
- MCP server → Tool service: routes · Entrypoint delegates to tool dispatch.
- Tool service → Session tools: executes · Handles session creation and review operations.
- Tool service → Topic tools: executes · Handles topic lookup and depth operations.
- MCP server → Learning lib: depends on · Uses shared learning domain logic.
- Session tools → Storage API: updates · Writes review outcomes through storage abstractions.
- Topic tools → Topic matching: matches · Finds topic candidates with fuzzy similarity.
- Topic tools → SM2 logic: scores · Determines review depth and due status.
- Learning lib → Topic model: defines · Core topic concepts.
- Learning lib → Session model: defines · Core session concepts.
- Learning lib → Storage API: abstracts · Storage traits and error boundaries.
- Storage API → SQLite store: backed by · SQLite implementation for durable learning state.
- Storage API → File storage: backed by · Markdown-backed session draft storage.
- SQLite store → Migrations: evolves with · Schema changes are managed through migrations.
- Dashboard → SQLite store: reads · Dashboard reports over persisted learning data.
- Migrations → SQLite store: migrates · Creates and updates the SQLite schema.
- Install scripts → Dashboard: installs · Operational script for dashboard deployment.
- Release flow → MCP server: launches · Operational script for running the MCP server.
- Install tests → Dashboard: verifies · Checks dashboard installation behavior.
