Distributed AI Chat (Multi-Agent Swarm Architecture)

Featured

A transparent, real-time multi-agent AI system where specialized agents collaborate to produce higher-quality answers.


Overview

This project is a distributed, multi-agent AI chat system where multiple specialized agents collaborate in real time to answer complex questions. Instead of relying on a single LLM response, the system orchestrates a swarm of agents, each with a distinct role, and synthesizes their outputs into a final, coherent answer.

Domain: Agentic AI Systems / Distributed AI

Primary Users: Developers, researchers, AI practitioners

Core AI Capabilities: Multi-agent orchestration, real-time streaming, collaborative reasoning

My Role: End-to-end AI Engineer (agent design, orchestration, backend, frontend, deployment)

This project focuses on how AI systems reason, not just what they output.


AutoGenFastAPIJavaScriptNext.jsOpenAIPostgreSQLPythonRailwayReactRedisSupabaseTailwind CSSTypeScriptVercelshadcn/ui

What it does

Ask a question once. Watch four specialized AI agents (Researcher, Critic, Explainer, Summarizer) collaborate in real time—then receive a polished, consolidated answer that synthesizes their collective intelligence using multi-agent orchestration with round-based collaboration, real-time transparency with live streaming via Server-Sent Events SSE, advanced conversation UX, complete feature set, and event-driven architecture

Best for

Users who need comprehensive answers to complex questions by analyzing questions comprehensively to identify key facts and research avenues, reviewing findings to identify gaps and potential risks, synthesizing information into clear, structured explanations, consolidating all perspectives into polished final answers, coordinating multiple research sources, and managing complex information synthesis workflows

Output

Full-stack distributed AI chat platform with Next.js 16.0.10 (React 19.2, TypeScript, Tailwind CSS, shadcn/ui, Server-Sent Events SSE) frontend, FastAPI backend (Python 3.11+, OpenAI GPT-4o-mini), Supabase PostgreSQL (schema: swarm), Upstash Redis (prefix: swarm), and deployment on Vercel (frontend) and Railway (backend)

Problem

Single-agent LLM systems suffer from structural limitations:

  • One perspective dominates the response

  • Errors or blind spots go unchecked

  • Reasoning steps are opaque to the user

  • Trust is hard to establish without transparency

Research and complex problem-solving benefit from multiple viewpoints, critique, and refinement — but most AI tools hide this process.

The challenge was to design a system that:

  • Enables collaborative AI reasoning

  • Makes agent interactions fully transparent

  • Streams intermediate reasoning without overwhelming the user

  • Remains fast, usable, and production-ready

Solution

I designed a swarm-based, multi-agent architecture where four specialized agents collaborate across structured rounds:

  1. Researcher — Analyzes the question and identifies key facts and constraints

  2. Critic — Reviews findings, challenges assumptions, and identifies gaps

  3. Explainer — Structures and clarifies the information into a coherent explanation

  4. Summarizer — Synthesizes all perspectives into a polished final response

Each agent:

  • Has a dedicated prompt and responsibility

  • Receives context from previous agents

  • Streams output in real time to the UI

The result is a system that produces higher-quality answers while exposing how those answers were formed.

SwarmChat homepage
Click to view full size

My Role

End-to-end AI Engineer (system design, AI orchestration, backend, frontend, infra)

Technical Architecture

AI & Agent Orchestration

  • AutoGen-inspired swarm architecture with explicit agent roles

  • OpenAI GPT-4o-mini for cost-efficient, high-quality agent responses

  • Round-based execution with configurable number of refinement cycles

  • Context sharing via transcript and partial-output propagation

  • Carefully designed prompts to avoid role overlap and hallucination

Backend

  • FastAPI (async Python) for orchestration and agent execution

  • Server-Sent Events (SSE) for real-time streaming of agent outputs

  • Redis (Upstash) for:

    • Job queuing

    • Ephemeral event buffering

  • Supabase PostgreSQL for:

    • Persistent threads

    • Messages

    • Analytics

    • Schema-isolated multi-project storage

Frontend

  • Next.js 16 + React 19

  • Event-driven UI powered by SSE

  • Per-agent panels showing live responses

  • Thread dashboard with search, pagination, and deletion

  • Analytics views for agent performance

  • Markdown rendering with citation extraction

  • Mobile-first, accessible design with dark/light mode

Deployment

  • Vercel for frontend hosting (Edge-ready)

  • Railway for backend API

  • Cloud-native, production-grade infrastructure

Impact

This project demonstrates the practical benefits of agentic collaboration:

  • Produces more robust and nuanced answers than single-agent systems

  • Exposes reasoning steps, improving trust and interpretability

  • Enables experimentation with agent roles, prompts, and collaboration strategies

  • Serves as a foundation for research assistants, decision-support systems, and AI copilots

This project includes production-level features:

  • Persistence

  • Analytics

  • Rate limiting

  • Error handling

  • Export and comparison tools

Challenges & Key Decisions

  • Agent role design: Preventing overlap and prompt conflict

  • Streaming complexity: Coordinating multi-agent SSE streams reliably

  • UX transparency: Showing reasoning without overwhelming users

  • Scalability: Designing for concurrent runs and multiple rounds

  • Consistency: Synthesizing diverse agent outputs into a coherent final answer

These challenges closely mirror real-world distributed AI system design problems.

What This Project Demonstrates

  • Multi-agent AI system design

  • Agent specialization and prompt engineering

  • Real-time streaming architectures (SSE)

  • Event-driven full-stack systems

  • AI transparency and interpretability

  • Production-ready AI UX and infrastructure

Tech Stack

Frontend

JavaScriptNext.jsReactTailwind CSSTypeScriptshadcn/ui

Backend

FastAPIPython

Data & Infrastructure

PostgreSQLRedisSupabase

AI & ML

AutoGenOpenAI

Tools & Infrastructure

RailwayVercel
Derril Filemon — Senior AI Engineer & Full-Stack Developer