Architecture
Task 2: Infrastructure Diagram
System Architecture
The diagram below shows the full stack: the Next.js/React UI communicates via REST API with a FastAPI backend deployed on Vercel. The backend runs a LangGraph supervisor that routes to specialist agents, each with access to specific tools and knowledge sources.
UI Layer
Next.js / React
API Layer
FastAPI on Vercel
Agent Orchestration (LangGraph)
Supervisor / Planner
Recall
Goal Seek
Strategic
What-If
Sensitivity
Forecast
Tools
Google Sheets API
Tavily Web Search
Data / Knowledge
Qdrant Vector Store
OpenAI Embeddings
Knowledge Base (5 categories)
Monitoring & Evals
LangSmith
RAGAS Framework
Agent Flow
Every request follows this path:
- Model Documentation Reader — Reads and caches the financial model's documentation tab on first interaction.
- Supervisor / Planner — Analyzes the user's question using structured output to decide which specialist agent should handle it.
- Specialist Agent — Executes the appropriate playbook. Tool-using agents (Recall, Goal Seek) enter a tool-call loop, calling Google Sheets tools and returning results until the task is complete.
- Response — The final agent response is returned through the API to the UI.
Memory Architecture
The system uses five memory types for comprehensive context management:
- Short-Term Memory — Conversation history via LangGraph checkpointer (MemorySaver).
- Long-Term Memory — Cross-session facts stored in InMemoryStore, persisted across threads.
- Semantic Memory — Embedding-indexed knowledge with text-embedding-3-small for similarity search.
- Episodic Memory — Timestamped records of past agent interactions and outcomes.
- Procedural Memory — Agent playbooks and standard operating procedures for each task type.