# priorityfill/deepseek-reasonix architecture

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

- Interactive diagram: https://gitdiagram.com/priorityfill/deepseek-reasonix
- Repository: https://github.com/priorityfill/deepseek-reasonix

## Overview

1. **Repository shape**
   - This is a monorepo for a Go-based AI coding agent called Reasonix.
   - The main product surfaces are a terminal CLI, a desktop app, supporting cloud services, a marketing/community site, and release/packaging tooling.
   - The codebase is centered on a single Go module at the root, with a separate TypeScript frontend for the desktop shell and separate worker apps for hosted services.

2. **Core runtime: the agent engine**
   - The architectural center lives under `internal/agent`, `internal/control`, `internal/provider`, `internal/tool`, `internal/plugin`, `internal/memory`, `internal/history`, `internal/session`, and `internal/checkpoint`.
   - This layer is responsible for orchestrating turns, model calls, tool execution, memory retrieval/compaction, transcript/history management, checkpointing, and recovery.
   - It is intentionally model-agnostic: provider selection and tool availability come from configuration rather than hardcoded assumptions.

3. **Primary execution paths**
   - `cmd/reasonix` is the main terminal entrypoint.
   - `desktop/main.go` starts the Wails-based desktop application.
   - `internal/cli` implements the terminal UX and command surfaces around the shared engine.
   - All of these frontends converge on the same core control/agent packages, so the architecture is “multiple shells, one orchestration core.”

4. **Desktop application boundary**
   - The desktop app is a Go backend plus a React/Vite frontend in `desktop/frontend`.
   - The Go side handles session lifecycle, workspace access, updater, tray, notifications, crash/heartbeat logic, and OS-specific behavior.
   - The frontend renders the conversation/workspace UI and talks to Go through the Wails bridge; state is split between local frontend stores and backend-managed session data.

5. **Session, workspace, and persistence model**
   - Reasonix is session-centric: conversations, tool outputs, approvals, and recovery state are stored and restored as local session artifacts.
   - `internal/store`, `internal/session`, `internal/history`, `internal/control`, and many `desktop/*session*` files show that persistence is local-first and optimized for resume/rewind/recovery.
   - Workspace concepts are first-class: the agent operates against a project directory, reads repo files, and maintains project-scoped context such as `AGENTS.md`, memory files, and task artifacts.

6. **Model/provider and cache-aware context flow**
   - `internal/provider` contains adapters for OpenAI-compatible backends, including DeepSeek presets called out in the README.
   - Configuration loading and provider/model resolution live in `internal/config` and are driven by `reasonix.toml`, user config, and environment variables.
   - The system is designed around long-running sessions and prefix-cache stability: startup context is kept small and stable, while stale tool output and summary compaction are managed deliberately.

7. **Tools, plugins, and sandboxing**
   - Built-in tools live under `internal/tool/builtin` and are registered into a shared tool contract.
   - External plugins are handled separately under `internal/plugin`, typically as subprocesses over stdio JSON-RPC / MCP-compatible transport; HTTP transport is also present for some plugin cases.
   - Tool execution is constrained by permissions and sandbox layers in `internal/permission`, `internal/sandbox`, `internal/shellsafe`, `internal/proc`, and related helpers, so file/process/network operations are not free-form.

8. **Memory, retrieval, and evidence**
   - Long-term or user-authored memory is managed under `internal/memory`, with compiler/summary logic in `internal/memorycompiler`.
   - Evidence and readiness checks are explicit subsystems (`internal/evidence`, `internal/retrieval`, `internal/guardian`) rather than being implicit prompt text.
   - This creates a pipeline where the agent can recall relevant project knowledge, then compress or prune it to stay within context limits.

9. **Automation and integrations**
   - The repo includes bot support under `internal/bot` and `internal/botruntime`, with adapters for Feishu/Lark, QQ, and Weixin.
   - There is also an `internal/serve` package for hosted session interaction and login/auth flows.
   - These integrations suggest Reasonix can be controlled from external chat surfaces and web endpoints, not only from the terminal or desktop UI.

10. **Cloud/backend services**
   - `workers/accounts` is an authentication and account-management service with user, session, email-token, and device-grant storage.
   - `workers/crash-report` handles crash telemetry and related registry/admin functionality; it also contains a registry sub-app for package/activity tracking.
   - `workers/forum` provides a lightweight community service with identity and antispam logic.
   - These services are separate deployment units from the Go client/runtime and represent the hosted backend edge of the ecosystem.

11. **Website, documentation, and release surface**
   - `site` is the public marketing/community/docs web app built with Astro.
   - `docs` contains the product architecture/specification, configuration, tool contract, checkpoint/rewind docs, and bot guide.
   - Release and distribution are automated via GitHub Actions, GoReleaser, npm packaging, and Windows code signing; the product is distributed as a native binary even though parts of the ecosystem are TypeScript-based.

12. **How data flows end-to-end**
   - A user request enters through CLI, desktop, or bot.
   - The control layer loads config, resolves the model/provider, assembles context from session/history/memory/workspace state, and invokes the agent loop.
   - The agent may call built-in tools or external plugins, collect evidence, update checkpoints/history, and persist the resulting session state locally.
   - Optional hosted services handle accounts, crash reporting, community, and release distribution, but the core runtime remains local-first and self-contained.

Main entry points: [`internal/agent`](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/agent) (Agent core), [`internal/control`](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/control) (Control), [`desktop/main.go`](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/desktop/main.go) (Desktop app), [`internal/store/session.go`](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/store/session.go) (Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client apps"]
  node_cmd_reasonix["CLI<br/>terminal entrypoint<br/>[main.go]"]
  node_internal_cli["Shell UX<br/>terminal UI"]
  node_desktop_main["Desktop app<br/>wails backend<br/>[main.go]"]
  node_desktop_frontend["Desktop UI<br/>react/vite frontend"]
end

subgraph group_core["Core runtime"]
  node_internal_control["Control<br/>orchestration layer"]
  node_internal_agent["Agent core<br/>turn engine"]
  node_internal_provider["Providers<br/>model adapters"]
  node_internal_tool["Tools<br/>tool contract"]
  node_internal_plugin["Plugins<br/>external tools"]
  node_internal_memory[("Memory<br/>retrieval store")]
  node_internal_memorycompiler["Memory compactor<br/>summary pipeline"]
  node_internal_history["History<br/>transcript store"]
  node_internal_checkpoint[("Checkpoints<br/>recovery snapshots<br/>[checkpoint.go]")]
  node_internal_config["Config<br/>settings loader<br/>[config.go]"]
  node_internal_store[("Store<br/>local persistence<br/>[session.go]")]
  node_internal_agent_session["Session core<br/>session lifecycle<br/>[session.go]"]
  node_internal_bot["Bots<br/>chat integrations"]
  node_internal_serve["Hosted runtime<br/>session service<br/>[serve.go]"]
end

subgraph group_cloud["Hosted services"]
  node_workers_accounts["Accounts<br/>auth service"]
  node_workers_crash["Crash report<br/>telemetry service"]
  node_workers_forum["Forum<br/>community service"]
end

subgraph group_ops["Docs and release"]
  node_site["Website<br/>astro site"]
  node_docs["Docs"]
  node_release["Release<br/>packaging automation<br/>[workflows]"]
end

node_cmd_reasonix -->|"uses"| node_internal_cli
node_internal_cli -->|"orchestrates"| node_internal_control
node_desktop_main -->|"hosts"| node_desktop_frontend
node_desktop_main -->|"uses"| node_internal_control
node_desktop_frontend -->|"bridges"| node_internal_control
node_internal_control -->|"loads"| node_internal_config
node_internal_control -->|"drives"| node_internal_agent
node_internal_control -->|"manages"| node_internal_agent_session
node_internal_agent -->|"calls"| node_internal_provider
node_internal_agent -->|"executes"| node_internal_tool
node_internal_agent -->|"delegates"| node_internal_plugin
node_internal_agent -->|"recalls"| node_internal_memory
node_internal_agent -->|"compacts"| node_internal_memorycompiler
node_internal_agent -->|"reads/writes"| node_internal_history
node_internal_agent -->|"snapshots"| node_internal_checkpoint
node_internal_agent -->|"persists"| node_internal_store
node_internal_agent_session -->|"stores"| node_internal_store
node_internal_bot -->|"routes"| node_internal_control
node_internal_serve -->|"auths with"| node_workers_accounts
node_internal_serve -->|"manages"| node_internal_store
node_workers_crash -->|"reports"| node_desktop_main
node_workers_forum -->|"powers"| node_site
node_site -->|"auth flow"| node_workers_accounts
node_docs -.->|"specifies"| node_internal_control
node_release -.->|"packages"| node_desktop_main
node_release -.->|"packages"| node_cmd_reasonix

click node_cmd_reasonix "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/cmd/reasonix/main.go"
click node_internal_cli "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/cli"
click node_desktop_main "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/desktop/main.go"
click node_desktop_frontend "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/desktop/frontend/src"
click node_internal_control "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/control"
click node_internal_agent "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/agent"
click node_internal_provider "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/provider"
click node_internal_tool "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/tool"
click node_internal_plugin "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/plugin"
click node_internal_memory "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/memory"
click node_internal_memorycompiler "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/memorycompiler"
click node_internal_history "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/history"
click node_internal_checkpoint "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/checkpoint/checkpoint.go"
click node_internal_config "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/config/config.go"
click node_internal_store "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/store/session.go"
click node_internal_agent_session "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/agent/session.go"
click node_internal_bot "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/bot"
click node_internal_serve "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/serve/serve.go"
click node_workers_accounts "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/workers/accounts"
click node_workers_crash "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/workers/crash-report"
click node_workers_forum "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/workers/forum"
click node_site "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/site"
click node_docs "https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/docs"
click node_release "https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/.github/workflows"

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_cmd_reasonix,node_internal_cli,node_desktop_main,node_desktop_frontend toneBlue
class node_internal_control,node_internal_agent,node_internal_provider,node_internal_tool,node_internal_plugin,node_internal_memory,node_internal_memorycompiler,node_internal_history,node_internal_checkpoint,node_internal_config,node_internal_store,node_internal_agent_session,node_internal_bot,node_internal_serve toneAmber
class node_workers_accounts,node_workers_crash,node_workers_forum toneMint
class node_site,node_docs,node_release toneRose
```

## Components

### Client apps

User-facing shells and desktop frontend.

- [CLI](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/cmd/reasonix/main.go): terminal entrypoint · Main terminal binary for local agent sessions. · `cmd/reasonix/main.go`
- [Shell UX](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/cli): terminal UI · Interactive command surfaces and chat TUI around the shared engine. · `internal/cli`
- [Desktop app](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/desktop/main.go): wails backend · Go backend entrypoint for the desktop application. · `desktop/main.go`
- [Desktop UI](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/desktop/frontend/src): react/vite frontend · Conversation and workspace shell rendered through the Wails bridge. · `desktop/frontend/src`

### Core runtime

Shared Go orchestration, tools, memory, and persistence.

- [Control](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/control): orchestration layer · Loads config, assembles context, manages approvals, and drives turn execution. · `internal/control`
- [Agent core](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/agent): turn engine · Model-agnostic loop for planning, tool use, compaction, and recovery. · `internal/agent`
- [Providers](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/provider): model adapters · Adapters and presets for OpenAI-compatible and other model backends. · `internal/provider`
- [Tools](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/tool): tool contract · Built-in tool registry, tool results, and session-aware tool execution. · `internal/tool`
- [Plugins](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/plugin): external tools · Subprocess and HTTP plugin transport, caching, and host-side plugin management. · `internal/plugin`
- [Memory](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/memory): retrieval store · Long-term memory, recall, and user-authored knowledge handling. · `internal/memory`
- [Memory compactor](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/memorycompiler): summary pipeline · Compresses memory and feedback to stay within context limits. · `internal/memorycompiler`
- [History](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/history): transcript store · Transcript and tool history search, stripping, and replay support. · `internal/history`
- [Checkpoints](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/checkpoint/checkpoint.go): recovery snapshots · Checkpointing and rewind support for session recovery. · `internal/checkpoint/checkpoint.go`
- [Config](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/config/config.go): settings loader · Loads reasonix.toml, user config, environment, presets, and model selection. · `internal/config/config.go`
- [Store](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/store/session.go): local persistence · Local session persistence layer used by the client runtime. · `internal/store/session.go`
- [Session core](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/agent/session.go): session lifecycle · Session identity, leases, recovery hooks, and event flow within the agent runtime. · `internal/agent/session.go`
- [Bots](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/internal/bot): chat integrations · Chat gateway, rendering, pairing, and platform adapters for external messaging surfaces. · `internal/bot`
- [Hosted runtime](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/internal/serve/serve.go): session service · Server-side session interaction and login/auth flows. · `internal/serve/serve.go`

### Hosted services

Separate deployment units for accounts, crash reporting, and community.

- [Accounts](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/workers/accounts): auth service · Hosted account, session, email-token, and device-grant service. · `workers/accounts`
- [Crash report](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/workers/crash-report): telemetry service · Crash telemetry plus registry/admin and package activity tracking. · `workers/crash-report`
- [Forum](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/workers/forum): community service · Lightweight community service with identity and antispam logic. · `workers/forum`

### Docs and release

Documentation, packaging, automation, and distribution.

- [Website](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/site): astro site · Public marketing, docs, account, and community web app. · `site`
- [Docs](https://github.com/priorityfill/deepseek-reasonix/tree/main-v2/docs): spec docs · Architecture, configuration, tool contract, checkpoint, and guide documentation. · `docs`
- [Release](https://github.com/priorityfill/deepseek-reasonix/blob/main-v2/.github/workflows): packaging automation · GitHub Actions, GoReleaser, npm packaging, and code-signing workflows. · `.github/workflows`

## Connections

- CLI → Shell UX: uses · CLI entrypoint hands off to terminal UX and commands.
- Shell UX → Control: orchestrates · Terminal shell delegates turns and session actions to control.
- Desktop app → Desktop UI: hosts · Wails backend serves the React/Vite desktop shell.
- Desktop app → Control: uses · Desktop backend converges on the shared orchestration core.
- Desktop UI → Control: bridges · Frontend state and actions flow through the Wails bridge into backend session data.
- Control → Config: loads · Configuration determines providers, tools, workspace, and runtime behavior.
- Control → Agent core: drives · Control layer runs the agent loop and turn orchestration.
- Control → Session core: manages · Control manages session lifecycle, resume, and recovery hooks.
- Agent core → Providers: calls · Agent invokes configured model providers.
- Agent core → Tools: executes · Agent runs built-in tools through the shared contract.
- Agent core → Plugins: delegates · Agent can route tool-like work to external plugins.
- Agent core → Memory: recalls · Agent retrieves memory for long-running sessions.
- Agent core → Memory compactor: compacts · Agent compresses memory and feedback to preserve context.
- Agent core → History: reads/writes · Agent tracks transcript and tool history for replay and context maintenance.
- Agent core → Checkpoints: snapshots · Agent checkpoints progress for rewind and recovery.
- Agent core → Store: persists · Session artifacts are stored locally for resume and recovery.
- Session core → Store: stores · Session state is persisted through the local store layer.
- Bots → Control: routes · Bot surfaces feed requests into the same orchestration core.
- Hosted runtime → Accounts: auths with · Hosted session/login flows rely on the accounts service.
- Hosted runtime → Store: manages · Hosted runtime interacts with session state and recovery artifacts.
- Crash report → Desktop app: reports · Desktop app integrates crash telemetry and registry interactions.
- Forum → Website: powers · Community service backs public forum/community pages.
- Website → Accounts: auth flow · Website account and login pages connect to the accounts service.
- Docs → Control: specifies · Documentation defines architecture, contracts, and recovery behavior.
- Release → Desktop app: packages · Release automation builds and signs the desktop distribution.
- Release → CLI: packages · Release automation ships the CLI binary.
