# sj-thakur/crucible-prototype architecture

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

- Interactive diagram: https://gitdiagram.com/sj-thakur/crucible-prototype
- Repository: https://github.com/sj-thakur/crucible-prototype

## Overview

Crucible is an organization-controlled agent workspace platform. Its current user workflow is to sign in, enter an authorized workspace, and submit a workspace-scoped task; the API coordinates execution through context assembly, a local model gateway, and tools, then persists run state. CRM Operations adds explicit synthetic-account assignment and read-only meeting briefs or account-scoped tasks. Consequential tool actions pause for human approval. The graph reflects documented capabilities, but several routes and services were only indexed or partially excerpted, so uncertain connections are omitted.

Main entry points: [`src/api/app.py`](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/app.py) (FastAPI app), [`src/execution_plane/runner.py`](https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/runner.py) (Run coordinator), [`src/api/routes/crm_routes.py`](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/crm_routes.py) (CRM account routes), [`src/execution_plane/tools.py`](https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/tools.py) (Tool broker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_frontend["Web app<br/>[App.tsx]"]
  node_api["FastAPI app<br/>[app.py]"]
end

subgraph group_governance["Identity and governance"]
  node_auth_routes["Authentication routes<br/>[auth_routes.py]"]
  node_auth["Token authentication<br/>[auth.py]"]
  node_workspace_routes["Workspace management"]
  node_policy["Access and tool policy<br/>[policy.py]"]
  node_approval_routes["Approval routes<br/>[approval_routes.py]"]
  node_approvals["Human approval service<br/>[approvals.py]"]
end

subgraph group_execution["Task execution"]
  node_run_routes["Run routes<br/>[run_routes.py]"]
  node_runner["Run coordinator<br/>[runner.py]"]
  node_context["Workspace context<br/>[context.py]"]
  node_gateway["Local model gateway<br/>[gateway.py]"]
  node_tools["Tool broker<br/>[tools.py]"]
end

subgraph group_crm["CRM capability"]
  node_crm_routes["CRM account routes<br/>[crm_routes.py]"]
  node_synthetic["Synthetic CRM data"]
  node_brief["Meeting brief builder<br/>[meeting_brief.py]"]
end

subgraph group_data["Persistence"]
  node_database[("Workspace database<br/>[models.py]")]
  node_db_connection["Database sessions<br/>[connection.py]"]
end

node_user(("Workspace user"))
node_ollama["Ollama model service"]

node_user -->|"uses"| node_frontend
node_frontend -.->|"accesses"| node_api
node_api -->|"registers routes"| node_auth_routes
node_auth_routes -->|"authenticates"| node_auth
node_auth -->|"loads user"| node_db_connection
node_db_connection -->|"sessions query"| node_database
node_api -->|"registers routes"| node_workspace_routes
node_workspace_routes -->|"checks access"| node_policy
node_workspace_routes -->|"reads and writes"| node_database
node_api -->|"registers routes"| node_run_routes
node_run_routes -->|"checks access"| node_policy
node_run_routes -->|"executes run"| node_runner
node_run_routes -->|"reads and writes"| node_database
node_runner -->|"assembles context"| node_context
node_runner -->|"requests inference"| node_gateway
node_gateway -->|"sends inference"| node_ollama
node_runner -->|"dispatches tools"| node_tools
node_tools -->|"checks permission"| node_policy
node_tools -->|"searches or stores"| node_context
node_tools -->|"requests approval"| node_approvals
node_api -->|"registers routes"| node_approval_routes
node_approval_routes -->|"handles decisions"| node_approvals
node_approvals -->|"executes approved tool"| node_tools
node_api -->|"registers routes"| node_crm_routes
node_crm_routes -->|"checks access"| node_policy
node_crm_routes -->|"lists accounts"| node_synthetic
node_crm_routes -.->|"builds brief"| node_brief
node_crm_routes -->|"reads assignments"| node_database
node_runner -->|"loads CRM evidence"| node_synthetic
node_runner -->|"persists run state"| node_database

click node_frontend "https://github.com/sj-thakur/crucible-prototype/blob/main/frontend/App.tsx"
click node_api "https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/app.py"
click node_auth_routes "https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/auth_routes.py"
click node_auth "https://github.com/sj-thakur/crucible-prototype/blob/main/src/control_plane/auth.py"
click node_workspace_routes "https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/workspace_routes.py"
click node_policy "https://github.com/sj-thakur/crucible-prototype/blob/main/src/control_plane/policy.py"
click node_run_routes "https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/run_routes.py"
click node_runner "https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/runner.py"
click node_context "https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/context.py"
click node_gateway "https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/gateway.py"
click node_tools "https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/tools.py"
click node_approval_routes "https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/approval_routes.py"
click node_approvals "https://github.com/sj-thakur/crucible-prototype/blob/main/src/control_plane/approvals.py"
click node_crm_routes "https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/crm_routes.py"
click node_synthetic "https://github.com/sj-thakur/crucible-prototype/blob/main/src/crm/synthetic_source.py"
click node_brief "https://github.com/sj-thakur/crucible-prototype/blob/main/src/crm/meeting_brief.py"
click node_database "https://github.com/sj-thakur/crucible-prototype/blob/main/src/database/models.py"
click node_db_connection "https://github.com/sj-thakur/crucible-prototype/blob/main/src/database/connection.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_frontend,node_api,node_user toneBlue
class node_auth_routes,node_auth,node_workspace_routes,node_policy,node_approval_routes,node_approvals toneAmber
class node_run_routes,node_runner,node_context,node_gateway,node_tools toneMint
class node_crm_routes,node_synthetic,node_brief toneRose
class node_database,node_db_connection,node_ollama toneIndigo
```

## Components

### User experience

- [Web app](https://github.com/sj-thakur/crucible-prototype/blob/main/frontend/App.tsx): `frontend/App.tsx`
- [FastAPI app](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/app.py): `src/api/app.py`

### Identity and governance

- [Authentication routes](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/auth_routes.py): `src/api/routes/auth_routes.py`
- [Token authentication](https://github.com/sj-thakur/crucible-prototype/blob/main/src/control_plane/auth.py): `src/control_plane/auth.py`
- [Workspace management](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/workspace_routes.py): `src/api/routes/workspace_routes.py`
- [Access and tool policy](https://github.com/sj-thakur/crucible-prototype/blob/main/src/control_plane/policy.py): `src/control_plane/policy.py`
- [Approval routes](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/approval_routes.py): `src/api/routes/approval_routes.py`
- [Human approval service](https://github.com/sj-thakur/crucible-prototype/blob/main/src/control_plane/approvals.py): `src/control_plane/approvals.py`

### Task execution

- [Run routes](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/run_routes.py): `src/api/routes/run_routes.py`
- [Run coordinator](https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/runner.py): `src/execution_plane/runner.py`
- [Workspace context](https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/context.py): `src/execution_plane/context.py`
- [Local model gateway](https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/gateway.py): `src/execution_plane/gateway.py`
- [Tool broker](https://github.com/sj-thakur/crucible-prototype/blob/main/src/execution_plane/tools.py): `src/execution_plane/tools.py`

### CRM capability

- [CRM account routes](https://github.com/sj-thakur/crucible-prototype/blob/main/src/api/routes/crm_routes.py): `src/api/routes/crm_routes.py`
- [Synthetic CRM data](https://github.com/sj-thakur/crucible-prototype/blob/main/src/crm/synthetic_source.py): `src/crm/synthetic_source.py`
- [Meeting brief builder](https://github.com/sj-thakur/crucible-prototype/blob/main/src/crm/meeting_brief.py): `src/crm/meeting_brief.py`

### Persistence

- [Workspace database](https://github.com/sj-thakur/crucible-prototype/blob/main/src/database/models.py): `src/database/models.py`
- [Database sessions](https://github.com/sj-thakur/crucible-prototype/blob/main/src/database/connection.py): `src/database/connection.py`

### Other components

- **Workspace user**
- **Ollama model service**

## Connections

- Workspace user → Web app: uses (evidence: `README.md`)
- Web app → FastAPI app: accesses
- FastAPI app → Authentication routes: registers routes
- Authentication routes → Token authentication: authenticates (evidence: `src/api/routes/auth_routes.py`)
- Token authentication → Database sessions: loads user (evidence: `src/control_plane/auth.py`)
- Database sessions → Workspace database: sessions query (evidence: `src/database/connection.py`)
- FastAPI app → Workspace management: registers routes
- Workspace management → Access and tool policy: checks access (evidence: `src/api/routes/workspace_routes.py`)
- Workspace management → Workspace database: reads and writes (evidence: `src/api/routes/workspace_routes.py`)
- FastAPI app → Run routes: registers routes
- Run routes → Access and tool policy: checks access (evidence: `src/api/routes/run_routes.py`)
- Run routes → Run coordinator: executes run (evidence: `src/api/routes/run_routes.py`)
- Run routes → Workspace database: reads and writes (evidence: `src/api/routes/run_routes.py`)
- Run coordinator → Workspace context: assembles context (evidence: `src/execution_plane/runner.py`)
- Run coordinator → Local model gateway: requests inference (evidence: `src/execution_plane/runner.py`)
- Local model gateway → Ollama model service: sends inference (evidence: `src/execution_plane/gateway.py`)
- Run coordinator → Tool broker: dispatches tools (evidence: `src/execution_plane/runner.py`)
- Tool broker → Access and tool policy: checks permission (evidence: `src/execution_plane/tools.py`)
- Tool broker → Workspace context: searches or stores (evidence: `src/execution_plane/tools.py`)
- Tool broker → Human approval service: requests approval (evidence: `src/execution_plane/tools.py`)
- FastAPI app → Approval routes: registers routes
- Approval routes → Human approval service: handles decisions (evidence: `src/api/routes/approval_routes.py`)
- Human approval service → Tool broker: executes approved tool (evidence: `src/control_plane/approvals.py`)
- FastAPI app → CRM account routes: registers routes
- CRM account routes → Access and tool policy: checks access (evidence: `src/api/routes/crm_routes.py`)
- CRM account routes → Synthetic CRM data: lists accounts (evidence: `src/api/routes/crm_routes.py`)
- CRM account routes → Meeting brief builder: builds brief (evidence: `src/api/routes/crm_routes.py`)
- CRM account routes → Workspace database: reads assignments (evidence: `src/api/routes/crm_routes.py`)
- Run coordinator → Synthetic CRM data: loads CRM evidence (evidence: `src/execution_plane/runner.py`)
- Run coordinator → Workspace database: persists run state (evidence: `src/execution_plane/runner.py`)
