# aj47/100x-orchestrator architecture

> Architecture diagram of the GitHub repository aj47/100x-orchestrator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aj47/100x-orchestrator
- Repository: https://github.com/aj47/100x-orchestrator

## Overview

##### High-Level System Components

a) Web Interface Layer
- Static/templates components
- REST API endpoints

b) Orchestration Layer (Core)
- Central orchestrator component
- Agent session management
- Database system
- LiteLLM client integration

c) Execution Layer
- Aider agents
- Individual workspaces
- Git integration

##### Component Relationships

**[Web Interface Layer]**

- HTTP/WebSocket

**[Orchestration Layer]**

- Process Management

**[Execution Layer]**

##### Detailed Component Breakdown

**┌─────────────────────────────────────────┐**
- Web Interface                │
- ┌─────────┐ ┌─────────┐ ┌─────────┐    │
- Index    │ │Agent    │ │Config   │    │
- View     │ │View     │ │View     │    │
- ┘ └─────────┘ └─────────┘    │
- ┬─────────────────────┘

**┌───────────────────┼─────────────────────┐**
- Orchestration Layer                   │
- ┌─────────┐ ┌─────────┐ ┌─────────┐    │
- Orchestra│ │Agent    │ │Prompt   │    │
- tor      │ │Session  │ │Processor│    │
- ┬────┘ └────┬────┘ └────┬────┘    │

- ┌────┴────┐ ┌────┴────┐ ┌────┴────┐    │
- Database │ │LiteLLM  │ │GitHub   │    │
- Client   │ │Integration│   │
- ┘ └─────────┘ └─────────┘    │
- ┬─────────────────────┘

**┌───────────────────┼─────────────────────┐**
- Execution Layer                       │
- ┌─────────┐ ┌─────────┐ ┌─────────┐    │
- Aider    │ │Git      │ │Workspace│    │
- Instances│ │Repos    │ │Manager  │    │
- ┘ └─────────┘ └─────────┘    │
- ┘

##### Data Flow Indicators

- User requests flow (Web → Orchestrator)
- Agent creation and management flow (Orchestrator → Execution)
- Database operations (Components ↔ Database)
- API calls (Components ↔ External Services)

##### Important Elements

- Database schema representation (tasks.db)
- API endpoints from app.py
- Environment configuration flow
- Testing infrastructure (pytest)
- Security components (GitHub token handling)

##### Configuration and state management

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make this system unique, particularly its AI agent orchestration capabilities and workspace isolation features.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Web
        Flask["Flask Server"]:::web
        IndexView["Index View"]:::web
        AgentView["Agent View"]:::web
        ConfigView["Config View"]:::web
        FrontendLogic["Frontend Logic"]:::web
        Styles["Frontend Styling"]:::web
        
        Flask --> IndexView
        Flask --> AgentView
        Flask --> ConfigView
        IndexView --> FrontendLogic
        AgentView --> FrontendLogic
        ConfigView --> FrontendLogic
        FrontendLogic --> Styles
    end

    subgraph Core
        Orchestrator["Orchestrator"]:::core
        AgentSession["Agent Session Manager"]:::core
        Database["Database System"]:::core
        LiteLLM["LiteLLM Client"]:::core
        PromptProcessor["Prompt Processor"]:::core
        
        Orchestrator --> AgentSession
        Orchestrator --> Database
        AgentSession --> LiteLLM
        AgentSession --> PromptProcessor
    end

    subgraph Integration
        GitToken["GitHub Token Handler"]:::integration
        PullRequest["Pull Request Manager"]:::integration
        
        GitToken --> PullRequest
    end

    subgraph Testing
        TestSuite["Test Suite"]:::testing
        AgentTest["Agent Tests"]:::testing
        OrchestratorTest["Orchestrator Tests"]:::testing
        DBTest["Database Tests"]:::testing
        LLMTest["LiteLLM Tests"]:::testing
        GitTest["GitHub Tests"]:::testing
        PRTest["PR Tests"]:::testing
        
        TestSuite --> AgentTest
        TestSuite --> OrchestratorTest
        TestSuite --> DBTest
        TestSuite --> LLMTest
        TestSuite --> GitTest
        TestSuite --> PRTest
    end

    Web --> Core
    Core --> Integration

    %% Click Events
    click Flask "https://github.com/aj47/100x-orchestrator/blob/main/app.py"
    click IndexView "https://github.com/aj47/100x-orchestrator/blob/main/templates/index.html"
    click AgentView "https://github.com/aj47/100x-orchestrator/blob/main/templates/agent_view.html"
    click ConfigView "https://github.com/aj47/100x-orchestrator/blob/main/templates/config_view.html"
    click FrontendLogic "https://github.com/aj47/100x-orchestrator/tree/main/static/js"
    click Styles "https://github.com/aj47/100x-orchestrator/blob/main/static/css/styles.css"
    click Orchestrator "https://github.com/aj47/100x-orchestrator/blob/main/orchestrator.py"
    click AgentSession "https://github.com/aj47/100x-orchestrator/blob/main/agent_session.py"
    click Database "https://github.com/aj47/100x-orchestrator/blob/main/database.py"
    click LiteLLM "https://github.com/aj47/100x-orchestrator/blob/main/litellm_client.py"
    click PromptProcessor "https://github.com/aj47/100x-orchestrator/blob/main/prompt_processor.py"
    click GitToken "https://github.com/aj47/100x-orchestrator/blob/main/github_token.py"
    click PullRequest "https://github.com/aj47/100x-orchestrator/blob/main/pull_request.py"
    click TestSuite "https://github.com/aj47/100x-orchestrator/tree/main/tests"
    click AgentTest "https://github.com/aj47/100x-orchestrator/blob/main/tests/test_agent_session.py"
    click OrchestratorTest "https://github.com/aj47/100x-orchestrator/blob/main/tests/test_orchestrator.py"
    click DBTest "https://github.com/aj47/100x-orchestrator/blob/main/tests/test_database.py"
    click LLMTest "https://github.com/aj47/100x-orchestrator/blob/main/tests/test_litellm_client.py"
    click GitTest "https://github.com/aj47/100x-orchestrator/blob/main/tests/test_github_token.py"
    click PRTest "https://github.com/aj47/100x-orchestrator/blob/main/tests/test_pull_request.py"

    %% Styling
    classDef web fill:#2374ab
    classDef core fill:#48a9a6
    classDef integration fill:#e4cc37
    classDef testing fill:#d96941

    %% Legend
    subgraph Legend
        WebL["Web Interface"]:::web
        CoreL["Core Components"]:::core
        IntegrationL["External Integration"]:::integration
        TestingL["Testing Infrastructure"]:::testing
    end
```
