Inspiration
Every month, millions of Pakistani households get an electricity bill they can't check. The 2026 LESCO web bill prints just two numbers, Total Electricity Charges and Taxes. Hidden behind them are slab rates, a fixed charge per kilowatt, an FC surcharge, a quarterly adjustment, a fuel adjustment charged on an earlier month's units, electricity duty and GST.
The rules are unforgiving. A "protected" household that uses 201 units instead of 200 loses its cheaper rates, and under the 6-month rule it keeps paying the higher rates for months afterwards. For a typical family that's around Rs. 17,000 for one extra unit, and most people only find out when the bill arrives. We wanted to answer two questions every household has: "Is my bill right?" and "How do I keep it down?"
ہر یونٹ کا حساب، ہر سوال کا جواب
What it does Snap or upload: a photo of the paper bill, or the PDF web bill from LESCO's website. Read: Amazon Bedrock reads the bill into structured fields. The photo is deleted the moment it's read, and names, addresses and reference numbers are never extracted. You confirm: hard-to-read fields are highlighted. The AI never has the last word on a number. Rebuild every line: a plain-code tariff engine recomputes the whole bill from NEPRA's notification S.R.O. 279(I)/2026 and that month's adjustments, then compares it with what LESCO printed. It covers: energy by slab fixed charges per kW FC surcharge quarterly adjustment fuel adjustment on the correct earlier month meter rent electricity duty and GST Explain: a clear verdict in simple Urdu or English, with read-aloud. Act: What-if: "13 fewer units would have saved Rs. 4,795," plus a live slider that shows the 200-unit cliff. Complaint letter in Urdu or English, ready to print. Your personal details never leave your phone. Slab Guard: log your meter every few days and get a forecast ("you'll cross 200 around 13 Dec; keep to 5.8 units a day"), with optional email alerts before it happens. How we built it
It all runs on AWS in one CDK stack (ap-southeast-2):
Amazon S3 (presigned upload) → EventBridge rule → AWS Step Functions workflow: Extract: Lambda + Amazon Bedrock (Amazon Nova 2 Lite) Wait for the user: a Step Functions task token pauses the workflow until the person confirms the numbers Audit: the tariff engine, with no AI Explain: Bedrock writes the Urdu and English text API Gateway HTTP API + AWS Lambda (Node 22, ARM), throttled to keep costs bounded. DynamoDB for bills (7-day expiry) and Slab Guards (60-day expiry). Amazon SNS email alerts through one topic with a per-guard filter, so we never store email addresses. EventBridge Scheduler sends a "read your meter" reminder every 3 days and deletes itself when the month ends. Amplify Hosting for the React + Vite frontend. It has English and Urdu (right-to-left Nastaliq), PDF bills rendered in the browser with pdf.js, and a landing page animated with GSAP, Lenis and Vanta.
Design rule: the AI never decides money. Bedrock reads the bill and explains the result. Every rupee comes from our TypeScript tariff engine, which has 57 tests, does all its maths in whole paisa, and has an official source for every rate.
Challenges we ran into The bill hides its maths. 2026 web bills print only totals. We found that the QR code on each bill holds an itemised breakdown, and decoding it let us confirm every formula: duty is charged on energy plus the quarterly adjustment GST is charged on everything including the duty, rounded to the rupee the fuel adjustment uses the units from two bills earlier The AI moved numbers between rows. One model put the GST into "electricity duty" and the late-payment surcharge into "TV fee". The fix was in the design: the model copies each label and amount exactly as printed, and code matches labels to fields. We also switched models after one mixed up the two-column history table. A rounding bug only real bills could catch. Our money helper rounded rates to the paisa before multiplying. That's harmless at 10.54 per unit but wrong at 2.3673 per unit. Real bills exposed it, and the tests now lock it down. New AWS account limits. On the Free plan, Textract and Translate were blocked and everything had to stay in one Region. We designed around it: Bedrock vision instead of OCR, Bedrock for Urdu, and the browser's speech engine for read-aloud. Accomplishments that we're proud of Three real LESCO bills rebuilt from the tariff alone, matching to the rupee: Bill Rebuilt Printed Protected, 74 units Rs. 2,247.91 Rs. 2,248 Non-protected, 125 units Rs. 5,838.01 Rs. 5,838 Time-of-use, 107 units Rs. 8,242.55 Rs. 8,242
Taxes matched to the paisa.
Human checking is part of the system itself: the Step Functions task token makes "check what the AI read" a required step, not just a suggestion on screen. Privacy by design: photos deleted after reading no personal data extracted letter details stay on the device no email addresses stored Real Urdu support, written in from the start. What we learned
Getting a model to read a bill is the easy part. The hard part is making its output verifiable. Splitting the job into read (AI), calculate (code) and confirm (human) made every mistake visible and fixable. We also learned that real data beats assumptions: our three real bills overturned two of our early assumptions and caught a bug that synthetic tests had missed.
What's next for Bill Samjho Pull fuel and quarterly adjustments automatically from NEPRA's monthly decisions (today it's one data entry per month). Support more DISCOs (IESCO, FESCO, K-Electric) and commercial tariffs. Read the bill's QR breakdown directly in the browser, for an exact extraction without AI. Let Slab Guard read the meter from a photo, and add WhatsApp alerts. Partner with consumer-rights groups so complaint letters reach the right office and get tracked.
Built With
- amazon-api-gateway
- amazon-bedrock
- amazon-cloudwatch
- amazon-dynamodb
- amazon-eventbridge
- amazon-nova
- amazon-sns
- amazon-web-services
- aws-amplify
- aws-cdk
- aws-cloudformation
- aws-iam
- aws-lambda
- aws-step-functions
- gsap
- node.js
- pdf.js
- react
- three.js
- typescript
- vite