Torvi · System architecture

A WhatsApp AI agent for housing societies

Designed so the AI can't reveal or change anything it isn't allowed to — even if someone tricks it.

Torvi lets residents of Indian housing societies ask about dues and payments on WhatsApp, in their own language. This page is the engineering view: how the system is structured, the agentic-AI patterns it uses, and the decisions behind it. For the product, see torvi.in ↗

Live pilot · Hyderabad Agentic AI with tool use Serverless on AWS Multi-tenant India data residency
01 · Why this is hard

Three constraints that shaped every decision

Money + LLMs

An AI in front of financial records

Language models can be manipulated through the very messages they read. Neighbours' balances must never leak, and payments must never be recorded by a persuaded model.

Real users

No apps, no passwords, many languages

Residents use WhatsApp, not portals. Questions arrive in English, Hindi, Telugu and mixtures of them. Any friction and they go back to calling the secretary.

Small budgets

Built for an 11-flat society

The system has to cost almost nothing at small scale, meet India's DPDP data rules, and still grow to many societies without re-architecture.

02 · Conceptual view

Layers, boundaries and two paths

Admins write through a console; residents read through chat. Both paths cross a single trust gate before reaching any domain logic, and the AI only sits on the read path.

Torvi conceptual architecture Admins reach Torvi through a web console and residents through WhatsApp. Both pass a trust gate. The admin write path goes to admin services that record expenses and payments in the society ledger. The resident read path goes to an AI agent, backed by an external foundation model, that calls read-only tools over the ledger and a RAG knowledge index. Data is stored per society with an append-only audit trail. ACTORS CHANNELS TRUST INTERACTION DOMAIN DATA Admins secretary · treasurer Residents ask questions Admin web console browser · one-time code sign-in WhatsApp chat · any language TORVI PLATFORM · SERVERLESS · INDIA REGION Trust gate verify source · identify person · resolve role and society · rate-limit · input guardrails Admin services validated · idempotent · step-up auth WRITE PATH AI agent reasoning loop · tool calling READ-ONLY TOOLS Expenses categories · splits Society ledger dues · payments · reversals · month close Society knowledge vendors · bye-laws Operational store partitioned by society · encrypted at rest · append-only audit trail Vector index embeddings · RAG Every read and write passes the trust gate · the AI never touches the write path EXTERNAL Messaging API delivery · codes Foundation model managed LLM token per request signed webhook role + society trusted context write once tool call · own flat CROSS-CUTTING Security Privacy & consent Tenant isolation Observability Infra as code
scroll the diagram →
Admin path (write) Resident path (read) Trust boundary External service

One gate, two doors

Chat and console have different authentication, but both resolve identity, role and society the same way before any logic runs.

AI on the read side only

The agent acts only through narrow, read-only, permission-checked tools. Every change to money goes through admin services instead.

Domain owns the truth

The ledger is the single source of truth for balances. Payments are recorded once and audited; nothing is edited in place.

03 · Request paths

What happens on each path

Read: a resident asks

chat
01ReceiveMessage arrives from the messaging provider as a signed event.
02GateAuthenticity, duplicates, rate limits, identity, role and flat.
03Plan & call toolThe agent works out intent and calls the right read-only tool.
04Tool checkThe tool re-checks permission against the identity from the gate.
05RespondAnswer composed in the user's language and sent back.

Write: an admin records a payment

console
01AuthenticatePasswordless one-time code; short-lived token.
02GateRole and society re-read on every request; step-up for sensitive actions.
03ValidateAmount, mode, reference and an open month.
04CommitPayment, balance and audit entry saved together — once, even on retry.
05ReflectUpdated balance is what residents see on their next question.
04 · AI & agentic patterns

The patterns that keep a single agent safe and cheap

Torvi uses one tool-using agent, deliberately constrained. These are the patterns that make it safe to put in front of financial data.

PatternWhat it means here
Tool-using agent (ReAct)The agent reasons about the question, calls a tool, reads the result and composes the reply.
Least agencyOnly read-only tools are exposed; every action that changes money lives outside the agent. Addresses Excessive Agency in the OWASP LLM Top 10.
Trusted context channelIdentity, role and flat travel in server-set session state — never in the message text the model reads and could be fooled by.
Policy at the tool boundaryThe model proposes; code decides. Each tool enforces permissions deterministically, whatever the model asked for.
Right retrieval for the dataDocuments come through retrieval (RAG); balances and payments come through structured tools — never from embeddings.
Layered guardrailsA cheap input filter before the model, permission checks after it, prompt rules last. No single layer is trusted alone.
Right-sized modelA small, fast model handles conversational reads — quick responses at a cost an 11-flat society can carry.
Human in the loop plannedAI-drafted meeting minutes are approved by an admin before anyone sees them.
05 · Quality attributes

How the architecture meets its non-functional goals

AttributeGoalArchitectural approach
SecurityNo data leaks through the AITrust gate before any logic; permission checks inside every tool; writes outside the AI path
IntegrityBalances are always rightSingle ledger of record; idempotent, transactional writes; append-only audit
PrivacyMinimal, protected personal dataMessages not stored; data classified before encryption; consent at first contact; India-only residency
Multi-tenancySocieties never see each otherTenant resolved from identity; data partitioned by society; no default tenant
ReliabilityRetries never cause harmDeduplicated inbound events; idempotency keys on writes; backoff on external calls
CostViable for an 11-flat societyPay-per-use services; unknown or abusive traffic stopped before the AI is called
06 · Key decisions

Three decisions that shaped the structure

ADR-002In place

Enforce access in code, not in the AI's instructions

Problem
An instruction like "only admins may…" can be talked around.
Outcome
Every tool checks identity the AI can't change.
ADR-018In place

Split the write path out of chat

Problem
Recording money through an AI conversation was the largest risk.
Outcome
A separate admin path; the risk was removed rather than defended.
ADR-005 → 013Reversed

From hashing phone numbers to encrypting them

Problem
Hashing looked sufficient but is weak for phone numbers and short of what DPDP expects.
Outcome
Tokens and encryption, decided before any code was written.

Full decision log →

07 · Engineering

Practices and implementation

The conceptual layers above map to managed services. Component-level detail is in the architecture docs.

Architecture Decision Records — incl. reversals C4-style views Threat modelling · OWASP LLM Top 10 Privacy by design · DPDP Append-only ledger · CQRS-style read model Idempotency · optimistic concurrency Zero-trust request handling
ConceptImplemented with
Chat channel · messaging APIWhatsApp Cloud API (Meta)
Admin web consoleReact SPA · Cloudflare Pages
Trust gateAWS Lambda webhook · Amazon Cognito (custom auth) · API Gateway JWT authorizer
AI agent · foundation modelAmazon Bedrock Agents · Claude
Admin services · domain logicAWS Lambda (Python)
Knowledge base · vector index (RAG)Amazon Bedrock Knowledge Bases
Operational store · audit trailAmazon DynamoDB (on-demand, point-in-time recovery)
Infrastructure & observabilityAWS SAM · CloudWatch · SNS · AWS Mumbai region
08 · Architecture evolution

Where the architecture goes next

Hardening

PII vault & private networking

Tokenised identity with customer-managed encryption keys; compute moved onto private network paths.

New pipeline

Event-driven media processing

Voice notes → transcription → AI-drafted minutes → admin approval → broadcast, as an asynchronous pipeline.

Integration

Payment gateway on the write path

Gateway callbacks enter through the same gate and admin services, behind a provider-neutral adapter.

KK

Building agentic AI for money, compliance or messaging?

Torvi is designed and built by Eswara Krishna Akurathi, a platform solutions architect working on enterprise agentic AI for banking and financial services. Happy to compare notes on the patterns here — or talk about piloting Torvi in your society.