# undifined/pyagent architecture

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

- Interactive diagram: https://gitdiagram.com/undifined/pyagent
- Repository: https://github.com/undifined/pyagent

## Overview

PyAgent is described as an autonomous multi-agent software-development platform, but this checkout’s tree does not contain the README’s `src/`, `web/`, or `rust_core/` implementations. The visible runtime centers on a FastAPI/WebSocket backend and a separate parallel shard executor; the README documents a ten-stage agent workflow, a NebulaOS UI, and Rust services that cannot be mapped to source nodes here. The graph focuses on present modules and documented entry points; links between backend helpers follow the app’s source index, while unshown internal behavior is omitted.

Main entry points: [`backend/app.py`](https://github.com/undifined/pyagent/blob/main/backend/app.py) (FastAPI app), [`parallel_execution/orchestrator.py`](https://github.com/undifined/pyagent/blob/main/parallel_execution/orchestrator.py) (Shard orchestrator), [`backend/ws_handler.py`](https://github.com/undifined/pyagent/blob/main/backend/ws_handler.py) (WebSocket handler), [`parallel_execution/main.py`](https://github.com/undifined/pyagent/blob/main/parallel_execution/main.py) (Parallel CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Backend API"]
  node_api_app["FastAPI app<br/>[app.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_auth_store[("Refresh sessions")]
  node_rate["Rate limiting<br/>[rate_limiter.py]"]
  node_api_memory[("Memory store<br/>[memory_store.py]")]
  node_benchmark[("AutoMem benchmarks")]
  node_ws_handler["WebSocket handler<br/>[ws_handler.py]"]
  node_sessions["Live sessions<br/>[session_manager.py]"]
  node_models["Message models<br/>[models.py]"]
  node_ws_crypto["WebSocket crypto<br/>[ws_crypto.py]"]
end

subgraph group_execution["Parallel execution"]
  node_exec_entry["Parallel CLI<br/>[main.py]"]
  node_orchestrator["Shard orchestrator<br/>[orchestrator.py]"]
  node_worker["Shard worker<br/>[worker.py]"]
  node_queue["Distributed queue"]
  node_metrics["Execution metrics<br/>[metrics_tracker.py]"]
  node_quality["Quality gates<br/>[quality_gates.py]"]
  node_reporter["Telegram reports"]
end

subgraph group_reasoning["Reasoning"]
  node_reasoning["Advanced reasoning"]
  node_beam["Beam search"]
  node_cache[("Reasoning cache<br/>[cache_manager.py]")]
end

subgraph group_memory["Execution memory"]
  node_progress[("Progress tracking")]
  node_progress_executor["Tracked executor"]
end

subgraph group_implementation["Implementation engine"]
  node_impl_engine["Implementation engine"]
end

node_client(("UI / tooling"))

node_client -->|"calls REST"| node_api_app
node_client -->|"streams tasks"| node_ws_handler
node_api_app -->|"uses authentication"| node_auth
node_api_app -->|"manages refresh sessions"| node_auth_store
node_api_app -->|"applies limits"| node_rate
node_api_app -->|"uses memory store"| node_api_memory
node_api_app -->|"uses benchmark store"| node_benchmark
node_api_app -->|"routes WebSocket"| node_ws_handler
node_api_app -->|"uses WebSocket crypto"| node_ws_crypto
node_ws_handler -->|"looks up peers"| node_sessions
node_ws_handler -->|"serializes messages"| node_models
node_exec_entry -->|"creates and runs"| node_orchestrator
node_orchestrator -->|"runs workers"| node_worker
node_orchestrator -->|"coordinates shards"| node_queue
node_orchestrator -->|"collects metrics"| node_metrics
node_orchestrator -->|"reports progress"| node_reporter
node_progress_executor -->|"records execution"| node_progress
node_exec_entry -.->|"may gate output"| node_quality
node_worker -.->|"generates implementation"| node_impl_engine
node_reasoning -.->|"includes search"| node_beam
node_reasoning -.->|"includes caching"| node_cache

click node_api_app "https://github.com/undifined/pyagent/blob/main/backend/app.py"
click node_auth "https://github.com/undifined/pyagent/blob/main/backend/auth.py"
click node_auth_store "https://github.com/undifined/pyagent/blob/main/backend/auth_session_store.py"
click node_rate "https://github.com/undifined/pyagent/blob/main/backend/rate_limiter.py"
click node_api_memory "https://github.com/undifined/pyagent/blob/main/backend/memory_store.py"
click node_benchmark "https://github.com/undifined/pyagent/blob/main/backend/automem_benchmark_store.py"
click node_ws_handler "https://github.com/undifined/pyagent/blob/main/backend/ws_handler.py"
click node_sessions "https://github.com/undifined/pyagent/blob/main/backend/session_manager.py"
click node_models "https://github.com/undifined/pyagent/blob/main/backend/models.py"
click node_ws_crypto "https://github.com/undifined/pyagent/blob/main/backend/ws_crypto.py"
click node_exec_entry "https://github.com/undifined/pyagent/blob/main/parallel_execution/main.py"
click node_orchestrator "https://github.com/undifined/pyagent/blob/main/parallel_execution/orchestrator.py"
click node_worker "https://github.com/undifined/pyagent/blob/main/parallel_execution/worker.py"
click node_queue "https://github.com/undifined/pyagent/blob/main/parallel_execution/distributed_queue.py"
click node_metrics "https://github.com/undifined/pyagent/blob/main/parallel_execution/metrics_tracker.py"
click node_quality "https://github.com/undifined/pyagent/blob/main/parallel_execution/quality_gates.py"
click node_reporter "https://github.com/undifined/pyagent/blob/main/parallel_execution/telegram_reporter.py"
click node_progress "https://github.com/undifined/pyagent/blob/main/memory_system/progress_tracker.py"
click node_progress_executor "https://github.com/undifined/pyagent/blob/main/memory_system/mega_executor_with_progress.py"
click node_reasoning "https://github.com/undifined/pyagent/tree/main/advanced_reasoning"
click node_beam "https://github.com/undifined/pyagent/blob/main/advanced_reasoning/beam_search_reasoner.py"
click node_cache "https://github.com/undifined/pyagent/blob/main/advanced_reasoning/cache_manager.py"
click node_impl_engine "https://github.com/undifined/pyagent/blob/main/real_implementation_engine.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_api_app,node_auth,node_auth_store,node_rate,node_api_memory,node_benchmark,node_ws_handler,node_sessions,node_models,node_ws_crypto,node_client toneBlue
class node_exec_entry,node_orchestrator,node_worker,node_queue,node_metrics,node_quality,node_reporter toneAmber
class node_reasoning,node_beam,node_cache toneMint
class node_progress,node_progress_executor toneRose
class node_impl_engine toneIndigo
```

## Components

### Backend API

- [FastAPI app](https://github.com/undifined/pyagent/blob/main/backend/app.py): `backend/app.py`
- [Authentication](https://github.com/undifined/pyagent/blob/main/backend/auth.py): `backend/auth.py`
- [Refresh sessions](https://github.com/undifined/pyagent/blob/main/backend/auth_session_store.py): `backend/auth_session_store.py`
- [Rate limiting](https://github.com/undifined/pyagent/blob/main/backend/rate_limiter.py): `backend/rate_limiter.py`
- [Memory store](https://github.com/undifined/pyagent/blob/main/backend/memory_store.py): `backend/memory_store.py`
- [AutoMem benchmarks](https://github.com/undifined/pyagent/blob/main/backend/automem_benchmark_store.py): `backend/automem_benchmark_store.py`
- [WebSocket handler](https://github.com/undifined/pyagent/blob/main/backend/ws_handler.py): `backend/ws_handler.py`
- [Live sessions](https://github.com/undifined/pyagent/blob/main/backend/session_manager.py): `backend/session_manager.py`
- [Message models](https://github.com/undifined/pyagent/blob/main/backend/models.py): `backend/models.py`
- [WebSocket crypto](https://github.com/undifined/pyagent/blob/main/backend/ws_crypto.py): `backend/ws_crypto.py`

### Parallel execution

- [Parallel CLI](https://github.com/undifined/pyagent/blob/main/parallel_execution/main.py): `parallel_execution/main.py`
- [Shard orchestrator](https://github.com/undifined/pyagent/blob/main/parallel_execution/orchestrator.py): `parallel_execution/orchestrator.py`
- [Shard worker](https://github.com/undifined/pyagent/blob/main/parallel_execution/worker.py): `parallel_execution/worker.py`
- [Distributed queue](https://github.com/undifined/pyagent/blob/main/parallel_execution/distributed_queue.py): `parallel_execution/distributed_queue.py`
- [Execution metrics](https://github.com/undifined/pyagent/blob/main/parallel_execution/metrics_tracker.py): `parallel_execution/metrics_tracker.py`
- [Quality gates](https://github.com/undifined/pyagent/blob/main/parallel_execution/quality_gates.py): `parallel_execution/quality_gates.py`
- [Telegram reports](https://github.com/undifined/pyagent/blob/main/parallel_execution/telegram_reporter.py): `parallel_execution/telegram_reporter.py`

### Reasoning

- [Advanced reasoning](https://github.com/undifined/pyagent/tree/main/advanced_reasoning): `advanced_reasoning`
- [Beam search](https://github.com/undifined/pyagent/blob/main/advanced_reasoning/beam_search_reasoner.py): `advanced_reasoning/beam_search_reasoner.py`
- [Reasoning cache](https://github.com/undifined/pyagent/blob/main/advanced_reasoning/cache_manager.py): `advanced_reasoning/cache_manager.py`

### Execution memory

- [Progress tracking](https://github.com/undifined/pyagent/blob/main/memory_system/progress_tracker.py): `memory_system/progress_tracker.py`
- [Tracked executor](https://github.com/undifined/pyagent/blob/main/memory_system/mega_executor_with_progress.py): `memory_system/mega_executor_with_progress.py`

### Implementation engine

- [Implementation engine](https://github.com/undifined/pyagent/blob/main/real_implementation_engine.py): `real_implementation_engine.py`

### Other components

- **UI / tooling**

## Connections

- UI / tooling → FastAPI app: calls REST (evidence: `README.md`)
- UI / tooling → WebSocket handler: streams tasks (evidence: `README.md`)
- FastAPI app → Authentication: uses authentication (evidence: `backend/app.py`)
- FastAPI app → Refresh sessions: manages refresh sessions (evidence: `backend/app.py`)
- FastAPI app → Rate limiting: applies limits (evidence: `backend/app.py`)
- FastAPI app → Memory store: uses memory store (evidence: `backend/app.py`)
- FastAPI app → AutoMem benchmarks: uses benchmark store (evidence: `backend/app.py`)
- FastAPI app → WebSocket handler: routes WebSocket (evidence: `backend/app.py`)
- FastAPI app → WebSocket crypto: uses WebSocket crypto (evidence: `backend/app.py`)
- WebSocket handler → Live sessions: looks up peers (evidence: `backend/ws_handler.py`)
- WebSocket handler → Message models: serializes messages (evidence: `backend/ws_handler.py`)
- Parallel CLI → Shard orchestrator: creates and runs (evidence: `parallel_execution/main.py`)
- Shard orchestrator → Shard worker: runs workers (evidence: `parallel_execution/orchestrator.py`)
- Shard orchestrator → Distributed queue: coordinates shards (evidence: `parallel_execution/orchestrator.py`)
- Shard orchestrator → Execution metrics: collects metrics (evidence: `parallel_execution/orchestrator.py`)
- Shard orchestrator → Telegram reports: reports progress (evidence: `parallel_execution/orchestrator.py`)
- Tracked executor → Progress tracking: records execution (evidence: `memory_system/mega_executor_with_progress.py`)
- Parallel CLI → Quality gates: may gate output
- Shard worker → Implementation engine: generates implementation
- Advanced reasoning → Beam search: includes search
- Advanced reasoning → Reasoning cache: includes caching
