How agno-agi/agent-api works
Project type and purpose
• This is a backend‐only, containerized API service (“Simple Agent API”) whose sole responsibility is to host and expose conversational “Agents” (chatbots) over HTTP.
• It uses FastAPI as the web framework, PostgreSQL for persistence, and a suite of Python “Agents” that delegate to external AI services (e.g., OpenAI’s GPT).
File structure
• Top level:
• Dockerfile & compose.yaml – container image build and multi‐container orchestration (FastAPI + PostgreSQL).
• scripts/ – build, validate, format, entrypoint, and dev setup helpers.
• providers of environment config: example.env, .env, pyproject.toml, requirements.txt.
• agents/ – individual agent implementations (agno_assist, finance_agent, web_agent) plus a selector module.
• api/ – FastAPI entrypoint (main.py), router definitions (routes/), settings module.
• db/ – database URL and session setup.
README for additional insights
• Confirms FastAPI on port 8000, PostgreSQL on port 5432.
• Explains prebuilt agents that combine local logic with external APIs (web search, finance, Agno knowledge base).
• Describes local development (uv + scripts/dev_setup.sh) and Docker Compose for deployment, plus production workflows (build_image.sh, push to registry, deploy to Cloud Run/ECS/GKE, etc.).
a. Main components:
• Client(s): Swagger UI (localhost:8000/docs), Agno Playground or any HTTP client.
• FastAPI Application:
– Routers: /agents, /health, /playground, /v1_router
– Settings loader
– Uvicorn ASGI server
• Agents Layer:
– agno_assist, finance_agent, web_agent (and selector logic)
– Each agent may call: OpenAI API, YFinance API, Web search API, or internal knowledge‐base loader.
• Database Layer: PostgreSQL
– db.session for ORM sessions (likely SQLAlchemy)
– db.url for connection strings
• External Services:
– OpenAI (or other LLM provider)
– YFinance, Web Search endpoints
• Container Orchestration: Docker Compose (FastAPI container + Postgres container)
b. Relationships and data flows:
1. Client → FastAPI (HTTP)
2. FastAPI routes dispatch to agent selector → specific agent module
3. Agent module:
– May read/write state to PostgreSQL via db.session
– May call external endpoints (OpenAI, YFinance, Web Search)
4. FastAPI returns HTTP response to Client
c. Architectural patterns and principles:
• Layered architecture: Presentation (HTTP/Routers), Domain/Business (Agent logic), Persistence (DB), Integration (External APIs).
• Dependency Injection: FastAPI’s settings and DB session in request scope.
• Containerized micro-service: single service with its own DB container.
d. Key technologies and frameworks:
• Python 3.x, FastAPI, Uvicorn
• SQLAlchemy or similar via db.session
• Docker & Docker Compose
• External APIs: OpenAI, YFinance, Web Search
Detail to capture
• Api/routes sub‐system under “FastAPI” to indicate modular endpoints.
• How /agents routes use a Selector to pick which agent implementation to run.
• Session lifecycle: client request → new DB session → commit/close.