Suriya fbfc02d140 Pull the catalogue from a real endpoint, with delta sync
Replaces the last simulation on the inbound side. RemoteCatalogueSource
returned SeedData after a fake progress bar; there was no wire format, no
endpoint, and no way to receive an update short of reinstalling.

Wire format (data/remote/catalogue_wire.dart)
- Tolerant where it should be: a catalogue of 4,000 products must not fail to
  import over one absent emoji, so optional fields take defaults and an
  unrecognised category files under Grocery — the item still scans, prices and
  bills.
- Strict where it matters: no id, name, barcode or price and the import fails.
  A silently dropped product is a shelf item that scans to nothing, discovered
  with a queue waiting.
- GST accepts 18 or 0.18 and reads both the same. Back offices disagree about
  which they mean, and getting it wrong silently changes the tax on every line.

HTTP source with paging and deltas
- GET {base}/catalogue?since={revision}&page={n}. Paged because a supermarket
  catalogue is tens of thousands of rows: one response times out on a shop's
  line and stalls the UI decoding it. Capped at 200 pages so a bad deployment
  cannot become an infinite request loop against a shop's connection.
- `since` carries the revision already held, so a normal morning fetches a
  handful of price changes rather than the whole book. A server that cannot do
  deltas ignores it and answers is_delta:false — the terminal reads the flag
  rather than assuming, so both work.
- A bad credential is non-retryable and says so, leaving the working catalogue
  in place so billing continues.

Applying deltas without losing local state
- A full snapshot withdraws what it omits; a delta must not. Read as a
  snapshot, the first morning price change would empty the shelf.
- Retired products are marked inactive, not deleted — order lines already
  recorded point at them, and a hard delete would orphan a bill's history.
- Locally registered shoppers survive a pull, as before.
- The unsynced-stock replay is now scoped to the products the pull actually
  overwrote. It exists because a server count predates local sales; running it
  over a delta that never carried that product would subtract those units a
  second time and quietly empty a shelf that is full. Both halves of that rule
  are tested.

MQTT stays the nudge, not the transport: a catalogue push on
pos/{store}/catalogue makes every terminal pull immediately, but the rows come
over HTTP, because a broker is the wrong shape for tens of thousands of them.

Tests: 210 -> 234. docs/sync-contract.md now covers both directions, including
a field-by-field table of what happens when something is missing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-01 15:37:42 +05:30
2026-07-29 11:41:53 +05:30
2026-07-29 11:41:53 +05:30
2026-07-29 11:41:53 +05:30
2026-07-29 11:41:53 +05:30
2026-07-29 11:41:53 +05:30
2026-07-29 13:06:39 +05:30
2026-07-29 11:41:53 +05:30
2026-07-29 11:41:09 +05:30

Nearle POS

An enterprise Point of Sale terminal for supermarkets, grocery stores, pharmacies and retail shops. Built for Flutter Desktop (Windows/macOS/Linux) and Android tablets.

Brand colour #662582 · Inter typeface · 16px corner radius · touch-first targets.


Getting started

flutter pub get
flutter run -d windows      # or macos, linux, or a connected tablet
flutter test                # 60+ unit and widget tests
flutter analyze

Requires Flutter 3.27 / Dart 3.6 or newer. See Version compatibility if flutter analyze complains about theme types.


Architecture

Clean architecture in three layers. Dependencies point inward only: presentation → domain ← data. The domain layer imports nothing from Flutter, which is what makes the pricing engine testable in isolation.

lib/
├── main.dart                    Entry point: orientation lock, store + audio warmup
├── app/
│   ├── app.dart                 MaterialApp.router, global shortcuts, text-scale lock
│   └── providers.dart           Dependency injection graph, cashier session, clock
│
├── core/
│   ├── constants/               Store details, GST rates, loyalty ratios, asset paths
│   ├── theme/                   Colours, 4pt spacing scale, typography, ThemeData
│   ├── router/                  GoRouter routes and page transitions
│   ├── services/                Barcode capture, scanner beeps, thermal receipt PDF
│   ├── utils/                   Formatters, validators, BuildContext extensions
│   └── widgets/                 GlassCard, PrimaryButton, NumericKeypad, StatusPill
│
├── domain/                      Pure Dart — no Flutter imports
│   ├── entities/                Product, Customer, Cart, SaleTransaction
│   ├── repositories/            Abstract contracts
│   └── usecases/                CheckoutSale
│
├── data/
│   ├── datasources/             LocalStore (swappable), seed catalogue
│   └── repositories/            Concrete implementations
│
└── presentation/                One folder per feature: screens / widgets / providers
    ├── welcome/  customer/  pos/  payment/  receipt/

Why the domain layer is pure

Cart is an immutable value object that computes every figure on the bill as a getter — subtotal, per-slab GST, membership discount, loyalty redemption, round-off, points earned. No widget, repository or provider participates in the arithmetic. That means the money maths is covered by fast unit tests with no pumpWidget and no mocking, and swapping LocalStore for Hive or a REST backend changes nothing above the data layer.


The five screens

Screen What it does
Welcome Three entry paths: New Customer, Existing Customer, Skip (walk-in). Vector illustration painted in code, so it stays crisp at 4K.
Customer Registration Mobile + name required; email, gender, DOB optional. Saves and drops straight into billing.
Existing Customer Large numeric keypad, auto-searches on the 10th digit. Shows name, tier, points and lifetime spend, or offers Register / Walk-in when nothing matches.
POS Dashboard Three columns: navigation, product grid, always-visible bill. Category chips, live search, barcode billing.
Payment Cash, Card, UPI, Wallet, Gift Card and arbitrary splits. Live change calculation with denomination shortcuts.
Receipt Success summary beside a paper-style preview. Counts down and starts the next sale on its own.

Fast cashier workflow

Barcode billing has no dialogs. BarcodeService listens to HardwareKeyboard globally rather than depending on a text field holding focus. It distinguishes a scanner from a human by keystroke timing — characters arriving faster than barcodeScanTimeout (120ms apart) are treated as a scan, so the cashier can still type into the same search box by hand. On a hit the item is added or its quantity incremented, a beep plays, and a floating toast confirms it. Nothing ever needs dismissing between items.

Other workflow details:

  • Tapping a product card bills it immediately; the card shows a live quantity badge.
  • Newest cart line renders first, mirroring what was just scanned.
  • Every mutation goes through CartController, so scanner input, taps and shortcuts share one code path — and one undo stack (F8).
  • Swipe a cart line to remove it.
  • F2 focuses search, Esc releases it.
  • Bills can be parked and resumed.
  • Stock is checked before adding, not after — an over-scan beeps and refuses rather than failing at checkout.

Pricing engine

Prices are GST-inclusive, per Indian retail convention, so tax is extracted rather than added.

  • Per-product GST slabs. Vegetables at 0%, milk at 5%, biscuits at 18%, aerated drinks at 28%. The receipt breaks GST out per slab, split into CGST and SGST.
  • Bill-level discounts are apportioned. When a membership discount or manual discount reduces the bill, the GST charged is scaled by the same factor rather than left at the pre-discount figure.
  • Membership tiers are automatic. Bronze / Silver / Gold / Platinum derive from lifetime spend and carry 0 / 2 / 5 / 8 percent off, applied without cashier action.
  • Loyalty. One point per ₹10 spent; each point is worth ₹0.25 on redemption. Redemption is capped at both the balance held and the bill value, and re-clamps automatically if the bill shrinks after points were applied.
  • Round-off to the nearest rupee is shown as its own line.
  • All money passes through an asMoney extension that rounds to two decimals, so floating-point drift never reaches a total.

Testing

flutter test
  • test/unit/cart_test.dart — the pricing engine: GST extraction, discount stacking, apportionment, loyalty caps, tier thresholds, round-off, and the guarantee that a payable never goes negative.
  • test/unit/checkout_test.dart — end-to-end sale completion against real repositories: stock decrement, invoice sequencing, split tenders, loyalty movement, and every rejection path. LocalStore.reset() re-seeds between tests so fixtures never leak.
  • test/unit/validators_test.dart — mobile/email/name validation and formatter output.
  • test/widget/primary_button_test.dart — button and status pill rendering, tap and busy states.

Swapping the data layer

LocalStore is a process-local map that stands in for a database. To move to Hive, SQLite or an HTTP API, implement the three interfaces in domain/repositories/ and rebind them in app/providers.dart:

final productRepositoryProvider = Provider<ProductRepository>(
  (ref) => HiveProductRepository(ref.watch(hiveBoxProvider)),
);

Nothing in domain/ or presentation/ changes.


Version compatibility

Two Flutter APIs used here moved recently:

  • ThemeData.cardTheme / dialogTheme take CardThemeData / DialogThemeData on Flutter 3.29+. On older versions, drop the Data suffix in lib/core/theme/app_theme.dart.
  • Color.withValues(alpha:) requires Flutter 3.27. On older versions substitute withOpacity().

Status and known gaps

This project has not been compiled. It was written in an environment without a Dart SDK or network access, so flutter pub get, flutter analyze and flutter test have never run against it. Verification was static: the import graph resolves with no missing or orphaned files, and every symbol referenced in the tests exists in lib/. That cannot catch type errors, signature mismatches, or drift in the pinned package APIs. Expect to fix a handful of issues on first build — the theme types above are the most likely.

Deliberately out of scope, stubbed as clear extension points:

  • Cash drawerReceiptService.openCashDrawer() logs the ESC/POS kick sequence but does not send it. Wire in your printer's serial passthrough.
  • AI product search — the search bar ranks by exact barcode, SKU, prefix then fuzzy match. No model is called.
  • Bottom navigation modules — Dashboard, Products, Inventory, Customers, Promos, Reports, Suppliers and Settings render with live badge counts but are not routed.
  • AuthenticationcashierSessionProvider holds a hardcoded session.
  • Sounds — the three bundled WAVs are synthesised placeholders. Replace with your own; SoundService swallows playback failures so a missing file never blocks billing.
Description
No description provided
Readme 1.5 MiB
Languages
Dart 94.7%
C++ 2.7%
CMake 2%
Swift 0.3%
HTML 0.2%
Other 0.1%