# stitionai/devika architecture

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

- Interactive diagram: https://gitdiagram.com/stitionai/devika
- Repository: https://github.com/stitionai/devika

## Overview

##### Project Type and Purpose
- Devika is a full-stack AI application that acts as an autonomous software engineer. It integrates LLMs (like GPT‐4, Claude 3, Gemini, etc.), advanced planning/reasoning, web browsing, and a UI for interactions.
- Key functionalities include parsing high-level objectives, breaking tasks into subtasks, researching, writing code, and project management. Its ambitious goal (mirroring Devin) shows the need to emphasize both the frontend (UI) and a highly modular backend engine.

##### File Structure and its Architectural Implications
- There’s a clear separation between frontend and backend:
– The “ui” directory comprises a modern web interface built with Svelte (using Vite, Tailwind, bun, etc.).
– The “src” directory contains most of the backend logic.
- Besides the agents, there are specialized modules:
– “llm”: Facilitates communication with various large language model providers (OpenAI, Claude, Gemini, etc.)
– “memory”: Implements knowledge base and retrieval mechanisms.
– “filesystem”, “services”, “sandbox”, “documenter”, and “browser”: Provide additional capabilities such as code reading, integration with external services (Git, GitHub, Netlify), safe code execution (via firejail), and generating documentation or visual representations (graphviz, UML).
- The presence of Dockerfiles, docker-compose.yaml, and Makefile indicates containerization and scripted setups for development and deployment.
- Documentation (docs/ directory) further details installation and architecture—important for verifying component interactions.

a. Main Components:
- Frontend/UI: Represent the web interface (in “ui”) which communicates with the backend API.
- Core Backend Engine: Include the primary server script (devika.py) and higher-level orchestrator (src/project.py, src/init.py) coordinating tasks.
- LLM Integration: Illustrate the “llm” module that encapsulates different client integrations (openai, claude, mistral, etc.).
- Services and External Integrations: Highlight connectors for Git, GitHub, Netlify (from src/services), search via external APIs, and browser interaction.
- Memory & State Management: Include components for memory (knowledge base, RAG) and state tracking.
- Utilities: Represent support modules like filesystem and sandbox (for secure code execution).
- Infrastructure/Containerization: Optionally include Docker and docker-compose components as they are used for deployment/testing.

b. Relationships and Data Flow:
- From the central orchestrator (e.g., devika.py / src/project.py), illustrate how high-level instructions are delegated to specific agent modules.
- That services (browser, file system, sandbox, etc.) are called by agents or the core engine.

c. Architectural Patterns and Design Principles:
- Modular Design: Emphasize that each agent is self-contained yet interacts with a common orchestration backend.
- Separation of Concerns: Clearly divide the UI/Client from backend processing and external integrations.
- Extensibility: Note that new agent types or external service connectors can be added, with clear “pluggable” interfaces.
- Containerization: Reflect the use of Docker and docker-compose for streamlined development and deployment environments.

d. Relevant Technologies and Frameworks:
- Frontend: Svelte, Vite, Tailwind CSS, bun (JavaScript runtime)
- Backend: Python (with uv for environment management), various Python libraries as defined in requirements.txt.
- LLM Integrations: Using API keys for providers (OpenAI, Anthropic, etc.) via dedicated client modules.
- Tooling: Playwright for browser automation; Docker for containerization; GitHub actions (in .github directory) for CI/CD.

##### Detailed Steps for the Principal Software Engineer
- Lay out the core processing unit (devika.py and project orchestration) in the backend.
- Branch out from the core orchestrator with sub-components for each “agent” (action, answer, coder, etc.) in the agents module.
- Agents to the LLM integration module (src/llm) to represent calls to GPT-4, Claude, etc.
- Supporting modules like “memory”, “filesystem”, and “sandbox” next to the agents, showing that they supply auxiliary functionality.
- Lastly, incorporate containerization elements (Dockerfiles, Compose) to indicate the system deployment environment.
- Verify that each component is clearly labeled and that relevant integrations (e.g., API keys and endpoints) are noted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    UI["Frontend/UI"]:::frontend

    %% Core Backend Engine Subgraph
    subgraph "Core Backend Engine"
        CE1["devika.py"]:::backend
        CE2["src/project.py"]:::backend
        CE3["src/init.py"]:::backend
    end

    %% Agent Modules
    Agents["Agent Modules"]:::agent

    %% LLM Integration
    LLM["LLM Integration"]:::integration

    %% Memory & State Subgraph
    subgraph "Memory & State"
        M1["Memory Module"]:::backend
        M2["State Management"]:::backend
    end

    %% External Services
    ExtServices["External Services"]:::external

    %% Browser Automation
    Browser["Browser Automation"]:::external

    %% Filesystem Utility
    Filesys["Filesystem Utility"]:::external

    %% Sandbox Utility
    Sandbox["Sandbox Utility"]:::external

    %% Documentation
    Docs["Documentation"]:::external

    %% Containerization/Deployment Subgraph
    subgraph "Containerization/Deployment"
        C1["Devika Dockerfile"]:::container
        C2["App Dockerfile"]:::container
        C3["docker-compose"]:::container
        C4["Makefile"]:::container
    end

    %% Connections
    UI -->|"HTTP"| CE1

    CE1 -->|"orchestrates"| Agents
    CE1 -->|"delegates"| LLM
    CE1 -->|"updates"| M1
    CE1 -->|"updatesState"| M2
    CE1 -->|"integrates"| ExtServices
    CE1 -->|"triggers"| Browser
    CE1 -->|"reads"| Filesys
    CE1 -->|"executes"| Sandbox
    CE1 -->|"generates"| Docs
    CE1 -->|"deployedIn"| C1

    Agents -->|"callsLLM"| LLM
    Agents -->|"accessesMemory"| M1
    Agents -->|"accessesState"| M2
    Agents -->|"integrates"| ExtServices

    %% Click Events
    click UI "https://github.com/stitionai/devika/tree/main/ui"
    click CE1 "https://github.com/stitionai/devika/blob/main/devika.py"
    click CE2 "https://github.com/stitionai/devika/blob/main/src/project.py"
    click CE3 "https://github.com/stitionai/devika/blob/main/src/init.py"
    click Agents "https://github.com/stitionai/devika/tree/main/src/agents"
    click LLM "https://github.com/stitionai/devika/tree/main/src/llm"
    click M1 "https://github.com/stitionai/devika/tree/main/src/memory"
    click M2 "https://github.com/stitionai/devika/blob/main/src/state.py"
    click ExtServices "https://github.com/stitionai/devika/tree/main/src/services"
    click Browser "https://github.com/stitionai/devika/tree/main/src/browser"
    click Filesys "https://github.com/stitionai/devika/tree/main/src/filesystem"
    click Sandbox "https://github.com/stitionai/devika/tree/main/src/sandbox"
    click Docs "https://github.com/stitionai/devika/tree/main/src/documenter"
    click C1 "https://github.com/stitionai/devika/blob/main/devika.dockerfile"
    click C2 "https://github.com/stitionai/devika/blob/main/app.dockerfile"
    click C3 "https://github.com/stitionai/devika/blob/main/docker-compose.yaml"
    click C4 "https://github.com/stitionai/devika/tree/main/Makefile"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef backend fill:#ACE1AF,stroke:#000,stroke-width:1px;
    classDef agent fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef integration fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef container fill:#FFD700,stroke:#000,stroke-width:1px;
```
