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
How the agent handles a message A WhatsApp message is verified and the resident and intent identified. Four branches follow: a dues question fetches the resident's own balance with a read-only tool; a vendor question looks up society knowledge; a request for another flat's dues is politely refused; an unknown number is guided to registration without calling the AI. Message on WhatsApp Verify · identify · understand who is asking, which flat, what they want "My dues?" "Plumber?" "Flat 101's dues" Unknown number Fetch ownbalance read-only toollive from ledger Look upvendors society knowledgevia retrieval Politelyrefuse not your flat —enforced in code Guide toregister AI not calledzero cost Same checks whether the message is in English, Hindi, Telugu or a mix. FICTIONAL SOCIETY · ILLUSTRATIVE
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: what happens when someone tries to trick the agent

chat
Sequence: a resident asks for another flat's dues A resident of flat A-202 asks for flat A-101's dues. The trust gate verifies the sender and attaches trusted context saying the requester is a resident of A-202. The AI agent is persuaded and calls the dues tool for A-101. The tool compares A-101 with the trusted flat A-202, denies the request, and the ledger is never queried. The resident receives a polite refusal. Resident Trust gate AI agent Dues tool Ledger "Show flat A-101's dues" verified sender resident · A-202 message + trusted context {flat: A-202, role: resident} getDues(A-101) the model went along with it A-101 ≠ A-202 denied in code never queried ✕ access_denied "You can only view your own flat's dues." 1234567
scroll the diagram →

The agent was fooled at step 4 and it didn't matter. Identity came from the gate at step 2, not from the message, and the tool enforced it in code at step 5.

Write: what happens when a payment is submitted twice

console
Sequence: an admin's payment is submitted twice An admin records a payment for flat A-202 with an idempotency key. The trust gate validates the token and re-reads the admin's role and society. Admin services commit the payment, balance update, audit entry and key in one transaction. The response is lost, so the admin retries with the same key. Admin services find the key already recorded and return the original result without writing again. The balance changes once and the audit trail has one entry. Admin · console Trust gate Admin services Operational store Record ₹3,412 for A-202 idempotency key K1 valid token admin · role re-read request + trusted context one transaction payment + balance + audit + key K1 committed together response lost · network drop Retry · same key K1 checked again K1 already recorded no new write untouched ✓ Recorded once · same receipt 12345678
scroll the diagram →

The retry was harmless: the balance changed once and the audit trail has one entry. Role and society were re-checked on both requests, and the AI isn't on this path at all.

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.
Language-agnostic toolsThe agent understands English, Hindi, Telugu and mixed messages; the tools and data underneath are language-neutral. No translation layer — a dues question in Telugu runs exactly the same check as one in English.
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 become approved minutes through an asynchronous pipeline, with an admin approving before anything is shared (below).

Integration

Payment gateway on the write path

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

Planned pipeline: meeting minutes

designed
Planned meeting-minutes pipeline An admin's voice note is transcribed in Hindi, Telugu or English, an AI drafts the minutes, an admin approves them, they are broadcast to residents, and they become searchable through retrieval. Voice notefrom admin Transcribehi · te · en AI drafts minutesstructured summary Admin approveshuman in the loopnothing is shared before this Broadcastto residents Searchablevia RAG Asynchronous and event-driven: long-running steps run outside the chat request, and the AI only drafts.
scroll the diagram →
09 · Questions

Questions a sceptic would ask

What stops the AI showing another flat's dues?

The AI never decides who is asking. The sender is identified from server-side records before the AI runs, and every tool re-checks that identity in code. If the AI is talked into asking for another flat, the tool refuses and the data is never read.

Can the AI make up a balance?

Balances aren't the AI's to invent: every figure is fetched live from the ledger by a tool, and the AI only puts it into a sentence. Automatically checking that the reply repeats the tool's numbers exactly is on the roadmap.

Can someone record a fake payment by chatting?

No. The AI has no tools that change money. Payments are recorded only in the admin console, after a one-time-code sign-in, with role and society re-checked on every request and an audit entry for every change.

What if a payment is submitted twice?

Each submission carries an idempotency key. The first one is saved together with the balance update and audit entry in a single transaction; a repeat with the same key returns the original receipt and writes nothing.

Where is the data, and what is kept?

All resident data stays in AWS's Mumbai region. Chat messages are processed in memory and not stored. Consent is captured at first contact, in line with India's DPDP Rules, and payment records are kept for the seven years accounting rules require.

Which languages does it understand?

English, Hindi, Telugu, and the mixes people actually type, such as Hinglish. The same tools and checks apply whatever the language.

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.