# amine123max/monolith architecture

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

- Interactive diagram: https://gitdiagram.com/amine123max/monolith
- Repository: https://github.com/amine123max/monolith

## Overview

Monolith is a local-first desktop workspace for AI-agent chat, coding, and collaboration. A user unlocks the optional local PIN gate, selects a workspace and starts a session; the React client sends requests through Tauri IPC to Rust orchestration, which routes model calls, runs tools, streams events, and persists session history and usage in local SQLite. Separate product branches cover provider configuration and secrets, local GGUF models, the integrated editor/terminal workbench, and desktop-native behavior. Relationships among backend crates and unsampled feature implementations follow README architecture statements; source excerpts establish the frontend entry points and IPC boundary.

Main entry points: [`apps/monolith-desktop/src/App.tsx`](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/App.tsx) (Workspace app), [`apps/monolith-desktop/src-tauri/src/commands.rs`](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src-tauri/src/commands.rs) (Command handlers), [`crates/monolith-agent/src/runtime.rs`](https://github.com/amine123max/monolith/blob/main/crates/monolith-agent/src/runtime.rs) (Agent runtime), [`crates/monolith-agent/src/orchestrator.rs`](https://github.com/amine123max/monolith/blob/main/crates/monolith-agent/src/orchestrator.rs) (Session orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop experience"]
  node_app["Workspace app<br/>[App.tsx]"]
  node_gate["PIN gate<br/>[LoginGate.tsx]"]
  node_chat["Session chat<br/>[SessionChat.tsx]"]
  node_workbench["Workbench<br/>[AgentInspector.tsx]"]
  node_ui_state["UI state<br/>[app.ts]"]
end

subgraph group_runtime["Agent runtime"]
  node_agent["Agent runtime<br/>[runtime.rs]"]
  node_orchestrator["Session orchestration<br/>[orchestrator.rs]"]
end

subgraph group_models["Models and tools"]
  node_router["Model routing<br/>[route.rs]"]
  node_openai["OpenAI adapter<br/>[lib.rs]"]
  node_anthropic["Anthropic adapter<br/>[lib.rs]"]
  node_tools["Tool registry<br/>[registry.rs]"]
end

subgraph group_data["Local data and security"]
  node_domain["Session domain<br/>[session.rs]"]
  node_sessions["Session repository<br/>[session.rs]"]
  node_database[("SQLite database<br/>[pool.rs]")]
  node_credentials["Encrypted credentials<br/>[file_store.rs]"]
  node_integrations["Security controls<br/>[lib.rs]"]
end

subgraph group_shell["Desktop shell"]
  node_ipc["IPC client<br/>[ipc.ts]"]
  node_tauri["Command handlers<br/>[commands.rs]"]
  node_local_models["Local models<br/>[local_models.rs]"]
end

node_user(("Desktop user"))
node_external_models{{"Configured model endpoints"}}
node_workspace["Workspace files"]

node_user -->|"unlocks"| node_gate
node_user -->|"uses"| node_app
node_app -->|"checks access"| node_gate
node_app -->|"opens sessions"| node_chat
node_app -->|"renders"| node_workbench
node_app -->|"updates"| node_ui_state
node_chat -->|"sends commands"| node_ipc
node_workbench -->|"requests tools"| node_ipc
node_ipc -->|"invokes"| node_tauri
node_tauri -->|"dispatches"| node_agent
node_agent -->|"drives sessions"| node_orchestrator
node_orchestrator -->|"selects model"| node_router
node_router -->|"routes requests"| node_openai
node_router -->|"routes requests"| node_anthropic
node_openai -->|"sends requests"| node_external_models
node_anthropic -->|"sends requests"| node_external_models
node_agent -->|"executes calls"| node_tools
node_tools -->|"reads and writes"| node_workspace
node_orchestrator -->|"persists history"| node_sessions
node_sessions -->|"stores entities"| node_domain
node_sessions -->|"reads and writes"| node_database
node_tauri -->|"protects keys"| node_credentials
node_tauri -->|"applies safeguards"| node_integrations
node_app -->|"manages models"| node_local_models
node_local_models -.->|"downloads fallback"| node_external_models

click node_app "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/App.tsx"
click node_gate "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/pages/LoginGate.tsx"
click node_chat "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/pages/SessionChat.tsx"
click node_workbench "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/components/AgentInspector.tsx"
click node_ui_state "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/store/app.ts"
click node_ipc "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/lib/ipc.ts"
click node_tauri "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src-tauri/src/commands.rs"
click node_agent "https://github.com/amine123max/monolith/blob/main/crates/monolith-agent/src/runtime.rs"
click node_orchestrator "https://github.com/amine123max/monolith/blob/main/crates/monolith-agent/src/orchestrator.rs"
click node_router "https://github.com/amine123max/monolith/blob/main/crates/monolith-router/src/route.rs"
click node_openai "https://github.com/amine123max/monolith/blob/main/crates/monolith-provider-openai/src/lib.rs"
click node_anthropic "https://github.com/amine123max/monolith/blob/main/crates/monolith-provider-anthropic/src/lib.rs"
click node_tools "https://github.com/amine123max/monolith/blob/main/crates/monolith-tools/src/registry.rs"
click node_local_models "https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src-tauri/src/local_models.rs"
click node_domain "https://github.com/amine123max/monolith/blob/main/crates/monolith-domain/src/session.rs"
click node_sessions "https://github.com/amine123max/monolith/blob/main/crates/monolith-db/src/repository/session.rs"
click node_database "https://github.com/amine123max/monolith/blob/main/crates/monolith-db/src/pool.rs"
click node_credentials "https://github.com/amine123max/monolith/blob/main/crates/monolith-security/src/file_store.rs"
click node_integrations "https://github.com/amine123max/monolith/blob/main/crates/monolith-security/src/lib.rs"

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_app,node_gate,node_chat,node_workbench,node_ui_state,node_user toneBlue
class node_agent,node_orchestrator toneAmber
class node_router,node_openai,node_anthropic,node_tools toneMint
class node_domain,node_sessions,node_database,node_credentials,node_integrations toneRose
class node_ipc,node_tauri,node_local_models,node_external_models,node_workspace toneIndigo
```

## Components

### Desktop experience

- [Workspace app](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/App.tsx): `apps/monolith-desktop/src/App.tsx`
- [PIN gate](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/pages/LoginGate.tsx): `apps/monolith-desktop/src/pages/LoginGate.tsx`
- [Session chat](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/pages/SessionChat.tsx): `apps/monolith-desktop/src/pages/SessionChat.tsx`
- [Workbench](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/components/AgentInspector.tsx): `apps/monolith-desktop/src/components/AgentInspector.tsx`
- [UI state](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/store/app.ts): `apps/monolith-desktop/src/store/app.ts`

### Agent runtime

- [Agent runtime](https://github.com/amine123max/monolith/blob/main/crates/monolith-agent/src/runtime.rs): `crates/monolith-agent/src/runtime.rs`
- [Session orchestration](https://github.com/amine123max/monolith/blob/main/crates/monolith-agent/src/orchestrator.rs): `crates/monolith-agent/src/orchestrator.rs`

### Models and tools

- [Model routing](https://github.com/amine123max/monolith/blob/main/crates/monolith-router/src/route.rs): `crates/monolith-router/src/route.rs`
- [OpenAI adapter](https://github.com/amine123max/monolith/blob/main/crates/monolith-provider-openai/src/lib.rs): `crates/monolith-provider-openai/src/lib.rs`
- [Anthropic adapter](https://github.com/amine123max/monolith/blob/main/crates/monolith-provider-anthropic/src/lib.rs): `crates/monolith-provider-anthropic/src/lib.rs`
- [Tool registry](https://github.com/amine123max/monolith/blob/main/crates/monolith-tools/src/registry.rs): `crates/monolith-tools/src/registry.rs`

### Local data and security

- [Session domain](https://github.com/amine123max/monolith/blob/main/crates/monolith-domain/src/session.rs): `crates/monolith-domain/src/session.rs`
- [Session repository](https://github.com/amine123max/monolith/blob/main/crates/monolith-db/src/repository/session.rs): `crates/monolith-db/src/repository/session.rs`
- [SQLite database](https://github.com/amine123max/monolith/blob/main/crates/monolith-db/src/pool.rs): `crates/monolith-db/src/pool.rs`
- [Encrypted credentials](https://github.com/amine123max/monolith/blob/main/crates/monolith-security/src/file_store.rs): `crates/monolith-security/src/file_store.rs`
- [Security controls](https://github.com/amine123max/monolith/blob/main/crates/monolith-security/src/lib.rs): `crates/monolith-security/src/lib.rs`

### Desktop shell

- [IPC client](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src/lib/ipc.ts): `apps/monolith-desktop/src/lib/ipc.ts`
- [Command handlers](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src-tauri/src/commands.rs): `apps/monolith-desktop/src-tauri/src/commands.rs`
- [Local models](https://github.com/amine123max/monolith/blob/main/apps/monolith-desktop/src-tauri/src/local_models.rs): `apps/monolith-desktop/src-tauri/src/local_models.rs`

### Other components

- **Desktop user**
- **Configured model endpoints**
- **Workspace files**

## Connections

- Desktop user → PIN gate: unlocks
- Desktop user → Workspace app: uses (evidence: `README.md`)
- Workspace app → PIN gate: checks access (evidence: `apps/monolith-desktop/src/App.tsx`)
- Workspace app → Session chat: opens sessions (evidence: `README.md`)
- Workspace app → Workbench: renders (evidence: `apps/monolith-desktop/src/App.tsx`)
- Workspace app → UI state: updates (evidence: `apps/monolith-desktop/src/App.tsx`)
- Session chat → IPC client: sends commands (evidence: `README.md`)
- Workbench → IPC client: requests tools (evidence: `apps/monolith-desktop/src/components/AgentInspector.tsx`)
- IPC client → Command handlers: invokes (evidence: `apps/monolith-desktop/src/lib/ipc.ts`)
- Command handlers → Agent runtime: dispatches (evidence: `README.md`)
- Agent runtime → Session orchestration: drives sessions (evidence: `README.md`)
- Session orchestration → Model routing: selects model (evidence: `README.md`)
- Model routing → OpenAI adapter: routes requests (evidence: `README.md`)
- Model routing → Anthropic adapter: routes requests (evidence: `README.md`)
- OpenAI adapter → Configured model endpoints: sends requests (evidence: `README.md`)
- Anthropic adapter → Configured model endpoints: sends requests (evidence: `README.md`)
- Agent runtime → Tool registry: executes calls (evidence: `README.md`)
- Tool registry → Workspace files: reads and writes (evidence: `README.md`)
- Session orchestration → Session repository: persists history (evidence: `README.md`)
- Session repository → Session domain: stores entities (evidence: `crates/monolith-db/src/repository/session.rs`)
- Session repository → SQLite database: reads and writes (evidence: `README.md`)
- Command handlers → Encrypted credentials: protects keys (evidence: `README.md`)
- Command handlers → Security controls: applies safeguards (evidence: `README.md`)
- Workspace app → Local models: manages models (evidence: `README.md`)
- Local models → Configured model endpoints: downloads fallback (evidence: `README.md`)
