Architectural Overview
ÆHub (AeSoul Digital Hub) is a full-stack AI orchestration platform engineered for running autonomous, tool-using agents equipped with persistent memory, Retrieval-Augmented Generation (RAG), live web search, sandboxed code execution, and dynamic agent delegation. The platform is structured around a decoupled, service-oriented architecture: a React-based Next.js frontend handles client interactions and event streaming, a FastAPI backend serves as the core API gateway and control plane, and a stateful agent runtime named A.U.R.O.R.A. (built on LangGraph and LangChain) manages model workflows.
The system emphasizes high throughput and model flexibility by using fast inference providers like Groq, while evolving toward a zero-paid-inference multi-provider model strategy (M17). Data persistence, contextual vector retrieval, and task coordination are handled by a combined data layer featuring PostgreSQL with pgvector, Redis, and Celery.
Layered System Architecture
+-----------------------------+
| Next.js / React UI |
| (TypeScript, Event Streams) |
+--------------+--------------+
|
| HTTP / WebSockets / SSE
v
+-----------------------------+
| FastAPI Control Plane |
| (Async REST API, Gateway)|
+--------------+--------------+
|
+----------------------------+----------------------------+
| |
v v
+-----------------------------------+ +-----------------------------------+
| A.U.R.O.R.A. Runtime (LangGraph) | | Background Processing |
| - Multi-Agent Delegation | | - Celery Distributed Tasks |
| - MCP Tool Integration | | - Playwright Web Scraping |
| - Groq / M17 Provider Fleet | | - Docker Sandboxed Execution |
+----------------+------------------+ +----------------+------------------+
| |
+----------------------------+----------------------------+
|
v
+-----------------------------+
| Data Layer |
| - Postgres + pgvector |
| - Redis (Cache/PubSub/Queue)|
+-----------------------------+
1. Frontend Layer (Next.js & TypeScript)
The frontend provides a reactive user interface built with Next.js, React, and TypeScript. It displays real-time agent output streams, execution graphs, and active tool interactions. The frontend connects to the backend gateway via REST and persistent streaming connections (such as SSE or WebSockets), consuming execution steps emitted directly by the agent graph as nodes complete their tasks.
2. Control Plane & API Gateway (FastAPI)
The backend API is implemented in Python using FastAPI. It operates as the entry point for system operations, exposing endpoints for session management, tool configuration, agent invocation, and health checks. FastAPI's asynchronous asyncio execution loop manages long-lived client streaming connections without blocking worker threads while agents wait on external LLM responses or asynchronous tool execution.
3. Agent Execution Engine: A.U.R.O.R.A. (LangGraph & LangChain)
The agent runtime, A.U.R.O.R.A., relies on LangGraph to represent agent workflows as stateful graphs. Nodes within the graph correspond to specific LLM reasoning steps, tool invocation handlers, or sub-agent delegations.
- Multi-Agent Delegation: Tasks requiring specialized execution (e.g., searching the web vs. running code) are dynamically routed from a primary supervisor node to sub-agents.
- Model Context Protocol (MCP): Standardized context and tool definitions allow integration with external data providers and tools without requiring proprietary wrappers for each tool source.
- M17 Multi-Provider Strategy: High-speed inference relies on Groq for low-latency tool evaluation. The execution engine routes requests across multiple cloud providers to optimize cost and latency, progressing toward a zero-paid-inference architecture.
4. Memory and Data Management Subsystem
- PostgreSQL +
pgvector: Acts as the primary database for application state, agent session logs, dynamic RAG document stores, and vector embeddings. Storing both relational application data and high-dimensional vector embeddings within a single database eliminates cross-database sync issues and simplifies similarity searches using SQL. - Redis: Functions as a low-latency state cache, session broker, and event stream backend. It buffers real-time agent execution events generated by A.U.R.O.R.A. threads before they are pushed out to client connections.
5. Background Workflows & Sandboxed Execution
- Celery: Offloads heavy tasks—such as long-running document ingestion, vector index refreshes, and scheduled background routines—from the main API thread pool.
- Playwright: Executed by background tools to render JavaScript-heavy web pages, allowing agents to fetch dynamic external content and execute search tools.
- Docker Sandboxing: Code generated by agents is executed inside isolated Docker containers with restricted permissions, memory limits, and process isolation to prevent unauthorized access to the host environment.
Key Architectural Decisions
- State Graphs over Linear Chains: Switching from linear chain pipelines to LangGraph's cyclic state graphs allows agents to correct errors dynamically. If a tool execution fails or returns low-confidence output, the state graph routes execution back to a re-planning node rather than throwing an unrecoverable exception.
- Unified Vector and Relational Database: Using
pgvectorinside PostgreSQL allows transactional integrity across user metadata, chat history, and semantic memory vectors. This eliminates the operational overhead of managing a separate vector database. - Decoupled Asynchronous Event Architecture: Decoupling agent execution state from client presentation via Redis Pub/Sub and asynchronous task processing ensures that long-running operations—such as web scraping or multi-step agent reasoning—do not cause client timeouts.
Observability, Security, and Deployment
- Observability & Tracing:
- LangSmith: Captures execution paths, node transitions, token counts, and latency across LangGraph agent invocations for prompt debugging and trace evaluation.
- OpenTelemetry & Prometheus: Collects system-level metrics, trace spans across FastAPI routes, database query timings, and host resource utilization.
- Security & Isolation:
- Sandboxed code execution utilizes ephemeral Docker runtime environments.
- API endpoints enforce request validation via Pydantic models in FastAPI to prevent malformed payloads from reaching downstream tool engines.
- Deployment Packaging: The application uses Docker containers for microservices (Next.js, FastAPI, Celery, Redis, Postgres), enabling consistent configuration across local development setups and cloud production hosts.
