How rob2025tech/ai-agent-platform-starter works
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: main.py FastAPI app · execution_service.py Execution service · execute.py Execute endpoint · skill_service.py Skill service
Components 20
HTTP API
- FastAPI app
apps/api/main.py - Execute endpoint · POST /execute boundary.
apps/api/routers/execute.py - Health endpoint · Runtime liveness boundary.
apps/api/routers/health.py - Auth routes
apps/api/routers/auth.py - Butterbase routes
apps/api/routers/butterbase.py - HTTP contracts · Validated execution request and normalized response models.
apps/api/models/request_models.py
Execution Core
- Execution service · Resolves a backend, invokes it, and shapes results.
apps/api/services/execution_service.py - Adapter registry · Contains backend selection and availability behavior.
apps/api/adapters/registry.py - Adapter contract · Uniform model-backend interface.
apps/api/adapters/base_adapter.py - Model adapters · Mock, Ollama, Cerebras, OpenAI, and Snowflake backends.
apps/api/adapters/ollama_adapter.py
State & Memory
- Conversation service
apps/api/services/conversation_service.py - Conversation repository · Persistence access behind the repository contract.
apps/api/repositories/conversation_repository.py - Memory service · Application-facing contextual memory operations.
apps/api/services/memory_service.py - Memory manager · Selects and coordinates memory implementations.
apps/api/memory/memory_manager.py - Memory implementations · In-memory and Mem0 implementations share a contract.
apps/api/memory/base_memory.py
Extensions
- Skill service · Orchestration boundary for agent capabilities.
apps/api/services/skill_service.py - Skill registry & router · Resolves and dispatches registered skills.
apps/api/skills/registry.py - Tool registry · Registered tools implement the common tool contract.
apps/api/tools/registry.py
Provider Boundaries
- Butterbase client
apps/api/providers/butterbase/client.py - Inference services · Local Ollama plus optional hosted provider APIs.
Connections 18
- 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