AI Agents Alfa is a multi-agent retrieval-augmented generation (RAG) playground tailored for educational and experimentation purposes. The project combines a FastAPI backend, a Next.js frontend, and a PostgreSQL + pgvector persistence layer to let you ingest documents, route questions through specialized agents, and experiment with different large language model (LLM) providers.
- FastAPI backend that provisions default agents, users, and access control lists for rapid demos.
- Document ingestion pipeline with OCR/HTML parsing, chunking, and pgvector-powered semantic search.
- Chat orchestration layer that can call OpenAI, DeepSeek, Google Gemini (Vertex), and xAI Grok models with automatic fallback logic.
- Next.js client for authentication, agent switching, and chat sessions against the backend.
- Docker Compose stack for running PostgreSQL, the backend (with debugpy enabled), and the frontend in one command.
backend/– FastAPI application (app/main.py) plus agents, RAG utilities, and provider integrations.frontend/– Next.js app located underapp/with simple login + chat UI.db/init/– Database bootstrap scripts (pgvector extension).docker-compose.yml– Local stack definition for database, backend, and frontend services..env.example– Sample environment configuration for local experiments.
- Docker Desktop (or Docker Engine + Docker Compose plugin) or
- Python 3.13+, Node.js 20+, and PostgreSQL 15+ if running services manually.
- Copy the sample environment file and adjust secrets:
At minimum, set
cd D:\Projects\EDUARDO\REPOS\DLV1 copy .env.example .env
OPENAI_API_KEY(and any other provider keys you intend to use). Replace demo credentials inAUTH_USERS,AUTH_TOKEN_SECRET, andAPI_KEYif you do not want to rely on the defaults frombackend/app/defaults.py. - Launch the stack:
docker compose up --build - Once the containers are healthy:
- Backend REST API: http://localhost:18000 (interactive docs at
/docs). - Frontend UI: http://localhost:13000.
- Backend REST API: http://localhost:18000 (interactive docs at
- Sign in using one of the auto-seeded demo accounts (username → password):
owner→ownerpassdemo→demo123admin-local→local123admin-intl→intl123admin-logistics→logistics123
The backend automatically creates the database schema, loads the default agents (local regulations, international regulations, logistics, litigation), and assigns access control lists on startup.
- Create and activate a virtual environment with Python 3.13+.
- Install dependencies:
cd backend pip install -e .
- Provision PostgreSQL with pgvector enabled and export
DATABASE_URL,OPENAI_API_KEY, and any other provider-specific keys. - Run the API:
The startup lifecycle calls
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
init_db()which creates tables if they do not exist and seeds default principals/agents.
- Install dependencies:
cd frontend npm install - Start the dev server:
npm run dev
- Ensure
NEXT_PUBLIC_API_BASEpoints to the backend (http://localhost:8000orhttp://localhost:18000if using Docker).
- Document ingestion –
POST /documents/uploadaccepts PDF, DOCX, PPTX, RTF, or HTML files, performs parsing/OCR, and stores chunks in Postgres. Additional routes provide page maps, consolidated context, verification, and exports. - Chat –
POST /chat/askroutes questions through the selected agent (agentfield) and LLM provider (providerfield). Retrieval is handled byapp.rag.search_chunks. - Agents –
GET /agentslists available agents; access is filtered by the authenticated user’s ACL. - Auth –
POST /auth/loginissues JWT tokens backed byAUTH_TOKEN_SECRET. Use/auth/meand/auth/logoutto manage sessions.
DATABASE_URL– SQLAlchemy connection string (defaults to the Postgres service from Docker Compose).AUTH_USERS– Comma-separatedusername:password:roleentries used when seeding credentials.OPENAI_API_KEY,DEEPSEEK_API_KEY,GEMINI_API_KEY,GROK_API_KEY– Provider credentials; leave blank to disable a provider.EMBEDDING_MODEL,CHAT_MODEL,MAX_CHUNK_CHARS,TOP_K, etc. – Tune retrieval and generation behavior; seebackend/app/config.pyfor the full list.ALLOWED_ORIGINS– CORS configuration for the frontend;"*"allows any origin.NEXT_PUBLIC_API_BASE– Frontend base URL for API calls.
- The backend ships with exploratory scripts under
backend/app/testing/for Gemini integrations. Formal automated tests are not yet included; add your own test harness before using this in production scenarios. - Because this project is provided for learning/experimentation, review and harden security, validation, and audit logging before exposing it publicly.
This codebase is intentionally verbose and configurable to help you study multi-agent RAG orchestration. Do not treat it as production-ready software: secure secrets, validate inputs, and perform thorough testing before deploying beyond a lab setting.