# logeshn554/loopix__ architecture

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

- Interactive diagram: https://gitdiagram.com/logeshn554/loopix__
- Repository: https://github.com/logeshn554/loopix__

## Overview

#### Purpose and Entry Points
DevPilot is a local AI-native developer IDE: a React UI drives a Python API that analyzes workspaces, invokes LLM-backed agents, safely edits code, executes tools, and verifies results. Primary startup surfaces are `backend/app/main.py` (ASGI application), `frontend/src/main.tsx` (Vite React client), and `electron/main.js` (desktop shell). Backend is normally served by Uvicorn; Electron can package/embed the web experience.

#### Client, Desktop, and API Boundary
The frontend is a stateful IDE rather than a thin chat page. `frontend/src/App.tsx` composes editor, workspace, terminal, git, task, and agent panels; `frontend/src/api.ts` is its backend boundary. Context providers isolate UI domains, notably `frontend/src/core/ai/AIContext.tsx`, `frontend/src/core/workspace/WorkspaceContext.tsx`, and `frontend/src/core/editor/EditorContext.tsx`. Electron’s main/preload pair, `electron/main.js` and `electron/preload.js`, provides desktop integration while retaining the frontend/backend split.

#### HTTP Gateway and Platform Services
`backend/app/main.py` mounts the application’s route layer, with chat/agent execution centered in `backend/app/routes/chat.py` and `backend/app/routes/agents.py`; workspace and filesystem operations are exposed through `backend/app/routes/workspace.py` and `backend/app/routes/files.py`. Gateway controls—authentication, sessions, streaming, rate limiting, and circuit breaking—are separated in `backend/app/gateway/auth.py`, `backend/app/gateway/session_manager.py`, and `backend/app/gateway/streaming.py`. This is the principal boundary between untrusted client requests and execution services.

#### Agent Orchestration and Planning
The core agent layer converts an intent into planned, stateful execution. `backend/app/orchestrator.py`, `backend/app/agent/planning_engine.py`, and `backend/app/agent/workflow_engine.py` coordinate task progression. The more structured Agent OS supports agent construction, DAG execution, checkpoints, tool policy, verification, and worktrees in `backend/app/agent/agent_os/agent/agent_factory.py`, `backend/app/agent/agent_os/agent/dag_executor.py`, and `backend/app/agent/agent_os/agent/state_machine.py`. Parallel task decomposition/supervision exists independently under `backend/app/agent/parallel_agent_system/graph/supervisor.py` and `backend/app/agent/parallel_agent_system/graph/nodes/decompose.py`.

#### Context, Code Intelligence, and Memory
Before action, the system builds codebase-aware context through indexing, symbol/dependency analysis, search/ranking, and security filtering: `backend/app/agent/context_engine/context_engine.py`, `backend/app/agent/context_engine/symbol_index.py`, and `backend/app/agent/context_engine/dependency_graph.py`. Long-lived semantic and operational memory is modeled separately in `backend/app/brain/knowledge_graph.py`, `backend/app/brain/decision_memory.py`, and `backend/app/agent/knowledge_store.py`. These components feed planning and prompts but should remain distinct from direct workspace mutation.

#### LLM, Tools, and Execution Boundary
Provider abstraction and routing isolate model vendors from orchestration: `backend/app/adapters/router.py`, `backend/app/adapters/llm.py`, and `backend/app/agent/agent_os/providers/model_router.py`. Agent-selected actions pass through registered filesystem, Git, terminal, search, and web tools (`backend/app/tools/dispatcher.py`, `backend/app/tools/terminal_tool.py`, `backend/app/tools/file_tools.py`). Execution should be mediated by policy/sandbox layers rather than model output; alternate runtime mechanics live in `backend/app/agent/agent_runtime/runtime.py` and `backend/app/agent/agent_os/execution/sandbox.py`.

#### Safety, Transactionality, and Delivery
Security is enforced outside the LLM via permissions, workspace guards, prompt-injection protection, secret redaction, and terminal isolation: `backend/app/agent/security/permission_engine.py`, `backend/app/agent/security/workspace_guard.py`, and `backend/app/agent/security/prompt_injection_guard.py`. Changes are protected by transactional files/worktrees and merge/rollback mechanisms in `backend/app/transactional_fs.py`, `backend/app/merge/file_transaction.py`, and `backend/app/agent/agent_os/agent/git_worktree_manager.py`. Final gates run tests, lint/type/security checks via `backend/app/verification/test_runner.py`, `backend/app/verification/type_checker.py`, and `backend/app/outcome/release_gate.py`.

#### Infrastructure and External Integrations
Persistence includes SQLAlchemy/Alembic-oriented database infrastructure in `backend/app/infrastructure/database/connection.py` and migrations, plus agent/workflow stores under `backend/app/agent/agent_os/infrastructure/`. Observability and asynchronous work are represented by `backend/app/infrastructure/observability/telemetry.py`, `backend/app/infrastructure/queue.py`, and `backend/app/infrastructure/worker.py`. External boundaries include LLM providers, Open VSX/VSIX extension hosting (`backend/app/extension_host.py`), Git, terminal subprocesses, browser/web tools, and ChromaDB-style vector retrieval described by the context/RAG layer.

Main entry points: [`backend/app/agent/planning_engine.py`](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/planning_engine.py) (Planning & workflows), [`backend/app/agent/agent_os/agent/dag_executor.py`](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/agent_os/agent/dag_executor.py) (Structured Agent OS), [`backend/app/orchestrator.py`](https://github.com/logeshn554/loopix__/blob/main/backend/app/orchestrator.py) (Intent orchestration), [`frontend/src/App.tsx`](https://github.com/logeshn554/loopix__/blob/main/frontend/src/App.tsx) (IDE workspace UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client &amp; Desktop"]
  node_electron["Electron shell<br/>desktop runtime<br/>[main.js]"]
  node_preload["Desktop bridge<br/>Electron preload<br/>[preload.js]"]
  node_ide["IDE workspace UI<br/>React application<br/>[App.tsx]"]
  node_ui_context["UI domain state<br/>React contexts<br/>[AIContext.tsx]"]
  node_api_client["Backend API client<br/>frontend boundary<br/>[api.ts]"]
end

subgraph group_gateway["API Gateway"]
  node_asgi["ASGI application<br/>FastAPI entrypoint<br/>[main.py]"]
  node_routes["Chat, agent &amp; workspace routes<br/>HTTP route layer<br/>[chat.py]"]
  node_gateway_controls["Request controls<br/>auth/session/streaming<br/>[auth.py]"]
end

subgraph group_agents["Agent Execution"]
  node_orchestrator["Intent orchestration<br/>agent coordinator<br/>[orchestrator.py]"]
  node_planning["Planning &amp; workflows<br/>task execution engine<br/>[planning_engine.py]"]
  node_agent_os["Structured Agent OS<br/>DAG state machine<br/>[dag_executor.py]"]
  node_parallel["Parallel supervision<br/>task decomposition<br/>[supervisor.py]"]
end

subgraph group_intelligence["Context &amp; Memory"]
  node_context["Code context engine<br/>index/search/analysis<br/>[context_engine.py]"]
  node_memory[("Knowledge &amp; decisions<br/>semantic memory<br/>[knowledge_graph.py]")]
end

subgraph group_delivery["Safe Delivery"]
  node_runtime["Sandboxed runtime<br/>execution boundary<br/>[sandbox.py]"]
  node_security["Permission &amp; workspace guards<br/>security policy"]
  node_transactions["Transactional changes<br/>worktree/file transaction"]
  node_verification["Verification &amp; release gate<br/>quality gates<br/>[test_runner.py]"]
end

subgraph group_platform["Platform Services"]
  node_model_router["Model routing<br/>LLM provider boundary<br/>[router.py]"]
  node_tools["Tool dispatcher<br/>tool registry<br/>[dispatcher.py]"]
  node_persistence[("Database &amp; workflow stores<br/>persistence<br/>[connection.py]")]
  node_async_platform["Telemetry &amp; workers<br/>async platform<br/>[queue.py]"]
end

node_electron -->|"loads bridge"| node_preload
node_electron -->|"hosts"| node_ide
node_ide -->|"uses"| node_ui_context
node_ide -->|"calls through"| node_api_client
node_api_client -->|"HTTP/streaming"| node_asgi
node_asgi -->|"mounts"| node_routes
node_routes -->|"protected by"| node_gateway_controls
node_gateway_controls -->|"authorized requests"| node_orchestrator
node_orchestrator -->|"plans work"| node_planning
node_planning -->|"runs structured tasks"| node_agent_os
node_planning -.->|"delegates parallel work"| node_parallel
node_planning -->|"retrieves code context"| node_context
node_planning -->|"reads/writes memory"| node_memory
node_agent_os -->|"requests models"| node_model_router
node_agent_os -->|"selects actions"| node_tools
node_tools -->|"policy check"| node_security
node_security -->|"permits isolated execution"| node_runtime
node_runtime -->|"applies guarded changes"| node_transactions
node_transactions -->|"submits changes"| node_verification
node_verification -.->|"results and retry signal"| node_orchestrator
node_agent_os -->|"stores state/checkpoints"| node_persistence
node_orchestrator -.->|"emits jobs and telemetry"| node_async_platform

click node_electron "https://github.com/logeshn554/loopix__/blob/main/electron/main.js"
click node_preload "https://github.com/logeshn554/loopix__/blob/main/electron/preload.js"
click node_ide "https://github.com/logeshn554/loopix__/blob/main/frontend/src/App.tsx"
click node_ui_context "https://github.com/logeshn554/loopix__/blob/main/frontend/src/core/ai/AIContext.tsx"
click node_api_client "https://github.com/logeshn554/loopix__/blob/main/frontend/src/api.ts"
click node_asgi "https://github.com/logeshn554/loopix__/blob/main/backend/app/main.py"
click node_routes "https://github.com/logeshn554/loopix__/blob/main/backend/app/routes/chat.py"
click node_gateway_controls "https://github.com/logeshn554/loopix__/blob/main/backend/app/gateway/auth.py"
click node_orchestrator "https://github.com/logeshn554/loopix__/blob/main/backend/app/orchestrator.py"
click node_planning "https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/planning_engine.py"
click node_agent_os "https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/agent_os/agent/dag_executor.py"
click node_parallel "https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/parallel_agent_system/graph/supervisor.py"
click node_context "https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/context_engine/context_engine.py"
click node_memory "https://github.com/logeshn554/loopix__/blob/main/backend/app/brain/knowledge_graph.py"
click node_model_router "https://github.com/logeshn554/loopix__/blob/main/backend/app/adapters/router.py"
click node_tools "https://github.com/logeshn554/loopix__/blob/main/backend/app/tools/dispatcher.py"
click node_runtime "https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/agent_os/execution/sandbox.py"
click node_security "https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/security/permission_engine.py"
click node_transactions "https://github.com/logeshn554/loopix__/blob/main/backend/app/transactional_fs.py"
click node_verification "https://github.com/logeshn554/loopix__/blob/main/backend/app/verification/test_runner.py"
click node_persistence "https://github.com/logeshn554/loopix__/blob/main/backend/app/infrastructure/database/connection.py"
click node_async_platform "https://github.com/logeshn554/loopix__/blob/main/backend/app/infrastructure/queue.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_electron,node_preload,node_ide,node_ui_context,node_api_client toneBlue
class node_asgi,node_routes,node_gateway_controls toneAmber
class node_orchestrator,node_planning,node_agent_os,node_parallel toneMint
class node_context,node_memory toneRose
class node_runtime,node_security,node_transactions,node_verification toneIndigo
class node_model_router,node_tools,node_persistence,node_async_platform toneTeal
```

## Components

### Client & Desktop

- [Electron shell](https://github.com/logeshn554/loopix__/blob/main/electron/main.js): desktop runtime · `electron/main.js`
- [Desktop bridge](https://github.com/logeshn554/loopix__/blob/main/electron/preload.js): Electron preload · `electron/preload.js`
- [IDE workspace UI](https://github.com/logeshn554/loopix__/blob/main/frontend/src/App.tsx): React application · Composes editor, workspace, terminal, Git, task, and agent panels. · `frontend/src/App.tsx`
- [UI domain state](https://github.com/logeshn554/loopix__/blob/main/frontend/src/core/ai/AIContext.tsx): React contexts · `frontend/src/core/ai/AIContext.tsx`
- [Backend API client](https://github.com/logeshn554/loopix__/blob/main/frontend/src/api.ts): frontend boundary · `frontend/src/api.ts`

### API Gateway

- [ASGI application](https://github.com/logeshn554/loopix__/blob/main/backend/app/main.py): FastAPI entrypoint · `backend/app/main.py`
- [Chat, agent & workspace routes](https://github.com/logeshn554/loopix__/blob/main/backend/app/routes/chat.py): HTTP route layer · Exposes agent execution and workspace/filesystem operations. · `backend/app/routes/chat.py`
- [Request controls](https://github.com/logeshn554/loopix__/blob/main/backend/app/gateway/auth.py): auth/session/streaming · Applies authentication, sessions, streaming, rate limits, and circuit breaking. · `backend/app/gateway/auth.py`

### Agent Execution

- [Intent orchestration](https://github.com/logeshn554/loopix__/blob/main/backend/app/orchestrator.py): agent coordinator · `backend/app/orchestrator.py`
- [Planning & workflows](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/planning_engine.py): task execution engine · `backend/app/agent/planning_engine.py`
- [Structured Agent OS](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/agent_os/agent/dag_executor.py): DAG state machine · Constructs agents and runs checkpointed DAG execution. · `backend/app/agent/agent_os/agent/dag_executor.py`
- [Parallel supervision](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/parallel_agent_system/graph/supervisor.py): task decomposition · `backend/app/agent/parallel_agent_system/graph/supervisor.py`

### Context & Memory

- [Code context engine](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/context_engine/context_engine.py): index/search/analysis · Builds ranked codebase context with symbol and dependency intelligence. · `backend/app/agent/context_engine/context_engine.py`
- [Knowledge & decisions](https://github.com/logeshn554/loopix__/blob/main/backend/app/brain/knowledge_graph.py): semantic memory · `backend/app/brain/knowledge_graph.py`

### Safe Delivery

- [Sandboxed runtime](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/agent_os/execution/sandbox.py): execution boundary · `backend/app/agent/agent_os/execution/sandbox.py`
- [Permission & workspace guards](https://github.com/logeshn554/loopix__/blob/main/backend/app/agent/security/permission_engine.py): security policy · Enforces permissions, workspace restrictions, and prompt-injection defenses. · `backend/app/agent/security/permission_engine.py`
- [Transactional changes](https://github.com/logeshn554/loopix__/blob/main/backend/app/transactional_fs.py): worktree/file transaction · Supports isolated edits, merge, and rollback. · `backend/app/transactional_fs.py`
- [Verification & release gate](https://github.com/logeshn554/loopix__/blob/main/backend/app/verification/test_runner.py): quality gates · Runs tests, type/lint/security checks before delivery. · `backend/app/verification/test_runner.py`

### Platform Services

- [Model routing](https://github.com/logeshn554/loopix__/blob/main/backend/app/adapters/router.py): LLM provider boundary · `backend/app/adapters/router.py`
- [Tool dispatcher](https://github.com/logeshn554/loopix__/blob/main/backend/app/tools/dispatcher.py): tool registry · Dispatches filesystem, Git, terminal, search, and web actions. · `backend/app/tools/dispatcher.py`
- [Database & workflow stores](https://github.com/logeshn554/loopix__/blob/main/backend/app/infrastructure/database/connection.py): persistence · `backend/app/infrastructure/database/connection.py`
- [Telemetry & workers](https://github.com/logeshn554/loopix__/blob/main/backend/app/infrastructure/queue.py): async platform · Provides observability and queued background work. · `backend/app/infrastructure/queue.py`

## Connections

- Electron shell → Desktop bridge: loads bridge
- Electron shell → IDE workspace UI: hosts
- IDE workspace UI → UI domain state: uses
- IDE workspace UI → Backend API client: calls through
- Backend API client → ASGI application: HTTP/streaming
- ASGI application → Chat, agent & workspace routes: mounts
- Chat, agent & workspace routes → Request controls: protected by
- Request controls → Intent orchestration: authorized requests
- Intent orchestration → Planning & workflows: plans work
- Planning & workflows → Structured Agent OS: runs structured tasks
- Planning & workflows → Parallel supervision: delegates parallel work
- Planning & workflows → Code context engine: retrieves code context
- Planning & workflows → Knowledge & decisions: reads/writes memory
- Structured Agent OS → Model routing: requests models
- Structured Agent OS → Tool dispatcher: selects actions
- Tool dispatcher → Permission & workspace guards: policy check
- Permission & workspace guards → Sandboxed runtime: permits isolated execution
- Sandboxed runtime → Transactional changes: applies guarded changes
- Transactional changes → Verification & release gate: submits changes
- Verification & release gate → Intent orchestration: results and retry signal
- Structured Agent OS → Database & workflow stores: stores state/checkpoints
- Intent orchestration → Telemetry & workers: emits jobs and telemetry
