Building the Solution
We designed a modular, multi-agent architecture built around two specialized backends and an independent frontend ecosystem.
Frontend (Angular + WebSockets)
The chat widget was built as an autonomous micro-frontend using Angular Elements. They are compiled into a single JS file and embedded into the host platform as a plug-and-play module.
A Custom Events system enables two-way communication: the agent pulls live context from the parent app and pushes actions back to update dashboard widgets in real time. WebSocket-powered token streaming keeps sessions alive in the background, supporting long-running optimization workflows and multi-thread chat sessions.
Core AI Backend (TypeScript + AWS)
The primary assistant runs on AWS using a multi-agent collaborator pattern. It is a specialized sub-agents handle distinct domains (transactions, goals, financial planning) and report to the orchestrator.
A custom Chat Tool Router decouples tool logic from the agent, standardizing how it interacts with dozens of AWS Lambda functions. Context is managed through dynamic pagination and summarization to handle large MySQL datasets within token limits. RAG grounds responses in the platform's technical documentation and a proprietary knowledge base.
Portfolio Optimization Agent (Python + LangGraph)
A dedicated Python agent handles investment optimization via cyclic LangGraph workflows. AI Agent revisits and refines results across multiple iterations until portfolio goals are met. Intelligent model routing sends complex reasoning tasks to Claude Sonnet while delegating lightweight queries and continuous context compression to Claude Haiku, balancing capability with cost.
An Agent Skills module dynamically loads specialized prompt modules (e.g., Tax Location Optimization) on demand, preventing context bloat. Guardrails enforce constraint-based rules, which include restricted holdings, diversification targets, liquidity floors. The rules keeping the AI within professional boundaries. The entire environment is provisioned via Terraform, with a self-hosted Langfuse instance providing full traceability of every decision step.





.webp)

.webp)
.webp)



