# autoforgeai/autoforge architecture

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

- Interactive diagram: https://gitdiagram.com/autoforgeai/autoforge
- Repository: https://github.com/autoforgeai/autoforge

## Overview

#### Purpose and Launch Surfaces
AutoForge is a long-running autonomous coding harness: it converts an application specification into a persistent feature backlog, then repeatedly runs Claude-powered coding sessions against a generated project. npm users enter through `bin/autoforge.js` and `lib/cli.js`; source users use `start.py` for terminal operation or `start_ui.py` for the browser UI. The autonomous agent process begins at `autonomous_agent_demo.py`.

#### Agent Session Orchestration
The two-stage lifecycle is implemented around session and orchestration modules:
- Initialization creates project structure, Git state, prompts, and the initial feature set.
- Continuation sessions select and implement pending features, persist outcomes, and resume with a fresh model context.
- Parallel/autonomous coordination and progress handling are centered in `agent.py`, `parallel_orchestrator.py`, and `progress.py`.
Agent access to the Claude SDK/provider configuration is isolated in `client.py`; prompt selection/loading is in `prompts.py`.

#### Persistent Project and Feature Domain
Each generated project owns a SQLite `features.db`, prompts, progress notes, and generated application files. SQLAlchemy persistence and migrations live in `api/database.py` and `api/migration.py`. Dependency-aware backlog ordering is handled by `api/dependency_resolver.py`; `registry.py` and `autoforge_paths.py` provide project discovery/path conventions. This boundary lets sessions be disposable while feature status and Git commits remain durable.

#### MCP Feature-Control Boundary
Agents manage the backlog through an MCP server rather than directly coupling prompt/tool calls to UI behavior. `mcp_server/feature_mcp.py` exposes operations such as next-feature selection, bulk creation, skipping, regression selection, completion, and progress statistics. It mediates between agent execution and the SQLite feature model in `api/database.py`, forming the central control loop: agent requests work → MCP resolves/persists status → orchestrator starts the next session.

#### Security and Execution Constraints
Generated-project command execution is deliberately constrained. `security.py` validates an allowlisted command set and project-local filesystem scope; `auth.py` and `rate_limit_utils.py` support authentication/provider and rate-limit concerns. The intended runtime is Python 3.11+ plus the installed/authenticated Claude Code CLI; model access can use Anthropic, Vertex AI, or configured compatible providers such as Ollama, GLM, Kimi, and custom endpoints.

#### FastAPI Control Plane
The web backend is a FastAPI service rooted at `server/main.py`, with REST routers for projects, agents, features, filesystem, terminal, dev servers, schedules, settings, and specification workflows under `server/routers/`. Stateful process/session concerns are separated into services: agent-related database/chat sessions, process and terminal management, dev-server management, scheduler logic, and project configuration in `server/services/`. `server/websocket.py` streams agent status, logs, progress, and feature changes to project-scoped clients.

#### React Monitoring and Operator UI
The separate React/TypeScript frontend starts at `ui/src/main.tsx` and composes the application in `ui/src/App.tsx`. It calls the backend through `ui/src/lib/api.ts` and maintains live project state through `ui/src/hooks/useWebSocket.ts`. Operator-facing views cover dashboard/progress, Kanban features, dependency graph, assistant/spec/expansion chats, terminals, browser/dev-server control, logs, schedules, and settings; principal view composition is under `ui/src/components/views/`.

#### External Integrations and Delivery
The npm package bootstraps Python environments and launches the local service; Python requirements are split between `requirements.txt` and `requirements-prod.txt`. Optional N8N progress webhooks provide external notifications. Local development uses Vite in `ui/`, while production startup serves the built frontend. CI is defined in `.github/workflows/ci.yml`.

Main entry points: [`agent.py`](https://github.com/autoforgeai/autoforge/blob/master/agent.py) (Agent coordination), [`server/main.py`](https://github.com/autoforgeai/autoforge/blob/master/server/main.py) (FastAPI app), [`mcp_server/feature_mcp.py`](https://github.com/autoforgeai/autoforge/blob/master/mcp_server/feature_mcp.py) (Feature MCP server), [`ui/src/App.tsx`](https://github.com/autoforgeai/autoforge/blob/master/ui/src/App.tsx) (Operator application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launch["Launch Surfaces"]
  node_npm_bin["npm launcher<br/>Node CLI<br/>[autoforge.js]"]
  node_node_cli["Node CLI<br/>[cli.js]"]
  node_terminal_start["Terminal start<br/>Python entrypoint<br/>[start.py]"]
  node_ui_start["Browser UI start<br/>Python entrypoint<br/>[start_ui.py]"]
end

subgraph group_agent["Agent Runtime"]
  node_autonomous_entry["Autonomous runner<br/>Python entrypoint"]
  node_agent_orchestration["Agent coordination<br/>orchestrator<br/>[agent.py]"]
  node_parallel_orchestrator["Parallel orchestration<br/>orchestrator"]
  node_claude_client["Model client<br/>provider adapter<br/>[client.py]"]
  node_prompts["Prompt loader<br/>prompt registry<br/>[prompts.py]"]
end

subgraph group_domain["Feature Control"]
  node_mcp_feature_server{{"Feature MCP server<br/>[feature_mcp.py]"}}
  node_feature_persistence[("Feature persistence<br/>SQLAlchemy domain<br/>[database.py]")]
  node_dependency_resolver["Dependency resolver<br/>backlog ordering"]
  node_project_workspace[("Generated project<br/>persistent workspace")]
  node_execution_security["Execution security<br/>command guard<br/>[security.py]"]
end

subgraph group_server["FastAPI Control Plane"]
  node_fastapi_app["FastAPI app<br/>API service<br/>[main.py]"]
  node_server_services["Stateful services<br/>service layer<br/>[process_manager.py]"]
  node_websocket["Project WebSocket<br/>event stream<br/>[websocket.py]"]
end

subgraph group_ui["Operator UI"]
  node_react_entry["React entry<br/>TypeScript entrypoint<br/>[main.tsx]"]
  node_react_app["Operator application<br/>React composition<br/>[App.tsx]"]
  node_frontend_api["Backend API client<br/>HTTP client<br/>[api.ts]"]
  node_frontend_socket["Live state hook<br/>WebSocket hook<br/>[useWebSocket.ts]"]
end

node_claude_providers(("Claude-compatible providers<br/>external model service"))

node_npm_bin -->|"invokes"| node_node_cli
node_node_cli -->|"launches"| node_ui_start
node_terminal_start -->|"starts"| node_autonomous_entry
node_autonomous_entry -->|"runs"| node_agent_orchestration
node_agent_orchestration -->|"coordinates"| node_parallel_orchestrator
node_agent_orchestration -->|"loads prompts"| node_prompts
node_agent_orchestration -->|"requests coding session"| node_claude_client
node_claude_client -->|"uses"| node_claude_providers
node_agent_orchestration -->|"requests feature work"| node_mcp_feature_server
node_mcp_feature_server -->|"orders pending work"| node_dependency_resolver
node_mcp_feature_server -->|"reads and updates"| node_feature_persistence
node_feature_persistence -->|"persists features.db"| node_project_workspace
node_agent_orchestration -->|"writes outcomes and commits"| node_project_workspace
node_agent_orchestration -->|"validates execution"| node_execution_security
node_ui_start -->|"starts service"| node_fastapi_app
node_fastapi_app -->|"delegates stateful work"| node_server_services
node_server_services -->|"controls sessions"| node_agent_orchestration
node_fastapi_app -->|"serves feature data"| node_feature_persistence
node_fastapi_app -->|"publishes events"| node_websocket
node_react_entry -->|"mounts"| node_react_app
node_react_app -->|"uses"| node_frontend_api
node_react_app -->|"uses"| node_frontend_socket
node_frontend_api -->|"REST"| node_fastapi_app
node_frontend_socket -->|"subscribes"| node_websocket

click node_npm_bin "https://github.com/autoforgeai/autoforge/blob/master/bin/autoforge.js"
click node_node_cli "https://github.com/autoforgeai/autoforge/blob/master/lib/cli.js"
click node_terminal_start "https://github.com/autoforgeai/autoforge/blob/master/start.py"
click node_ui_start "https://github.com/autoforgeai/autoforge/blob/master/start_ui.py"
click node_autonomous_entry "https://github.com/autoforgeai/autoforge/blob/master/autonomous_agent_demo.py"
click node_agent_orchestration "https://github.com/autoforgeai/autoforge/blob/master/agent.py"
click node_parallel_orchestrator "https://github.com/autoforgeai/autoforge/blob/master/parallel_orchestrator.py"
click node_claude_client "https://github.com/autoforgeai/autoforge/blob/master/client.py"
click node_prompts "https://github.com/autoforgeai/autoforge/blob/master/prompts.py"
click node_mcp_feature_server "https://github.com/autoforgeai/autoforge/blob/master/mcp_server/feature_mcp.py"
click node_feature_persistence "https://github.com/autoforgeai/autoforge/blob/master/api/database.py"
click node_dependency_resolver "https://github.com/autoforgeai/autoforge/blob/master/api/dependency_resolver.py"
click node_execution_security "https://github.com/autoforgeai/autoforge/blob/master/security.py"
click node_fastapi_app "https://github.com/autoforgeai/autoforge/blob/master/server/main.py"
click node_server_services "https://github.com/autoforgeai/autoforge/blob/master/server/services/process_manager.py"
click node_websocket "https://github.com/autoforgeai/autoforge/blob/master/server/websocket.py"
click node_react_entry "https://github.com/autoforgeai/autoforge/blob/master/ui/src/main.tsx"
click node_react_app "https://github.com/autoforgeai/autoforge/blob/master/ui/src/App.tsx"
click node_frontend_api "https://github.com/autoforgeai/autoforge/blob/master/ui/src/lib/api.ts"
click node_frontend_socket "https://github.com/autoforgeai/autoforge/blob/master/ui/src/hooks/useWebSocket.ts"

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_npm_bin,node_node_cli,node_terminal_start,node_ui_start toneBlue
class node_autonomous_entry,node_agent_orchestration,node_parallel_orchestrator,node_claude_client,node_prompts toneAmber
class node_mcp_feature_server,node_feature_persistence,node_dependency_resolver,node_project_workspace,node_execution_security toneMint
class node_fastapi_app,node_server_services,node_websocket toneRose
class node_react_entry,node_react_app,node_frontend_api,node_frontend_socket toneIndigo
class node_claude_providers toneNeutral
```

## Components

### Launch Surfaces

- [npm launcher](https://github.com/autoforgeai/autoforge/blob/master/bin/autoforge.js): Node CLI · Bootstraps Python and launches the local service. · `bin/autoforge.js`
- [Node CLI](https://github.com/autoforgeai/autoforge/blob/master/lib/cli.js): CLI · `lib/cli.js`
- [Terminal start](https://github.com/autoforgeai/autoforge/blob/master/start.py): Python entrypoint · `start.py`
- [Browser UI start](https://github.com/autoforgeai/autoforge/blob/master/start_ui.py): Python entrypoint · `start_ui.py`

### Agent Runtime

- [Autonomous runner](https://github.com/autoforgeai/autoforge/blob/master/autonomous_agent_demo.py): Python entrypoint · `autonomous_agent_demo.py`
- [Agent coordination](https://github.com/autoforgeai/autoforge/blob/master/agent.py): orchestrator · Runs initialization, continuation, parallel execution, and progress handling. · `agent.py`
- [Parallel orchestration](https://github.com/autoforgeai/autoforge/blob/master/parallel_orchestrator.py): orchestrator · `parallel_orchestrator.py`
- [Model client](https://github.com/autoforgeai/autoforge/blob/master/client.py): provider adapter · Isolates Claude SDK and compatible provider configuration. · `client.py`
- [Prompt loader](https://github.com/autoforgeai/autoforge/blob/master/prompts.py): prompt registry · `prompts.py`

### Feature Control

- [Feature MCP server](https://github.com/autoforgeai/autoforge/blob/master/mcp_server/feature_mcp.py): MCP server · Backlog operations mediate the agent control loop. · `mcp_server/feature_mcp.py`
- [Feature persistence](https://github.com/autoforgeai/autoforge/blob/master/api/database.py): SQLAlchemy domain · Stores features and applies migrations. · `api/database.py`
- [Dependency resolver](https://github.com/autoforgeai/autoforge/blob/master/api/dependency_resolver.py): backlog ordering · `api/dependency_resolver.py`
- **Generated project**: persistent workspace · Contains application files, prompts, progress, Git state, and features.db.
- [Execution security](https://github.com/autoforgeai/autoforge/blob/master/security.py): command guard · Enforces allowlisted commands and project-local filesystem scope. · `security.py`

### FastAPI Control Plane

- [FastAPI app](https://github.com/autoforgeai/autoforge/blob/master/server/main.py): API service · REST control plane for projects, agents, features, terminal, dev servers, schedules, and settings. · `server/main.py`
- [Stateful services](https://github.com/autoforgeai/autoforge/blob/master/server/services/process_manager.py): service layer · Manages agent chats, processes, terminals, dev servers, scheduling, and project configuration. · `server/services/process_manager.py`
- [Project WebSocket](https://github.com/autoforgeai/autoforge/blob/master/server/websocket.py): event stream · Streams agent status, logs, progress, and feature changes. · `server/websocket.py`

### Operator UI

- [React entry](https://github.com/autoforgeai/autoforge/blob/master/ui/src/main.tsx): TypeScript entrypoint · `ui/src/main.tsx`
- [Operator application](https://github.com/autoforgeai/autoforge/blob/master/ui/src/App.tsx): React composition · Provides dashboard, backlog, graph, chats, terminals, logs, schedules, and settings. · `ui/src/App.tsx`
- [Backend API client](https://github.com/autoforgeai/autoforge/blob/master/ui/src/lib/api.ts): HTTP client · `ui/src/lib/api.ts`
- [Live state hook](https://github.com/autoforgeai/autoforge/blob/master/ui/src/hooks/useWebSocket.ts): WebSocket hook · `ui/src/hooks/useWebSocket.ts`

### Other components

- **Claude-compatible providers**: external model service · Anthropic, Vertex AI, or configured compatible endpoints.

## Connections

- npm launcher → Node CLI: invokes
- Node CLI → Browser UI start: launches
- Terminal start → Autonomous runner: starts
- Autonomous runner → Agent coordination: runs
- Agent coordination → Parallel orchestration: coordinates
- Agent coordination → Prompt loader: loads prompts
- Agent coordination → Model client: requests coding session
- Model client → Claude-compatible providers: uses
- Agent coordination → Feature MCP server: requests feature work
- Feature MCP server → Dependency resolver: orders pending work
- Feature MCP server → Feature persistence: reads and updates
- Feature persistence → Generated project: persists features.db
- Agent coordination → Generated project: writes outcomes and commits
- Agent coordination → Execution security: validates execution
- Browser UI start → FastAPI app: starts service
- FastAPI app → Stateful services: delegates stateful work
- Stateful services → Agent coordination: controls sessions
- FastAPI app → Feature persistence: serves feature data
- FastAPI app → Project WebSocket: publishes events
- React entry → Operator application: mounts
- Operator application → Backend API client: uses
- Operator application → Live state hook: uses
- Backend API client → FastAPI app: REST
- Live state hook → Project WebSocket: subscribes
