# bootstrapguru/dexor architecture

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

- Interactive diagram: https://gitdiagram.com/bootstrapguru/dexor
- Repository: https://github.com/bootstrapguru/dexor

## Overview

##### Project Type and Purpose
- Dexor is an AI-powered coding assistant built primarily in PHP. It aims to streamline software development by automating repetitive tasks (like bug identification, test case generation, and file management) through integrations with multiple AI providers (Anthropic Claude, OpenAI, Open Router, Ollama, and DeepSeek).
- Although it has a command-line interface (invoked via the “dexor” command), it’s architected like a web application (using familiar concepts such as Models, Migrations, Providers, and Services) emphasizing a clean separation of concerns and modular design.

##### Dissecting the File Structure for Architectural Insights
- The “app” directory is central and follows a modular pattern:
- Directories like “Models” and “Data” capture the core business entities (e.g., Assistant, Message, Project, Thread) and data representations.
- “Commands” (like DexorCommand) indicate the CLI interface entry points for interacting with the system.
- “Integrations” contains subdirectories for each AI provider (Claude, OpenAI, Ollama, OpenRouter) with purpose-specific connectors and requests. This clearly shows an extensible design where each provider is treated as a separate integration module.
- “Services” (including ChatAssistant and Request handling) encapsulate business logic and orchestrate interactions among components.
- “Tools” provide utility actions (e.g., CreateFile, ExecuteCommand, ListFiles) which the system can invoke to perform operations on the codebase.
- “Providers” and “Traits” further hint at dependency injection and shared functionalities.
- Supporting directories (config, database migrations, tests, bootstrap) indicate that the project adheres to modern PHP framework conventions (likely similar to Laravel), using configuration files, environment settings, and service providers.

##### Main Components and Their Interactions
a. CLI Interface & Command Handling:
- The entry point is the “dexor” CLI command (as seen in app/Commands). This receives user input, instantiates the appropriate command (e.g., DexorCommand) which then delegates tasks.
b. Core Application Logic:
- Services (like ChatAssistant) and Request handling classes under “app/Services” drive the business logic.
- Domain models and data structures (under Models/ and Data/) represent the assistant’s state, messages, and interactions.
c. AI Integrations:
- The “Integrations” directory details individual connectors for various AI providers. Each connector (for instance, in app/Integrations/OpenAI) handles building specific requests (like ChatRequest, ListModelsRequest) and managing responses.
d. Utility and Tooling Layer:
- The Tools directory contains functionalities for file manipulation and command execution. These are likely used as part of automation features in the assistant.
e. Persistence Layer (Database):
- The “database” directory with migrations and seeders shows how the state (assistants, projects, threads, messages) is persisted.
f. Configuration and Initialization:
- Config files (in config/) and bootstrap files set up the environment, dependency injection, and service provider registration.

##### Architectural Patterns and Design Principles
- Modularity and Separation of Concerns: Each function or service (commands, integrations, models, tools) is segregated into its own module.
- Extensibility: The integrations are designed as separate modules allowing new AI providers to be added without dramatically modifying core logic.
- Emphasis on Dependency Injection and Service Providers (as seen in app/Providers and bootstrap directories), enhancing testability and maintenance.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Interface (DexorCommand)"]:::cli
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Service["Core Business Services (ChatAssistant)"]:::service
        Models["Data/Domain Models"]:::model
        Tools["Utility Tools"]:::tool
    end

    %% External Integrations
    subgraph "External Integrations"
        Claude["Claude Integration"]:::integration
        OpenAI["OpenAI Integration"]:::integration
        OpenRouter["OpenRouter Integration"]:::integration
        Ollama["Ollama Integration"]:::integration
    end

    %% System Configuration
    subgraph "System Configuration"
        Config["Configuration Files"]:::config
        Bootstrap["Bootstrap Setup"]:::config
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        Database["Database (Migrations & Seeders)"]:::persistence
    end

    %% Connections
    CLI -->|"invokes"| Service
    CLI -->|"loads"| Bootstrap
    Bootstrap -->|"initializes"| Config
    Config -->|"configures"| Service
    Service -->|"handles-data"| Models
    Service -->|"utilizes"| Tools
    Service -->|"integrates-with"| Claude
    Service -->|"integrates-with"| OpenAI
    Service -->|"integrates-with"| OpenRouter
    Service -->|"integrates-with"| Ollama
    Service -->|"persists-in"| Database

    %% Click Events
    click CLI "https://github.com/bootstrapguru/dexor/blob/main/app/Commands/DexorCommand.php"
    click Service "https://github.com/bootstrapguru/dexor/blob/main/app/Services/ChatAssistant.php"
    click Models "https://github.com/bootstrapguru/dexor/tree/main/app/Models"
    click Tools "https://github.com/bootstrapguru/dexor/tree/main/app/Tools"
    click Claude "https://github.com/bootstrapguru/dexor/tree/main/app/Integrations/Claude"
    click OpenAI "https://github.com/bootstrapguru/dexor/tree/main/app/Integrations/OpenAI"
    click OpenRouter "https://github.com/bootstrapguru/dexor/tree/main/app/Integrations/OpenRouter"
    click Ollama "https://github.com/bootstrapguru/dexor/tree/main/app/Integrations/Ollama"
    click Database "https://github.com/bootstrapguru/dexor/tree/main/database"
    click Config "https://github.com/bootstrapguru/dexor/tree/main/config"
    click Bootstrap "https://github.com/bootstrapguru/dexor/tree/main/bootstrap"

    %% Styles
    classDef cli fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef service fill:#87CEEB,stroke:#000,stroke-width:2px;
    classDef model fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef integration fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef tool fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef persistence fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef config fill:#E6E6FA,stroke:#000,stroke-width:2px;
```
