# uraniumcorporation/maiar-ai architecture

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

- Interactive diagram: https://gitdiagram.com/uraniumcorporation/maiar-ai
- Repository: https://github.com/uraniumcorporation/maiar-ai

## Overview

##### Project Type & Purpose
- MAIAR is a composable, plugin-based AI agent framework. Its core idea is to split an AI agent’s functionality into modular steps (data ingestion/triggers, decision-making, and action execution) orchestrated by a dynamic runtime.
- The project is set up as a monorepo with several packages handling core logic, memory providers, model providers, monitor providers, and a host of plugins (e.g., terminal, text, Discord, etc.). There’s also a client (“maiar-client”) for a frontend interface and a “maiar-starter” as an example integration.

##### Analyzing the File Structure
- Top-Level Structure: Notice directories and files such as:
– “packages/”: Contains sub-packages like “core”, “memory-filesystem”, “memory-sqlite”, “model-openai”, “monitor-console”, and various “plugin-*” packages.
– “maiar-client”: A frontend folder, built with React and Vite (App.tsx, components, theme), representing the interactive interface of the system.
– “maiar-starter”: A reference implementation using Express and demonstrating how the core packages integrate.
– “.github”, “website”, and configuration files serve development, CI, and documentation roles.
- This separation suggests a layered architecture: a core runtime with pluggable components, several integration providers, and distinct frontend & starter application layers.

##### Key Architectural Components
- Core Runtime & Orchestration:
– Represents the central engine found in “packages/core”, which dynamically builds execution pipelines from triggers to actions using a “context chain” mechanism.
- Plugin Framework:
– Individual plugins (organized in separate packages such as plugin-terminal, plugin-text, plugin-discord, etc.) encapsulate specific triggers and actions.
- Providers & External Dependencies:
– Model Providers (e.g., Model OpenAI, Model Ollama) abstract the AI models used for decision making.
– Memory Providers (SQLite, Postgres, Filesystem) abstract persistence for conversation context.
– Monitor Providers (e.g., ConsoleMonitor, WebSocketMonitor) offer logging and debugging capabilities.
- Client & Starter Application:
– “maiar-client” is the user frontend providing interaction with the agent.
– “maiar-starter” demonstrates how to consume the core libraries and plugin ecosystem.
- Development & Build Tools:
– The presence of tools like pnpm, turbo, and lerna indicate a well-structured monorepo supporting continuous development and deployment.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Core Layer
    trigger["External Triggers"]:::dev
    CR["Core Runtime Engine"]:::core

    trigger -->|"triggers"| CR

    %% Plugin Layer
    subgraph "Plugin Layer"
        PT["Plugin Terminal"]:::plugin
        PText["Plugin Text"]:::plugin
        PD["Plugin Discord"]:::plugin
        PE["Plugin Express"]:::plugin
        PC["Plugin Character"]:::plugin
        PI["Plugin Image"]:::plugin
        PS["Plugin Search"]:::plugin
        PTel["Plugin Telegram"]:::plugin
        PTi["Plugin Time"]:::plugin
        PWS["Plugin WebSocket"]:::plugin
        PX["Plugin X"]:::plugin
    end

    %% Provider Modules
    subgraph "Providers"
        subgraph "Memory Providers"
            MFS["Filesystem Provider"]:::provider
            MSQ["SQLite Provider"]:::provider
            MPG["Postgres Provider"]:::provider
        end
        subgraph "Model Providers"
            MOAI["Model OpenAI Provider"]:::provider
            MOLLA["Model Ollama Provider"]:::provider
        end
        subgraph "Monitor Providers"
            CMon["Console Monitor"]:::provider
            WSMon["WebSocket Monitor"]:::provider
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        client["Maiar Client"]:::client
        starter["Maiar Starter"]:::client
    end

    %% Development & Build Tools
    subgraph "Dev & Build Tools"
        devTools["Monorepo Config & CI/CD (lerna.json, pnpm-workspace.yaml, turbo.json, .github/workflows)"]:::dev
    end

    %% Connections from Core Runtime to Plugins
    CR -->|"invokes"| PT
    CR -->|"invokes"| PText
    CR -->|"invokes"| PD
    CR -->|"invokes"| PE
    CR -->|"invokes"| PC
    CR -->|"invokes"| PI
    CR -->|"invokes"| PS
    CR -->|"invokes"| PTel
    CR -->|"invokes"| PTi
    CR -->|"invokes"| PWS
    CR -->|"invokes"| PX

    %% Connections from Core Runtime to Providers
    CR -->|"stores/queries"| MFS
    CR -->|"stores/queries"| MSQ
    CR -->|"stores/queries"| MPG

    CR -->|"calls"| MOAI
    CR -->|"calls"| MOLLA

    CR -->|"monitors"| CMon
    CR -->|"monitors"| WSMon

    %% Connections from Applications to Core
    client -->|"interfaces"| CR
    starter -->|"interfaces"| CR

    %% External Service Connection
    openAI["OpenAI API"]:::external
    MOAI -->|"callsAPI"| openAI

    %% Connection from Dev Tools to Core (build & deploy)
    devTools ---|"supports"| CR

    %% Styles
    classDef core fill:#f4d03f,stroke:#333,stroke-width:2px;
    classDef plugin fill:#85c1e9,stroke:#333,stroke-width:2px;
    classDef provider fill:#82e0aa,stroke:#333,stroke-width:2px;
    classDef client fill:#d2b4de,stroke:#333,stroke-width:2px;
    classDef dev fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef external fill:#d1f2eb,stroke:#333,stroke-width:2px;

    %% Click Events
    click CR "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/core"
    click PT "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-terminal"
    click PText "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-text"
    click PD "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-discord"
    click PE "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-express"
    click PC "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-character"
    click PI "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-image"
    click PS "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-search"
    click PTel "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-telegram"
    click PTi "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-time"
    click PWS "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-websocket"
    click PX "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/plugin-x"
    click MFS "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/memory-filesystem"
    click MSQ "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/memory-sqlite"
    click MPG "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/memory-postgres"
    click MOAI "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/model-openai"
    click MOLLA "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/model-ollama"
    click CMon "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/monitor-console"
    click WSMon "https://github.com/uraniumcorporation/maiar-ai/tree/main/packages/monitor-websocket"
    click client "https://github.com/uraniumcorporation/maiar-ai/tree/main/maiar-client"
    click starter "https://github.com/uraniumcorporation/maiar-ai/tree/main/maiar-starter"
    click devTools "https://github.com/uraniumcorporation/maiar-ai/blob/main/lerna.json"
```
