# ahmedfaisal11/aios architecture

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

- Interactive diagram: https://gitdiagram.com/ahmedfaisal11/aios
- Repository: https://github.com/ahmedfaisal11/aios

## Overview

Key Components to Include:

##### Core System Layers (Top to Bottom)
- Agent Layer
- Different types of agents (MathAgent, RecAgent, TravelAgent, etc.)
- Agent configurations from agent_configs/

- AIOS Kernel Layer
- LLM Kernel (/aios/llm_kernel/)
- Command Parser & Executor (/aios/command_executor.py, command_parser.py)
- Context Management (/aios/context/)

- Resource Management Layer
- Scheduler (/aios/scheduler/)
- Memory Management (/aios/memory/)
- Storage System (/aios/storage/)

##### Supporting Components
- Utils System (/aios/utils/)
- External Integrations
- Different LLM Backends (GPT, Gemini, Bedrock, VLLM, etc.)
- External Tools & APIs

##### Use a Layered Architecture Pattern
- [Agents Layer]
- ↕️
- [AIOS Kernel Layer]
- ↕️
- [Resource Management Layer]
- ↕️
- [External Services/Tools]

##### Subsystems
- Memory Management:
- LRU-K replacement strategy
- Shared vs. Single memory systems

- Storage System:
- File storage
- Database storage

- Scheduler:
- FIFO and Round-Robin implementations
- Agent scheduling mechanisms

##### External Integrations
- Different LLM providers (GPT, Gemini, etc.)
- Tool integration points
- API connections

- Flow direction indicators
- Component type indicators

Level of Detail:
- Keep high-level architecture clear and visible
- Configuration points
- Extension points for future development

Remember to emphasize:

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef agent fill:#90EE90,stroke:#333,stroke-width:2px
    classDef kernel fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef resource fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px
    classDef utils fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Agent Layer
    subgraph AgentLayer["Agent Layer"]
        MathAgent["Math Agent"]:::agent
        RecAgent["Rec Agent"]:::agent
        TravelAgent["Travel Agent"]:::agent
        AcademicAgent["Academic Agent"]:::agent
        CreationAgent["Creation Agent"]:::agent
    end

    %% AIOS Kernel Layer
    subgraph KernelLayer["AIOS Kernel Layer"]
        LLMKernel["LLM Kernel"]:::kernel
        CmdParser["Command Parser"]:::kernel
        CmdExecutor["Command Executor"]:::kernel
        ContextMgmt["Context Management"]:::kernel
    end

    %% Resource Management Layer
    subgraph ResourceLayer["Resource Management Layer"]
        subgraph Scheduler["Scheduler"]
            FIFO["FIFO Scheduler"]:::resource
            RR["Round-Robin Scheduler"]:::resource
        end

        subgraph Memory["Memory Management"]
            LRUK["LRU-K Replacer"]:::resource
            SharedMem["Shared Memory"]:::resource
            SingleMem["Single Memory"]:::resource
        end

        subgraph Storage["Storage System"]
            FileStorage["File Storage"]:::resource
            DBStorage["Database Storage"]:::resource
        end
    end

    %% External Integrations
    subgraph ExternalLLMs["LLM Backends"]
        GPT["GPT"]:::external
        Gemini["Gemini"]:::external
        Bedrock["Bedrock"]:::external
        VLLM["VLLM"]:::external
        Ollama["Ollama"]:::external
        OpenLLM["OpenLLM"]:::external
    end

    %% Utils System
    subgraph Utils["Utils System"]
        Calculator["Calculator"]:::utils
        Logger["Logger"]:::utils
        Compressor["Compressor"]:::utils
        CmdUtils["Command Utils"]:::utils
    end

    %% Relationships
    AgentLayer --> KernelLayer
    KernelLayer --> ResourceLayer
    KernelLayer --> ExternalLLMs
    KernelLayer --> Utils

    %% Click Events
    click MathAgent "https://github.com/AhmedFaisal11/AIOS/blob/main/agent_configs/MathAgent_task.txt"
    click RecAgent "https://github.com/AhmedFaisal11/AIOS/blob/main/agent_configs/RecAgent_task.txt"
    click TravelAgent "https://github.com/AhmedFaisal11/AIOS/blob/main/agent_configs/TravelAgent_task.txt"
    click AcademicAgent "https://github.com/AhmedFaisal11/AIOS/blob/main/agent_configs/AcademicAgent_task.txt"
    click CreationAgent "https://github.com/AhmedFaisal11/AIOS/blob/main/agent_configs/CreationAgent_task.txt"
    
    click LLMKernel "https://github.com/AhmedFaisal11/AIOS/tree/main/aios/llm_kernel/"
    click CmdParser "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/command_parser.py"
    click CmdExecutor "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/command_executor.py"
    click ContextMgmt "https://github.com/AhmedFaisal11/AIOS/tree/main/aios/context/"
    
    click FIFO "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/scheduler/fifo_scheduler.py"
    click RR "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/scheduler/rr_scheduler.py"
    click LRUK "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/memory/lru_k_replacer.py"
    click SharedMem "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/memory/shared_memory.py"
    click SingleMem "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/memory/single_memory.py"
    click FileStorage "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/storage/file_storage.py"
    click DBStorage "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/storage/db_storage.py"
    
    click GPT "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/llm_kernel/llm_classes/gpt_llm.py"
    click Gemini "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/llm_kernel/llm_classes/gemini_llm.py"
    click Bedrock "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/llm_kernel/llm_classes/bed_rock.py"
    click VLLM "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/llm_kernel/llm_classes/vllm.py"
    click Ollama "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/llm_kernel/llm_classes/ollama_llm.py"
    click OpenLLM "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/llm_kernel/llm_classes/open_llm.py"
    
    click Calculator "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/utils/calculator.py"
    click Logger "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/utils/logger.py"
    click Compressor "https://github.com/AhmedFaisal11/AIOS/blob/main/aios/utils/compressor.py"
    click CmdUtils "https://github.com/AhmedFaisal11/AIOS/tree/main/aios/utils/commands/"
```
