Case Studies

BSc Thesis · Event-Driven AI

Multi-Agent Microservice

Event-driven AI agents collaborating over microservices (BSc thesis)

ai-agents-thesis

N+M

coupling - down from N×M

10K+/s

Kafka event throughput

99.9%

agent uptime

Overview

My bachelor's thesis: an event-driven multi-agent AI system that analyzes Mongolian Stock Exchange data and delivers personalized investment advice - in Mongolian. Five specialized agents cooperate over Apache Kafka instead of calling each other directly.

Direct agent-to-agent APIs create N×M coupling; routing every message through Kafka brings it down to N+M. Agents fail independently, scale horizontally by adding instances, and any event can be replayed for debugging or model retraining - with Apache Flink handling stateful multi-step execution plans.

The Orchestrator classifies intent with a ReAct loop on Gemini 2.0 Flash and routes work to the Investment, News and Knowledge agents - the latter a pgvector RAG over an MSE company knowledge base. AI queries complete end to end in ~15–20s, API calls in ~200–500ms, and the whole system idles at ~123MB with 99.9% agent uptime.

Highlights

  • Event-driven architecture on Kafka cuts N×M agent coupling down to N+M.
  • Five agents: Orchestrator (ReAct), Investment, News, Knowledge (RAG) and a PyFlink planner.
  • Semantic search over MSE companies with pgvector and sentence-transformers.
  • Daily sentiment-scored financial news digests by email (Finnhub + Resend).
  • Event replay for debugging and model retraining; real-time streaming with Flink.
  • KPIs beat every target: 10K+ events/s, ~200–500ms API responses, ~123MB idle memory, 99.9% uptime.

Architecture

Event-driven AI agents coordinating over Apache Kafka

Frontend

Next.js 16 + React 19 · dashboard · AI chat · watchlist

API gateway

Express · JWT auth · Kafka producer

Event broker

Apache Kafka

user.requests · agent.tasks · agent.responses · planning.tasks

AI agents

Orchestrator

ReAct · intent routing

Investment

MSE analysis · advice

News

Finnhub · sentiment

Knowledge

RAG · pgvector

PyFlink planner

Flink 1.18 · multi-step

Data layer

PostgreSQL 16 · Redis 7 · pgvector

grid

Radnaabazar Bulgan

Aruarian Dance