# rob2025tech/ai-agent-platform-starter architecture

> Architecture diagram of the GitHub repository rob2025tech/ai-agent-platform-starter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rob2025tech/ai-agent-platform-starter
- Repository: https://github.com/rob2025tech/ai-agent-platform-starter

## Overview

#### Purpose and Runtime

This is a Python 3.11 AI-agent API starter built around FastAPI/Uvicorn. Its primary contract is `POST /execute`: accept a prompt and selected backend, invoke an LLM/provider adapter, and return a normalized response. Start at `apps/api/main.py` with `uvicorn apps.api.main:app --reload`; health is exposed separately.

#### API Composition and Entry Points

`apps/api/main.py` constructs the FastAPI application and mounts route modules. The principal HTTP boundaries are:
- `apps/api/routers/execute.py` — prompt execution endpoint.
- `apps/api/routers/health.py` — runtime liveness endpoint.
- `apps/api/routers/auth.py` and `apps/api/routers/butterbase.py` — authentication and Butterbase-facing API surfaces.

Request/response contracts are centralized in `apps/api/models/request_models.py` and `apps/api/models/response_models.py`, isolating HTTP schemas from execution internals.

#### Execution Orchestration

`apps/api/services/execution_service.py` is the core control-flow coordinator. It receives validated execution input, resolves the requested model backend, invokes it, and shapes the execution result consumed by the router. This is the primary boundary between API concerns and provider-specific behavior.

Backend selection is delegated to `apps/api/adapters/registry.py`, rather than being embedded in route handlers. Unsupported or unavailable backend behavior should remain contained at this service/registry boundary.

#### Model Adapter Layer

`apps/api/adapters/base_adapter.py` defines the common backend interface. Concrete implementations translate that interface to external or local inference systems:
- `apps/api/adapters/mock_adapter.py` supports deterministic local development/testing.
- `apps/api/adapters/ollama_adapter.py` calls local Ollama, expected at its standard local service endpoint.
- `apps/api/adapters/cerebras_adapter.py` and `apps/api/adapters/openai_adapter.py` integrate hosted LLM APIs.
- `apps/api/adapters/snowflake_adapter.py` provides a Snowflake-oriented backend.

Adapters are the external-service boundary: credentials, SDK/HTTP behavior, provider payloads, and provider-specific failures belong here, while callers retain a uniform execution contract.

#### Conversation, Storage, and Memory

Conversation state is separated into repository and service layers:
- `apps/api/repositories/base_repository.py` and `apps/api/repositories/conversation_repository.py` define persistence access.
- `apps/api/services/conversation_service.py` coordinates conversation operations.
- `apps/api/services/storage_service.py` abstracts storage-related work.

Memory is independently pluggable:
- `apps/api/memory/base_memory.py` defines the memory contract.
- `apps/api/memory/in_memory.py` is an ephemeral implementation.
- `apps/api/memory/mem0_memory.py` integrates Mem0.
- `apps/api/memory/memory_manager.py` selects/coordinates memory implementations, with `apps/api/services/memory_service.py` providing application-facing operations.

This separation permits execution to add contextual memory without coupling it to a particular persistence engine.

#### Skills and Tools Extension Boundary

Skills provide a higher-level agent capability layer:
- `apps/api/skills/skill.py` defines skill behavior.
- `apps/api/skills/registry.py` resolves registered skills.
- `apps/api/skills/router.py` routes skill invocation.

Tools follow a parallel registry pattern in `apps/api/tools/base_tool.py` and `apps/api/tools/registry.py`. `apps/api/services/skill_service.py` is the likely orchestration boundary for exposing skills to execution flows. These modules are designed extension points; new capabilities should register through them rather than alter provider adapters or HTTP routes directly.

#### Configuration and Provider Integrations

`apps/api/config/settings.py` centralizes environment-driven configuration, including optional provider credentials. Provider-specific clients are grouped independently of adapters:
- `apps/api/providers/butterbase/client.py`
- `apps/api/providers/evermind/client.py`
- `apps/api/providers/nebius/client.py`

This indicates integrations beyond direct LLM inference, with routers/services retaining responsibility for deciding when to use those clients. Local Ollama is the baseline runtime dependency; Cerebras and other hosted providers are optional and credential-gated.

Main entry points: [`apps/api/main.py`](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/main.py) (FastAPI app), [`apps/api/services/execution_service.py`](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/execution_service.py) (Execution service), [`apps/api/routers/execute.py`](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/execute.py) (Execute endpoint), [`apps/api/services/skill_service.py`](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/skill_service.py) (Skill service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["FastAPI app<br/>[main.py]"]
  node_execute_route["Execute endpoint<br/>router<br/>[execute.py]"]
  node_health_route["Health endpoint<br/>router<br/>[health.py]"]
  node_auth_route["Auth routes<br/>router<br/>[auth.py]"]
  node_butterbase_route["Butterbase routes<br/>router<br/>[butterbase.py]"]
  node_contracts["HTTP contracts<br/>schemas<br/>[request_models.py]"]
end

subgraph group_execution["Execution Core"]
  node_execution_service{{"Execution service<br/>orchestrator"}}
  node_adapter_registry["Adapter registry<br/>[registry.py]"]
  node_adapter_contract["Adapter contract<br/>interface<br/>[base_adapter.py]"]
  node_model_adapters["Model adapters<br/>adapter implementations<br/>[ollama_adapter.py]"]
end

subgraph group_state["State &amp; Memory"]
  node_conversation_service["Conversation service"]
  node_conversation_repository[("Conversation repository")]
  node_memory_service["Memory service<br/>[memory_service.py]"]
  node_memory_manager["Memory manager<br/>[memory_manager.py]"]
  node_memory_contract["Memory implementations<br/>memory backends<br/>[base_memory.py]"]
end

subgraph group_extensions["Extensions"]
  node_skill_service["Skill service<br/>[skill_service.py]"]
  node_skill_registry["Skill registry &amp; router<br/>extension registry<br/>[registry.py]"]
  node_tool_registry["Tool registry<br/>extension registry<br/>[registry.py]"]
end

subgraph group_providers["Provider Boundaries"]
  node_butterbase_client["Butterbase client<br/>provider client<br/>[client.py]"]
  node_inference_services(("Inference services<br/>external LLMs"))
end

node_app -->|"mounts"| node_execute_route
node_app -->|"mounts"| node_health_route
node_app -->|"mounts"| node_auth_route
node_app -->|"mounts"| node_butterbase_route
node_execute_route -->|"validates / returns"| node_contracts
node_execute_route -->|"executes prompt"| node_execution_service
node_execution_service -->|"resolves backend"| node_adapter_registry
node_adapter_registry -->|"selects implementation"| node_adapter_contract
node_adapter_contract -->|"implemented by"| node_model_adapters
node_model_adapters -->|"calls"| node_inference_services
node_execution_service -.->|"adds context"| node_memory_service
node_memory_service -->|"uses"| node_memory_manager
node_memory_manager -->|"selects"| node_memory_contract
node_conversation_service -->|"persists conversations"| node_conversation_repository
node_execution_service -.->|"exposes capabilities"| node_skill_service
node_skill_service -->|"invokes skill"| node_skill_registry
node_skill_service -->|"uses tools"| node_tool_registry
node_butterbase_route -->|"uses"| node_butterbase_client

click node_app "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/main.py"
click node_execute_route "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/execute.py"
click node_health_route "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/health.py"
click node_auth_route "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/auth.py"
click node_butterbase_route "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/butterbase.py"
click node_contracts "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/models/request_models.py"
click node_execution_service "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/execution_service.py"
click node_adapter_registry "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/adapters/registry.py"
click node_adapter_contract "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/adapters/base_adapter.py"
click node_model_adapters "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/adapters/ollama_adapter.py"
click node_conversation_service "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/conversation_service.py"
click node_conversation_repository "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/repositories/conversation_repository.py"
click node_memory_service "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/memory_service.py"
click node_memory_manager "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/memory/memory_manager.py"
click node_memory_contract "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/memory/base_memory.py"
click node_skill_service "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/skill_service.py"
click node_skill_registry "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/skills/registry.py"
click node_tool_registry "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/tools/registry.py"
click node_butterbase_client "https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/providers/butterbase/client.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_execute_route,node_health_route,node_auth_route,node_butterbase_route,node_contracts toneBlue
class node_execution_service,node_adapter_registry,node_adapter_contract,node_model_adapters toneAmber
class node_conversation_service,node_conversation_repository,node_memory_service,node_memory_manager,node_memory_contract toneMint
class node_skill_service,node_skill_registry,node_tool_registry toneRose
class node_butterbase_client,node_inference_services toneIndigo
```

## Components

### HTTP API

- [FastAPI app](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/main.py): application · `apps/api/main.py`
- [Execute endpoint](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/execute.py): router · POST /execute boundary. · `apps/api/routers/execute.py`
- [Health endpoint](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/health.py): router · Runtime liveness boundary. · `apps/api/routers/health.py`
- [Auth routes](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/auth.py): router · `apps/api/routers/auth.py`
- [Butterbase routes](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/routers/butterbase.py): router · `apps/api/routers/butterbase.py`
- [HTTP contracts](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/models/request_models.py): schemas · Validated execution request and normalized response models. · `apps/api/models/request_models.py`

### Execution Core

- [Execution service](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/execution_service.py): orchestrator · Resolves a backend, invokes it, and shapes results. · `apps/api/services/execution_service.py`
- [Adapter registry](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/adapters/registry.py): registry · Contains backend selection and availability behavior. · `apps/api/adapters/registry.py`
- [Adapter contract](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/adapters/base_adapter.py): interface · Uniform model-backend interface. · `apps/api/adapters/base_adapter.py`
- [Model adapters](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/adapters/ollama_adapter.py): adapter implementations · Mock, Ollama, Cerebras, OpenAI, and Snowflake backends. · `apps/api/adapters/ollama_adapter.py`

### State & Memory

- [Conversation service](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/conversation_service.py): service · `apps/api/services/conversation_service.py`
- [Conversation repository](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/repositories/conversation_repository.py): repository · Persistence access behind the repository contract. · `apps/api/repositories/conversation_repository.py`
- [Memory service](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/memory_service.py): service · Application-facing contextual memory operations. · `apps/api/services/memory_service.py`
- [Memory manager](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/memory/memory_manager.py): manager · Selects and coordinates memory implementations. · `apps/api/memory/memory_manager.py`
- [Memory implementations](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/memory/base_memory.py): memory backends · In-memory and Mem0 implementations share a contract. · `apps/api/memory/base_memory.py`

### Extensions

- [Skill service](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/services/skill_service.py): service · Orchestration boundary for agent capabilities. · `apps/api/services/skill_service.py`
- [Skill registry & router](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/skills/registry.py): extension registry · Resolves and dispatches registered skills. · `apps/api/skills/registry.py`
- [Tool registry](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/tools/registry.py): extension registry · Registered tools implement the common tool contract. · `apps/api/tools/registry.py`

### Provider Boundaries

- [Butterbase client](https://github.com/rob2025tech/ai-agent-platform-starter/blob/main/apps/api/providers/butterbase/client.py): provider client · `apps/api/providers/butterbase/client.py`
- **Inference services**: external LLMs · Local Ollama plus optional hosted provider APIs.

## Connections

- FastAPI app → Execute endpoint: mounts
- FastAPI app → Health endpoint: mounts
- FastAPI app → Auth routes: mounts
- FastAPI app → Butterbase routes: mounts
- Execute endpoint → HTTP contracts: validates / returns
- Execute endpoint → Execution service: executes prompt
- Execution service → Adapter registry: resolves backend
- Adapter registry → Adapter contract: selects implementation
- Adapter contract → Model adapters: implemented by
- Model adapters → Inference services: calls
- Execution service → Memory service: adds context
- Memory service → Memory manager: uses
- Memory manager → Memory implementations: selects
- Conversation service → Conversation repository: persists conversations
- Execution service → Skill service: exposes capabilities
- Skill service → Skill registry & router: invokes skill
- Skill service → Tool registry: uses tools
- Butterbase routes → Butterbase client: uses
