# doriandarko/omni-engineer architecture

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

- Interactive diagram: https://gitdiagram.com/doriandarko/omni-engineer
- Repository: https://github.com/doriandarko/omni-engineer

## Overview

##### Project Type and Purpose
- This is a console-based AI-powered developer assistant. It is designed to respond to development-related commands (file management, web search, image processing, etc.) and integrate with multiple AI models via external services.
- The README provides clear details on the key features (AI-powered responses, multi-file editing, real-time diff display, image handling, etc.) and explains that it uses OpenRouter to send queries to various AI models.

##### Key Components
a. Main Application:
- Main Module (main.py): Acts as the entry point that interprets user commands from the console and directs them to the appropriate processing module.
- Environment & Config: The .env file (configured from .env.example) that holds API keys and configuration parameters.
- Dependency Management: Although not a logical module, requirements.txt indicates dependency on external libraries—to be noted near the main application framework.

b. Command Processing and Routing:
- A Command Parser Component that reads user inputs from the terminal.
- A Command Dispatcher that routes commands such as /add, /edit, /search, /image, etc. to dedicated handlers.

c. Feature-specific Modules:
- File Management Module: Handles file creation, editing, and undo functionality.
- AI Communication Module: Deals with sending user queries and supporting commands to external AI models. This would include sending requests to OpenRouter (indicating model selection/switching and streaming responses).
- Search Module: Interfaces with the web (e.g., using DuckDuckGo) for search queries.
- Image Processing Module: Responsible for handling both local images and URL-based images integrated into the context.
- Session/History Module: Manages conversation save & load, chat history, and command history.
- /Output Module: Implements real-time diff display and syntax highlighting.

d. External Integrations:
- External AI Service (OpenRouter): This component is responsible for handling the heavy lifting of AI responses through models like “anthropic/claude-3.5-sonnet” and “google/gemini-pro-1.5.”
- External APIs such as DuckDuckGo for web searches.

##### Architectural Relationships and Interactions
- User interacts with the console (Front-End Interface) and issues a command.
- The main application processes the input through the Command Parser.
- Depending on the command, it redirects the request to one of the modules:
- File operations are handled by the File Management Module.
- Any AI-related processing is forwarded to the AI Communication Module that interfaces with OpenRouter.
- Web search and image commands are directed to the Search and Image Processing Modules respectively.
- Results from these modules are routed back and displayed to the user via the Display/Output Module.
- There’s also a feedback loop where updates (like diff updates in file content) are calculated and shown.

##### Architectural Patterns
- A modular monolithic design: Although it’s a single script (main.py), different concerns (command handling, external API interfacing, session management) should be treated as separate components or layers.
- Separation of concerns is key; distinct modules can be visualized as separate blocks even if they reside in the same file or are later separated.
- The design suggests a loosely-coupled command-driven architecture with clear boundaries between UI, business logic, and external integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities and Styles
    UI["Console Input/Output"]:::internal
    MAIN["Main Module: main.py"]:::internal
    CONFIG["Environment & Configuration (.env)"]:::internal
    DEP["Dependency Management (requirements.txt)"]:::internal

    CMD["Command Parser/Dispatcher"]:::internal
    FILE["File Management Module"]:::internal
    AI["AI Communication Module"]:::internal
    SEARCH["Search Module"]:::internal
    IMG["Image Processing Module"]:::internal
    SESSION["Session/History Module"]:::internal
    DISPLAY["Display/Output Module"]:::internal

    EXT_AI["External AI Service (OpenRouter API)"]:::external
    EXT_SEARCH["External Web Search API (DuckDuckGo)"]:::external

    %% Diagram Flow - Vertical Orientation
    UI -->|"sendsCommand"| CMD
    MAIN -->|"starts"| CMD
    CONFIG -->|"configures"| MAIN
    DEP -->|"providesDependencies"| MAIN

    CMD -->|"fileCommand"| FILE
    CMD -->|"aiCommand"| AI
    CMD -->|"searchCommand"| SEARCH
    CMD -->|"imageCommand"| IMG
    CMD -->|"sessionCommand"| SESSION

    FILE -->|"updatesDiff"| DISPLAY
    AI -->|"returnsAIResponse"| DISPLAY
    SEARCH -->|"returnsSearchResults"| DISPLAY
    IMG -->|"returnsImageData"| DISPLAY
    SESSION -->|"returnsSessionData"| DISPLAY

    AI -->|"calls"| EXT_AI
    SEARCH -->|"calls"| EXT_SEARCH

    %% Click Events for Component Mapping
    click MAIN "https://github.com/doriandarko/omni-engineer/blob/main/main.py"
    click CONFIG "https://github.com/doriandarko/omni-engineer/blob/main/.env.example"
    click DEP "https://github.com/doriandarko/omni-engineer/blob/main/requirements.txt"

    %% Styles
    classDef internal fill:#d6eaf8,stroke:#2874a6,stroke-width:2px;
    classDef external fill:#fdebd0,stroke:#d35400,stroke-width:2px;
```
