How thomas-de-oliveira/agentkit works
Project Type & Purpose
• This is a full-stack application aimed at helping developers experiment with and build production-grade Agent apps.
• The backend provides APIs for processing agents’ actions, mediating between multiple tools (SQL, PDF ingestion, summarization, visualization, etc.), and ensuring reliability via pre-configured action plans.
• The frontend is a React/Next.js chat interface that renders streamed results, interactive UIs (like conversation views, feedback components, and authentication), and connects to backend APIs.
• The overall design emphasizes modularity (pluggable tools, configurable agents), scalability (Docker deployment, asynchronous task handling with Celery/Redis), and a clear separation between UI and service layers.
Analysis of the File Structure
• Top Level: Directories like “backend” and “frontend” clearly indicate a split between server-side and client-side code.
• Backend:
• Contains a detailed “app” folder with subdirectories:
▪ “api” — versioned REST API endpoints (v1) for chat, SQL queries, statistics, etc.
▪ “services” — housing the “chat_agent” with a meta agent concept, tool libraries (including implementations for SQL, PDF, image generation, summarizer, etc.), and helper modules.
▪ “config” and “core” — configuration files and core modules like FastAPI configurations, Celery integration, and database sessions (SQLDatabaseExtended, vector DB ingestion).
▪ “db” and “models” — managing database interactions, including migrations and ORM models.
• Inclusion of alembic directories shows database migration handling.
• Dockerfile and poetry configuration files indicate containerization and dependency management.
• Frontend:
• Uses Next.js with “src” containing API clients, components (conversation view, code view, dashboards, etc.), hooks, state management with stores, and global theming (tailwind/daisyUI).
• Cypress and Jest configurations for testing UI behavior.
• Configuration files (.env, Dockerfile, etc.) ensuring smooth integration with the backend.
• Deployment & DevOps:
• Docker Compose files (for demo, development, and production) provide details about how the containers come together.
• GitHub Actions workflows and pre-commit hooks for linting, tests, and CI/CD pipelines.
a. Main Components:
• Client / Frontend: Next.js user interface with modules for chat, authentication, and interactive views.
• API Gateway: Next.js API routes (and also FastAPI endpoints if both ways are used) handling incoming requests.
• Backend Service (FastAPI):
• REST API layer for endpoints (chat, SQL, statistics).
• Agent Logic: The Meta Agent that selects and routes action plans.
• Tools & Services: The library of agent tools (SQL tool, PDF ingestion tool, summarizer, etc.) and parallel action execution.
• Task Queue: Celery (with Redis as the broker) for managing long-running or asynchronous operations.
• Database Layer: Database integrations (local Postgres with pgvector, Chinook sample database) and ORM models.
• External Integrations:
• OpenAI API for LLM functionalities.
• Possibly caching/monitoring services.
• Infrastructure:
• Docker & Docker Compose for container orchestration.
• CI/CD pipelines (GitHub Actions) for linting and testing.
b. Relationships & Interactions:
• The Frontend interacts with the Backend’s REST API endpoints via HTTP/HTTPS requests.
• The FastAPI backend receives requests and uses the Meta Agent to select the proper action plan and tools.
• Asynchronous tasks (managed via Celery and brokered through Redis) are used for long-running operations.
• The backend connects to the Database for persistent storage and query operations.
• Configuration files and environment variables set the operational parameters, and external API calls (e.g., to OpenAI) are integrated in the workflow.
c. Architectural Patterns & Design Principles:
• Separation of concerns: Clear division between frontend and backend.
• Modular design: The structure supports plugging in different “tools” that the agent can execute.
• Routing and constrained decision architecture: The use of a Meta Agent combined with pre-configured action plans ensures controlled flows.
• Asynchronous task management: Use of Celery and Redis to handle non-blocking operations.
• Layered Architecture: Controllers (FastAPI endpoints) -> Services (agent tools, meta agent, business logic) -> Data Access Layer (ORM and migration scripts).
d. Key Technologies, Frameworks, & Libraries:
• Frontend: Next.js 14, React, Tailwind CSS, daisyUI.
• Backend: Python (3.10+), FastAPI, sqlmodel/pydantic, LangChain integration.
• Messaging/Task queue: Celery with Redis.
• Database: PostgreSQL (with pgvector), Chinook sample database.
• Containerization: Docker and Docker Compose.
• CI/CD: GitHub Actions workflows.