Case study · 2026
KASI: AI Expense Tracker for Sri Lanka
AI fintech app · Gemini agent · Flutter
Personal product · iOS & Android · Built May – Oct 2026 · v1.0
KASI (කාසි, "coins" in Sinhala) is a personal-finance app built for Sri Lanka. Point the camera at a receipt, paste a bank SMS, or just ask, and KASI turns it into a categorised expense, keeps budgets and income in balance, and gives you an AI money advisor that lives on your phone.

- Solo builder · Design, app, backend & AI
- 2026
- AI fintech app
- 9 technologies
- Flutter
- Gemini 3.5 Flash-Lite
- Firebase AI Logic
- Cloud Functions
- Firestore
- SQLite
- App Check
- RevenueCat
- Google Stitch
~34K
Lines of Dart · 12 feature modules
11
Tools the Kasi AI agent can call
4
AI features: scan, SMS, advisor, chat
~0.1 LKR
Measured AI cost per receipt scan
~100
Screens & states designed in Stitch
7
Cloud Functions in asia-south1
App screens
13 real screens from the shipped app · tap to enlarge
The problem
Global expense trackers don't fit Sri Lankan spending: no LKR-first design, no CEB or water bills, no units like packet, sachet or bunch, and manual entry that people quickly give up on. Most AI finance apps also send your whole transaction history to the cloud.
Overview
KASI is offline-first: every expense, budget and income record lives in a local SQLite database, so the app is instant and works with no internet. Cloud backup and two-way sync are an opt-in Pro feature.
Google Gemini 3.5 Flash-Lite, reached through Firebase AI Logic with no API key in the app, reads receipt photos and bank SMS into strict JSON, writes a monthly advisor report, and powers Kasi AI, a tool-calling agent that queries your local data to answer questions like "How much did I spend on fuel in the first week?".
The interface was designed first in Google Stitch (about 100 screens, variants and states) and then rebuilt natively in Flutter, using Clean Architecture per feature with GetX. A small TypeScript Cloud Functions backend owns everything the client can't be trusted with: quotas, the AI cost ledger and Pro entitlements.
Architecture
System architecture
Local-first by design: the screens only ever read SQLite. Gemini runs from the device, but money decisions (quota, cost, entitlement) run on the server.
- 01
Flutter app
Presentation (GetX pages and controllers) → Domain (pure Dart entities and use cases) → Data (repositories and datasources).
- 02
Local database
Expenses, budgets, incomes, chat history and agent preferences, so everything works offline.
- 03
AI layer
Receipt and SMS parsing, the Kasi Advisor and the tool-calling agent, with no API key in the app and an App Check token on every call.
- 04
Quota & billing
reserveAi → settleAi metering, a per-user monthly AI cost ceiling, and Pro entitlements written only by the server.
- 05
Cloud sync
Two-way sync of expenses, budgets and income; the newest updatedAt wins. Firestore is a backup target, never the screens' source.
- 06
Subscriptions
App Store and Play Billing purchases, confirmed by a server-side webhook so Pro can't be faked from the client.
AI agent
Kasi AI: the tool-calling agent
A floating assistant on every screen. It answers from your own data by calling local tools, and never saves anything without your tap.
- 01
Ask
"How many packets of milk did I buy this month?"
- 02
Reserve
Checks plan, daily and monthly quota and the cost ceiling, and books a single-use reservation.
- 03
Think
The model picks tools such as get_expenses_in_range, search_purchases or compare_periods.
- 04
Query
Tools run on the phone and return aggregates, unit-aware (kg, litres, packets).
- 05
Confirm
add_expense only proposes; nothing is saved until the user taps Confirm.
- 06
Settle & learn
Real token cost is settled, and confirmed choices teach merchant → category aliases.
UI design
Designed in Google Stitch, built in Flutter
Stitch's HTML is used as a specification, never a web view. Every screen is rebuilt natively.
- 01
Prompt
Each screen described with LKR context, local merchants and bills, and the brand system.
- 02
Variants & states
Three Home layouts, plus empty, loading, error, locked (free tier), overspent, dark mode and a 200% large-text stress test.
- 03
Handoff boards
Component spec, interaction flow map, prototype map and asset list.
- 04
Stitch MCP → Claude Code
The coding agent reads each screen's HTML and screenshot directly through the Stitch MCP server.
- 05
Tokens → widgets
Colours, radii, spacing and type lifted into AppColors and AppTextStyles; shared KasiCard, KasiButton and TransactionTile widgets.
- 06
Verify
Compare each built screen with its Stitch design and iterate.
Components
Receipt scan
Camera or gallery photo → Gemini extracts merchant, date, line items with quantities and units, total and category → review and save.
Paste bank SMS
Paste a bank or card alert and Gemini turns it into an expense, never guessing a date it can't see.
Kasi Advisor
An LLM-written monthly report from a ~2 KB summary (category totals, budgets, top merchants) with 3–5 savings suggestions.
Budgets & income
Per-category monthly limits, an income split that warns about over-allocation, savings rate and a 6-month income-vs-spending chart.
Smart tips (no AI)
Rule-based tips, pace vs last month and budget alerts, free and fully offline.
Cloud Functions
reserveAi, settleAi, getQuota, syncEntitlement, revenuecatWebhook, initUsage and cleanupDeletedUser (TypeScript, Node 20, Mumbai region).
Key features
- LKR-first: Sri Lankan categories (CEB bill, water bill, fuel, telecom, pharmacy) and units (packet, sachet, bunch, tin, dozen, plate)
- Three ways to add an expense: AI receipt scan, pasted bank SMS, or a fast manual form with line items
- Kasi AI chat on every screen, answering with rich cards and follow-up suggestions
- In-app and OS notifications: budget near or over limit, large transactions, daily reminder, weekly summary and AI tip
- Email, Google and Apple sign-in, custom categories, assistant tone, CSV export and full account deletion
- Free plan: 25 AI scans a month · Pro (LKR 490/month or 4,900/year): 250 scans, Advisor, AI chat and cloud sync
Security & privacy
- No secrets in the app: no Gemini key at all, and only public RevenueCat SDK keys
- Firebase App Check (Play Integrity and App Attest) enforced on every function and on Gemini, with limited-use tokens for replay protection
- Server-owned entitlements: the usage document is write-protected in Firestore rules, so the client can ask for a re-check but never grant itself Pro
- Single-use AI reservations with a floor cost, so even a tampered client can't push AI spend below a known bound
- Owner-only Firestore rules, cloud writes only for live Pro, and Storage rules limited to your own profile photo (images only, under 5 MB)
- Data minimisation: the Advisor sees aggregates only, and chat history never leaves the phone
- Local data lives in a standard SQLite file (not encrypted by the app itself) inside the app's private sandbox, relying on the phone's OS-level protection, with Android backups disabled; small secrets use secure storage (Keychain / Keystore)
- Account deletion wipes local data, cloud data and the Firebase user, with a server trigger as a guarantee; CSV export is formula-injection safe
Advantages
- Instant and offline: the UI never waits on the network
- Private by default: your transaction list stays on your device unless you turn on sync
- Cheap to run: on-device model calls cut latency and cost, at about 0.1 LKR per receipt scan, with a hard LKR 250 monthly AI ceiling per user
- Trustworthy AI: agent actions need a human tap, and the model never guesses missing dates
- Built for local reality: LKR amounts, Sri Lankan bills and shopping units out of the box
- Tested on real data paths: 20 test suites run the production SQLite schema in memory, including v1 → v3 migrations
Known limitations & roadmap
- Dark theme is designed in Stitch but not finished in code yet; the app ships light-only
- Budget deletes don't sync across devices yet (no tombstones)
- AI categorisation maps to default categories; custom categories are manual for now
- Line items exist for scanned receipts and manual entries, not yet for SMS-parsed expenses
- Next: App Store and Play Store release of v1.0