Inspiration

Corporate treasury and ledger reconciliation are traditionally manual, slow, and error-prone. Multinational enterprises face huge operational overhead reconciling accounts across different regional entities, dealing with fluctuating currency rates (FX variances), wire transfer fees, and strict AML (Anti-Money Laundering) regulations. We wanted to build an autonomous, zero-friction, and globally consistent solution.

Zenith Treasury demonstrates how a modern B2B application can automate complex double-entry bookkeeping using an active-active, globally replicated relational database (AWS Aurora DSQL) combined with a collaborative, multi-agent AI system.

What it does

Zenith Treasury streams incoming bank statements and ERP sales invoices, processing them through a multi-agent AI mesh:

  1. Matcher Agent identifies matches. If the amount, currency, and metadata match perfectly, it signs off. If it detects a discrepancy, it flags the transaction and hands it off to the Investigator.
  2. Investigator Agent resolves edge cases: it parses wire transfer descriptors to identify and write off intermediary bank fees, converts cross-border currencies (using real-time ECB rates) to account for FX variances, and checks unsolicited deposits for compliance, quarantining suspicious funds.
  3. Auditor Agent validates the double-entry accounting records, signs the transactional commits, and writes the ledger entries to AWS Aurora DSQL shards in us-east-1 (Virginia) or eu-west-1 (Dublin).

How we built it

  • Frontend: Next.js (App Router, Tailwind CSS, Lucide Icons) deployed on Vercel with Edge runtime optimizations.
  • Database Engine: AWS Aurora DSQL (Distributed SQL) serving as a single, globally replicated active-active relational database.
  • ORM & Connection: Prisma v7 ORM configured with relationMode = "prisma" and @prisma/adapter-pg.
  • Security & IAM Auth: Short-lived tokens signed dynamically using @aws-sdk/dsql-signer to authenticate the pg.Pool connection adapter without static passwords.
  • Real-time Logs: Next.js Server-Sent Events (SSE) API to stream agent-to-agent logs directly to a high-fidelity glassmorphic dashboard terminal.

Challenges we ran into

  • DSQL Indexing Constraints: Aurora DSQL does not support synchronous secondary unique indexes. We resolved this constraint by moving unique checks to the application and repository layer logic.
  • Relation Handling: Aurora DSQL distributes data across global shards and does not enforce traditional foreign keys at the storage level. We configured Prisma's relationMode = "prisma" to manage relations at the client ORM level.
  • IAM Token Connection Pool: Since DSQL doesn't use passwords, we had to implement a custom asynchronous token generator in our pool connection configuration to refresh the IAM signature dynamically.

Accomplishments that we're proud of

  • Designing a system that works locally out-of-the-box (using a smart seeded in-memory state engine) and escalates to a live AWS cloud database as soon as the DATABASE_URL environment variable is defined.
  • Creating a visually stunning, premium-grade dashboard utilizing dark mode, glassmorphism, and live glowing neon state-lights representing active agent statuses.
  • Implementing a Server-Sent Events (SSE) pipeline that streams real-time, multi-agent discussions as they resolve variances and record ACID-compliant double-entry ledger items.

What we learned

  • How to connect Node.js application runtimes to passwordless AWS Aurora DSQL databases using @aws-sdk/dsql-signer.
  • How to model database schemas under distributed SQL environments where foreign keys are managed at the client layer.
  • How to structure multi-agent systems where LLMs collaborate to perform structured bookkeeping tasks and ensure audit-ready ledger consistency.

What's next for Zenith Treasury

  • Integration with standard ERP system webhooks (such as NetSuite, SAP, and QuickBooks).
  • Expanding the agent mesh with a Forecasting & Liquidity Agent to predict cash runway and treasury health.
  • Integration with open banking APIs (Plaid/Yodlee) for automated, live bank statement feeds.

Built With

Share this project:

Updates