# anuragdeshmukh27/q-ai architecture

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

- Interactive diagram: https://gitdiagram.com/anuragdeshmukh27/q-ai
- Repository: https://github.com/anuragdeshmukh27/q-ai

## Overview

Q is a local AI software-building team with a React pixel-office interface. The main workflow is a user goal or imported project entering through the UI and API, then moving through specification and contract design, planning, parallel engineering, review, integration and QA; generated projects can then be run and inspected. The README documents additional sandbox, model-routing, benchmarking, and record/replay capabilities. Several backend links are documented rather than visible in the partial excerpts, so those edges cite the README; unsampled implementation details are not inferred.

Main entry points: [`backend/app/orchestrator.py`](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/orchestrator.py) (Build orchestrator), [`frontend/src/App.tsx`](https://github.com/anuragdeshmukh27/q-ai/blob/main/frontend/src/App.tsx) (React interface), [`backend/app/session.py`](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/session.py) (Build sessions), [`backend/app/goalspec.py`](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/goalspec.py) (Goal and contract design)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_frontend["React interface<br/>[App.tsx]"]
  node_office["Pixel office<br/>[scene.ts]"]
  node_state["UI state and stream<br/>[useQ.ts]"]
end

subgraph group_workflow["Build workflow"]
  node_api["HTTP and WebSocket API<br/>[main.py]"]
  node_session["Build sessions<br/>[session.py]"]
  node_orchestrator["Build orchestrator<br/>[orchestrator.py]"]
  node_spec["Goal and contract design<br/>[goalspec.py]"]
  node_planning["Task planning<br/>[planning.py]"]
  node_engineering["Agent execution<br/>[loop.py]"]
  node_review["Code review<br/>[review.py]"]
  node_integration["Branch integration<br/>[integrator.py]"]
  node_qa["Independent QA<br/>[qa.py]"]
end

subgraph group_runtime["Agent runtime"]
  node_tools["Sandboxed tools<br/>[tools.py]"]
  node_approval["Approval policy<br/>[approvals.py]"]
  node_llm["Structured model calls<br/>[llm.py]"]
  node_router["Model routing<br/>[router.py]"]
  node_scheduler["VRAM scheduler<br/>[scheduler.py]"]
  node_models["Model providers"]
end

subgraph group_project["Project output"]
  node_workspace["Generated project<br/>[project.py]"]
  node_preset["App scaffold<br/>[scaffold.py]"]
  node_relations["Resource design<br/>[relations.py]"]
end

subgraph group_history["Build history"]
  node_events["Build events<br/>[events.py]"]
  node_recording["Record and replay<br/>[recording.py]"]
end

node_user(("Builder"))
node_localmodels(("Ollama"))

node_user -->|"sets goal"| node_frontend
node_frontend -->|"uses state"| node_state
node_state -->|"sends requests"| node_api
node_api -->|"manages sessions"| node_session
node_session -->|"starts builds"| node_orchestrator
node_orchestrator -->|"defines goal"| node_spec
node_orchestrator -->|"plans tasks"| node_planning
node_orchestrator -->|"dispatches work"| node_engineering
node_orchestrator -->|"requests review"| node_review
node_orchestrator -->|"merges branches"| node_integration
node_orchestrator -->|"runs QA"| node_qa
node_engineering -->|"uses tools"| node_tools
node_tools -->|"checks policy"| node_approval
node_orchestrator -->|"requests completions"| node_llm
node_llm -.->|"selects model"| node_router
node_llm -->|"budgets models"| node_scheduler
node_scheduler -.->|"loads provider"| node_models
node_models -.->|"calls locally"| node_localmodels
node_orchestrator -->|"builds project"| node_workspace
node_orchestrator -->|"emits events"| node_events
node_session -->|"records or replays"| node_recording
node_recording -->|"stores events"| node_events
node_spec -.->|"derives resources"| node_relations
node_spec -.->|"seeds app structure"| node_preset
node_frontend -->|"renders office"| node_office

click node_frontend "https://github.com/anuragdeshmukh27/q-ai/blob/main/frontend/src/App.tsx"
click node_office "https://github.com/anuragdeshmukh27/q-ai/blob/main/frontend/src/office/scene.ts"
click node_state "https://github.com/anuragdeshmukh27/q-ai/blob/main/frontend/src/useQ.ts"
click node_api "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/main.py"
click node_session "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/session.py"
click node_orchestrator "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/orchestrator.py"
click node_spec "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/goalspec.py"
click node_planning "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/planning.py"
click node_engineering "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/loop.py"
click node_review "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/review.py"
click node_integration "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/integrator.py"
click node_qa "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/qa.py"
click node_tools "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/tools.py"
click node_approval "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/approvals.py"
click node_llm "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/llm.py"
click node_router "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/router.py"
click node_scheduler "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/scheduler.py"
click node_models "https://github.com/anuragdeshmukh27/q-ai/tree/main/backend/app/providers"
click node_workspace "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/project.py"
click node_preset "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/scaffold.py"
click node_relations "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/relations.py"
click node_events "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/events.py"
click node_recording "https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/recording.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_office,node_state toneBlue
class node_api,node_session,node_orchestrator,node_spec,node_planning,node_engineering,node_review,node_integration,node_qa toneAmber
class node_tools,node_approval,node_llm,node_router,node_scheduler,node_models toneMint
class node_workspace,node_preset,node_relations toneRose
class node_events,node_recording,node_user,node_localmodels toneIndigo
```

## Components

### User interface

- [React interface](https://github.com/anuragdeshmukh27/q-ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Pixel office](https://github.com/anuragdeshmukh27/q-ai/blob/main/frontend/src/office/scene.ts): `frontend/src/office/scene.ts`
- [UI state and stream](https://github.com/anuragdeshmukh27/q-ai/blob/main/frontend/src/useQ.ts): `frontend/src/useQ.ts`

### Build workflow

- [HTTP and WebSocket API](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Build sessions](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/session.py): `backend/app/session.py`
- [Build orchestrator](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/orchestrator.py): `backend/app/orchestrator.py`
- [Goal and contract design](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/goalspec.py): `backend/app/goalspec.py`
- [Task planning](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/planning.py): `backend/app/agent/planning.py`
- [Agent execution](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/loop.py): `backend/app/agent/loop.py`
- [Code review](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/review.py): `backend/app/agent/review.py`
- [Branch integration](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/integrator.py): `backend/app/integrator.py`
- [Independent QA](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/agent/qa.py): `backend/app/agent/qa.py`

### Agent runtime

- [Sandboxed tools](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/tools.py): `backend/app/tools.py`
- [Approval policy](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/approvals.py): `backend/app/approvals.py`
- [Structured model calls](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/llm.py): `backend/app/llm.py`
- [Model routing](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/router.py): `backend/app/router.py`
- [VRAM scheduler](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/scheduler.py): `backend/app/scheduler.py`
- [Model providers](https://github.com/anuragdeshmukh27/q-ai/tree/main/backend/app/providers): `backend/app/providers`

### Project output

- [Generated project](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/project.py): `backend/app/project.py`
- [App scaffold](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/scaffold.py): `backend/app/scaffold.py`
- [Resource design](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/relations.py): `backend/app/relations.py`

### Build history

- [Build events](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/events.py): `backend/app/events.py`
- [Record and replay](https://github.com/anuragdeshmukh27/q-ai/blob/main/backend/app/recording.py): `backend/app/recording.py`

### Other components

- **Builder**
- **Ollama**

## Connections

- Builder → React interface: sets goal (evidence: `README.md`)
- React interface → UI state and stream: uses state (evidence: `frontend/src/App.tsx`)
- UI state and stream → HTTP and WebSocket API: sends requests (evidence: `frontend/src/useQ.ts`)
- HTTP and WebSocket API → Build sessions: manages sessions (evidence: `backend/app/main.py`)
- Build sessions → Build orchestrator: starts builds (evidence: `README.md`)
- Build orchestrator → Goal and contract design: defines goal (evidence: `backend/app/orchestrator.py`)
- Build orchestrator → Task planning: plans tasks (evidence: `backend/app/orchestrator.py`)
- Build orchestrator → Agent execution: dispatches work (evidence: `README.md`)
- Build orchestrator → Code review: requests review (evidence: `README.md`)
- Build orchestrator → Branch integration: merges branches (evidence: `README.md`)
- Build orchestrator → Independent QA: runs QA (evidence: `README.md`)
- Agent execution → Sandboxed tools: uses tools (evidence: `README.md`)
- Sandboxed tools → Approval policy: checks policy (evidence: `README.md`)
- Build orchestrator → Structured model calls: requests completions (evidence: `backend/app/orchestrator.py`)
- Structured model calls → Model routing: selects model
- Structured model calls → VRAM scheduler: budgets models (evidence: `backend/app/llm.py`)
- VRAM scheduler → Model providers: loads provider
- Model providers → Ollama: calls locally
- Build orchestrator → Generated project: builds project (evidence: `README.md`)
- Build orchestrator → Build events: emits events (evidence: `README.md`)
- Build sessions → Record and replay: records or replays (evidence: `README.md`)
- Record and replay → Build events: stores events (evidence: `README.md`)
- Goal and contract design → Resource design: derives resources
- Goal and contract design → App scaffold: seeds app structure
- React interface → Pixel office: renders office (evidence: `frontend/src/App.tsx`)
