Documentation Index
Fetch the complete documentation index at: https://raveculture-mintlify-api-spec-sync-1774445910.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Architecture
How Agentbot is built. A reference for contributors, self-hosters, and anyone who wants to understand the system.
System Overview
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USERS β
β Telegram Β· Discord Β· WhatsApp Β· Web Dashboard β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
ββββββββΌβββββββ
β VERCEL β
β Next.js 16 β
β (Frontend) β
ββββββββ¬βββββββ
β
ββββββββββββββΌβββββββββββββ
β β β
ββββββββΌβββββββ ββββΌββββ ββββββββΌβββββββ
β RENDER β βRedis β β Neon PG β
β Backend β βCache β β Database β
β (Express) β β β β β
ββββββββ¬βββββββ ββββββββ βββββββββββββββ
β
βββββββββββΌββββββββββ
β β β
βββββΌββββ ββββΌβββ ββββββΌβββββ
βWorker β βOllamaβ β A2A β
βServiceβ β AI β β Bus β
βββββββββ βββββββ βββββββββββ
Components
Frontend (Vercel)
Stack: Next.js 16 (App Router) + React 19 + Tailwind CSS v4
The web dashboard, onboarding flow, billing, and all user-facing pages. Deployed on Vercel with automatic Git-based deploys.
Key directories:
web/app/ β Pages and API routes
web/app/api/ β Server-side API proxies (provision, billing, auth)
web/app/components/ β Shared UI components
web/app/lib/ β Utilities (auth, Stripe, security)
Backend (Render)
Stack: Express.js + TypeScript
The core API server. Handles agent provisioning, deployments, A2A communication, and skill management.
Key services:
POST /api/provision β Create new agents (public, no auth)
POST /api/deployments β Deploy agent containers (auth required)
GET /api/agents β List and manage agents
POST /api/ai/* β AI provider proxy (OpenRouter, Anthropic, etc.)
GET /api/browse/* β File explorer (tree, read, write, git sync)
GET /api/logs/:agentId/stream β Live log tail (SSE)
GET /api/usage/* β Usage tracking (tokens, costs, tool metrics)
Protected endpoints use JWT auth middleware that verifies the token, attaches user context, and sets the RLS context on the database connection. See the auth API for details.
Worker service (Render)
A standalone background job processor built on BullMQ. It connects to the same Redis instance used by the backend and processes jobs from two queues:
| Queue | Job types | Concurrency |
|---|
tasks | scheduled-task β cron jobs per agent | 5 |
| skill-execution β run a skill on behalf of an agent | |
provision | new-agent β provision a new agent asynchronously | 2 |
The worker also handles:
- A2A message routing between agents
- Webhook processing (Stripe, Telegram, Discord)
The worker listens for SIGTERM and drains in-flight jobs before shutting down.
Database (Neon PostgreSQL)
Stores:
- User accounts and authentication
- Agent configurations and metadata
- Billing, subscriptions, and usage tracking
- Skill marketplace data
- A2A message history
All user-scoped tables are protected by PostgreSQL row-level security (RLS) policies. Each authenticated request sets a database-level user context so queries automatically return only the calling userβs data. Admin users bypass RLS and can access all rows. See Security for the full list of protected tables.
Cache (Redis)
Used for:
- Rate limiting
- Session management
- Real-time agent status
- A2A message queues
- Webhook deduplication
AI Layer (Ollama + BYOK)
Two modes:
- Ollama (self-hosted): Local inference for self-hosted deployments (Llama 3, Mistral)
- BYOK: Users bring their own API keys for OpenRouter, Anthropic, OpenAI, Google, or Groq
Watchdog
Monitors agent gateway processes for health and auto-recovers from failures:
| Capability | Details |
|---|
| Health checks | Every 2 minutes (configurable via WATCHDOG_CHECK_INTERVAL) |
| Crash detection | Listens for gateway exit events |
| Crash-loop detection | 3 crashes in 5-minute window |
| Auto-repair | Kill β wait 5s β restart β verify health (max 2 attempts) |
| Notifications | Telegram + Discord alerts for crashes, repairs, and recovery |
| Degraded state | 5-second retry interval when health check fails |
See Watchdog for the full API.
File Explorer + Git Sync
Browser-based workspace management β no SSH needed:
- File tree: Recursive directory listing with depth control
- Read/Write: View and edit files inline (1MB limit)
- Git status: See uncommitted changes
- Git diff: Per-file or full workspace diffs
- Git sync: One-click commit + push to GitHub
- Git log: Browse recent commit history
See File Explorer API for the full API.
Usage Tracker
SQLite-backed token and cost tracking per agent, model, and time period:
- Per-event recording (session, agent, provider, model, tokens, cost)
- Daily aggregation with upsert
- Tool event monitoring (success rate, duration)
- Query APIs: summary, by-agent, by-model, daily totals
See Usage Tracking API for the full API.
A2A Bus (Agent-to-Agent)
Enables agents to communicate directly:
- Request/response patterns
- Fire-and-forget messages
- Skill delegation between agents
- Cross-tenant isolation enforced
Data Flow: Agent Provisioning
User fills form (frontend)
β
βΌ
POST /api/provision (Vercel)
β
βΌ
POST /api/provision (Render backend)
β
βββ Validate input (plan, provider, tokens)
βββ Generate userId + agentId
βββ Store config in PostgreSQL
βββ Allocate port + subdomain
βββ Deploy Docker container
βββ Configure Caddy reverse proxy
β
βΌ
Return agent URL + stream key to user
Data Flow: Agent Runtime
User sends message (Telegram/Discord/WhatsApp)
β
βΌ
Webhook β Worker Service
β
βββ Route to correct agent container
βββ Load agent config + memory
βββ Execute skills if needed
βββ Call AI provider (BYOK or Ollama)
βββ Check A2A bus for delegated tasks
β
βΌ
Response sent back to user
Self-Hosting
Agentbot is fully open source. To self-host:
- Frontend: Deploy
web/ to Vercel or any Next.js-compatible host
- Backend: Run
agentbot-backend/ on any Docker-capable server
- Worker: Run the worker entry point from
agentbot-backend/ using Dockerfile.worker
- Database: Neon Postgres (free tier available) or any PostgreSQL 15+
- Redis: Any Redis 7+ instance
- AI: Ollama for local inference, or configure BYOK providers
See Installation for full setup instructions.
Tech Decisions
| Choice | Why |
|---|
| Next.js 16 | App Router, server components, Vercel-native DX |
| Express (not serverless) | Long-running agent processes need persistent connections |
| Neon Postgres | Serverless, scales to zero, generous free tier |
| Redis | Fast rate limiting and session management |
| Docker | Isolated agent environments per user |
| BYOK over reselling | Users pay providers directly β no markup, no lock-in |
| Base (not Ethereum) | Low fees, fast finality, Coinbase ecosystem |