About the AI Agent System

System Architecture

This system demonstrates a multi-agent orchestration using Mastra.ai. It connects a Next.js frontend with a stateful backend of specialized AI agents that maintain context over time.

Architecture Overview

Frontend (Next.js)

  • Modern React components and UI
  • API routes for agent communication
  • Chat interface with agent selection
  • Streaming responses for better UX

Backend (Mastra Orchestration)

  • Multiple specialized agents (CEO, Marketing, Developer, etc.)
  • Tool integrations (email, web research, database)
  • Vector memory with Postgres+pgvector
  • Chain of command for complex tasks

Agent System Diagram

CEO Agent (Kenard)

Orchestrates other agents and makes strategic decisions

Marketing

Chloe

Developer

Alex

Sales

Hannah

Finance

Jenna

Product

Mark

Design

Maisie

Research

Garek

Weather

Utility

Tool Integrations

  • Email Tool
  • Web Research Tool
  • Database Tool
  • Vector Memory Tool

Vector Database

Postgres with pgvector extension for semantic memory

LLM Provider

OpenAI GPT-4o Mini powering all agents

How It Works

  1. User Submits a Query: The user selects an agent and sends a message through the chat interface.
  2. API Routes Direct Traffic: Next.js API routes forward the request to the appropriate agent.
  3. Agent Processing: The agent uses its tools and context to formulate a response.
  4. Memory Storage: Interactions are stored in the vector database for future context.
  5. Streaming Response: The response is streamed back to the user in real-time.