AI systems · Independent product

MehngaiLens

Turning a grocery receipt into a source-backed city comparison.

A Next.js and Flutter product that combines reviewed PBS grocery data, receipt extraction, and deterministic comparison logic across all 17 SPI cities.

About 9 min read

My role
Product, web, mobile & AI engineering
Platform
Next.js · Flutter · Vercel
Focus
Next.js · Flutter · Receipt AI
MehngaiLens receipt review, verified price catalogue, and mobile product views displayed across a laptop, tablet, and phone.
AI-composited editorial cover based on the live product interfaces. Original, unaltered production captures appear below.

The product and the problem

MehngaiLens helps a person compare a grocery basket against reviewed Pakistan Bureau of Statistics Weekly SPI city averages. A visitor can browse the verified catalogue, build a basket manually, or upload a receipt and review the extracted items before running the comparison. The result uses the same comparable item subset for the receipt and reference totals, then explains matches, exclusions, source rows, and the limits of the estimate.

I designed and built the web product, its comparison APIs, and a Flutter companion application around a deliberately narrow trust boundary. The version documented here uses a dated 5 November 2026 PBS snapshot covering all 17 SPI cities and 13 selected grocery references per city. AI assists with receipt extraction and optional plain-language explanation, while validated application code controls matching, unit conversion, benchmark selection, and arithmetic.

Live product screens

Live production captures retrieved 8 November 2026. They show the product overview, receipt-review workspace, and source-backed price catalogue. Select a screen to view the complete capture.

How the experience works

Start with a known city and a visible reference catalogue

The comparison begins with the city whose PBS average should be used. A visitor can inspect the catalogue before supplying any receipt, search the selected grocery references, and see the source date and city context attached to the data. This makes the benchmark visible before the product asks the user to trust a result.

The catalogue is intentionally narrower than a general shopping database. It represents 13 selected grocery references for each of the 17 Weekly SPI cities in the documented 5 November 2026 snapshot. That boundary keeps the first version auditable and prevents the interface from implying that every possible supermarket item has an official match.

Turn a receipt into a reviewable basket

A person can upload a receipt image or enter items manually. The extraction route returns candidate product names, quantities, units, line prices, and confidence information through a strict response schema. Those candidates appear in a review workspace rather than going directly into the comparison engine.

The review step is part of the product contract. Users can correct an item, remove an unrelated line, or continue manually when a receipt is unclear. This matters because optical and language ambiguity is normal in real receipts, particularly when English, Urdu, Roman Urdu, abbreviations, and shop-specific names appear together.

Compare only what can be matched responsibly

After confirmation, the engine normalizes each item, looks for an allowed alias, checks whether its unit can be compared safely, and selects the city-specific reference row. Successfully matched items form one common subset. The application calculates both the receipt subtotal and PBS benchmark subtotal from that same subset.

The result separates included and excluded lines, shows the source reference behind each benchmark, and can produce an optional plain-language explanation from the already validated result. A user can therefore understand why a total changed instead of receiving a single opaque label about whether their receipt appears high or low.

My contribution

  • Defined the product workflow from price discovery and receipt review through a transparent city comparison.
  • Built the Next.js interface, server APIs, PBS data import and provenance model, and deterministic comparison engine.
  • Integrated server-side receipt extraction with strict schema validation, guarded aliases, unit conversion, and a manual fallback.
  • Developed the Flutter companion for catalogue access and manual basket comparisons against the same public data contract.
  • Added automated checks for dataset integrity, conversions, city changes, comparable subsets, and exclusion handling.

Architecture and implementation

A versioned PBS import behind the catalogue

The data layer starts from a reviewed Weekly SPI snapshot. Import logic maps the selected grocery references into a consistent shape for all supported cities and retains row-level provenance used by the interface and API. Dataset tests check expected city coverage, reference counts, required fields, and known relationships before the data is treated as a valid release asset.

This creates a reproducible boundary between source material and product behavior. The comparison service consumes a versioned dataset rather than scraping an unversioned page during a user request. Updating the benchmark is therefore a deliberate publishing step that can be reviewed and tested before deployment.

An AI boundary that cannot control the money calculation

Receipt extraction runs on the server so provider credentials are not exposed to the browser. The provider is asked for structured candidate lines, and the response passes through schema validation before it can enter the review workflow. The model is useful for reading varied layouts, but its output remains untrusted application input.

Aliases and conversions are defined by code. The comparison engine decides whether a receipt line maps to a supported reference, which quantity is comparable, and which values enter each total. An optional explanation receives the completed validated result; it does not recalculate the basket or supply missing official prices.

One public data contract for web and Flutter

The Next.js application exposes the catalogue and comparison capabilities through server routes used by the web interface. A Flutter companion reads the public price endpoint and provides a manual basket-comparison journey on mobile. Sharing the contract keeps the reference data and core comparison semantics aligned across the two clients.

The documented version deliberately avoids account infrastructure and a receipt-history database. Browser work is kept in session storage, while uploaded receipt data is processed for the active request. That smaller persistence surface suits the current product scope and makes the privacy explanation easier to verify.

Key engineering decisions

Keep benchmark arithmetic deterministic

The model can extract candidate receipt lines and explain a completed result, but it cannot choose PBS prices, invent a match, or calculate the benchmark totals. Application code performs those decisions from validated inputs and versioned source rows.

Compare the same item subset

A receipt total and a city benchmark only become comparable when both use the same successfully matched items. Unmatched, ambiguous, or unsupported lines are excluded from both sides and remain visible to the user instead of silently changing the denominator.

Require review before comparison

Receipt extraction is treated as a draft. The workspace lets the user confirm names, quantities, units, and prices before the comparison runs, with manual entry available when the provider is unavailable or the receipt is difficult to read.

Challenges and trade-offs

Product names and units rarely match neatly

A shop may write a product in English, Urdu, Roman Urdu, a brand-specific form, or a shortened label. Even when the meaning is recognizable, a receipt quantity can use a unit that is unsafe to compare with the PBS reference. A broad fuzzy match would make the interface feel convenient while quietly reducing trust in the benchmark.

MehngaiLens uses explicit aliases and guarded conversions instead. Unsupported or ambiguous lines are excluded and explained. This favors a smaller defensible result over a larger total built from guesses, and it gives future dataset work a clear place to add a reviewed mapping.

A fair total needs a shared denominator

If the receipt total included every scanned item while the benchmark contained only supported items, the comparison would be misleading. The engine first identifies the comparable subset and then calculates both sides from it. Excluded lines are not hidden, so the user can see exactly which part of the receipt the result represents.

Changing the selected city also requires a complete recalculation from the same reviewed basket. Automated tests cover city changes and subset behavior because cached or partially updated benchmark rows could otherwise produce a plausible-looking but inconsistent result.

Explain usefulness without overstating the source

Weekly SPI values are city-level averages for a dated reference period. They are useful context, but they are not a live shelf-price service, an invoice audit, or evidence that a retailer has broken a legal limit. The product language, methodology, and result explanation all need to preserve that distinction.

The interface therefore pairs the comparison with the source date, included references, exclusions, and limitations. This turns provenance into a visible feature instead of leaving it in a footer that users may never read.

Validation and delivery considerations

Test the dataset and arithmetic separately from the interface

Automated checks cover dataset integrity, unit conversions, alias behavior, comparable subsets, exclusion handling, and recalculation when a city changes. These tests focus on the deterministic parts of the product where a small mistake can change a monetary result while leaving the UI visually correct.

The interface still needs its own journey review: browse prices, create a manual basket, upload a receipt, edit an extracted line, compare, change city, and inspect source details. Keeping calculation tests and experience tests separate makes it easier to identify whether a failure belongs to the data, engine, API, or presentation layer.

Design failure states as normal paths

The receipt provider may be unavailable, a file may be unreadable, or the schema response may be rejected. The product retains manual entry as a complete route rather than treating it as a hidden emergency control. An extraction failure should not remove work the user has already confirmed in the active session.

Validation also includes the no-match and partial-match outcomes. A result with exclusions needs useful language and source context, while a basket with no defensible matches should stop before presenting a misleading percentage. These states are central to a trustworthy comparison product.

Review privacy and source claims with every release

The deployed pages explain the dated data source, calculation method, receipt handling, and product limitations. Those statements need to stay synchronized with the implementation. Adding cloud history, a new AI provider, or a different source would change both the architecture and the public explanation.

For the current version, the review checks that provider secrets remain server-side, receipt uploads are not intentionally persisted by the application, browser state is session-scoped, and source references remain reachable from the relevant product journey.

What was delivered

A deployed Next.js product with a searchable price catalogue, manual basket builder, receipt-review workspace, deterministic comparison API, source references, optional AI explanations, and clear methodology and privacy pages. The same repository also contains a Flutter companion that reads the public price API and supports manual basket comparison on mobile.

Open MehngaiLens

Project scope

Data
Versioned 5 November 2026 Weekly SPI snapshot covering 17 cities and 13 selected grocery references per city.
Calculation
Validated aliases, guarded unit conversions, and equal-subset totals calculated by application code rather than the AI provider.
Privacy
No account or receipt-history database in this version; uploaded receipt data is processed for the active request and browser state uses session storage.

The reference values are dated city-level PBS averages, not live shop prices, invoices, or legal price limits. Receipt extraction depends on image quality and provider availability, so every extracted line requires review. The documented version does not provide accounts, cloud receipt history, or historical trend charts; browser state is session-scoped and the server does not intentionally persist uploaded receipts.

Key takeaways

  • AI can reduce receipt-entry work without being allowed to set official prices or control benchmark arithmetic.
  • A transparent comparison uses the same matched subset on both sides and keeps exclusions visible.
  • Versioned public data, explicit source limits, and reviewable failure states are product features, not supporting documentation.

Have a product in mind?

Let’s discuss the scope, the trade-offs, and a practical first step.

Discuss your project