Book a call
Choose how to read this case

Client workBuilt for an external organization under a paid engagement.

Architecture, system rules, decisions & documented evidence.

← All workProduct case file / 010
HealthcareMulti-tenant SaaSArabic RTLContract-tested

PHARMACY WEB / صيدليتي

Pharmacy. Web

A pharmacy counter runs on a till that cannot be wrong: dispense, check interactions, take payment, and keep the books straight — in Arabic, with the money stored as text.

System snapshotPHARMA / RTL

15

Bounded-context modules

19,4

Money precision

03

Enforced boundary rules

00

Domain data in localStorage

Data path

POS cart → API + contract → Server total

Module count is the src/modules directory; the 19,4 is the NUMERIC precision the contract specifies for money.

Role: Product & frontend architectureDomain: Pharmacy / POS2026

Have a similar product or workflow in mind?

Tell me what you need and we can define deliverables, timing and cost. A finished brief is optional.

Discuss your project →
Pharmacy Web — token-driven interface kit
Interface kit — token-driven, RTL-firstCONTRACT / 2026

01 / The challenge

A till is a financial system that a tired person operates at 11pm.

Retail software fails in a specific way: not by crashing, but by being slightly wrong. A total rounded on the client, a payment posted twice after a flaky connection, a credit balance written by a screen that should only read it.

Pharmacy adds a second layer. Dispensing has rules the software must respect — an interaction block is not a warning toast, it is a stop that a pharmacist has to consciously override, and the override itself has to be recorded.

This is the web frontend for a pharmacy SaaS platform, written against a CTO architecture decision document and an API contract specification. The interesting work is not the screens — it is making the rules impossible to bypass.

Core decision: the server owns every number. The client may preview a total, but it never posts one — and it never posts twice, because every financial call carries an idempotency key.

02 / Architecture

Fifteen modules, three iron rules.

The boundary rules are not a convention in a wiki — `npm run boundaries` fails the build when one is crossed.

01

POS & sales

modules/pos · modules/sales

Cart state in Zustand (the only place it lives), POST /sales with the DUR gate in front of it, and a payment panel that reflects server truth.

02

Inventory & FEFO

modules/inventory · …/grn

Stock, batches and GRN posting — with first-expiry-first-out allocation, which is a clinical requirement before it is an accounting one.

03

Finance & ledger

modules/finance · modules/customers

Customer statements and payments. The balance is read-only in the UI: it renders from the statement endpoint and there is no path that writes it.

04

Identity & tenancy

modules/identity · lib/auth

Tenant identity lives in the JWT. pharmacy_id is never sent from the client, so a manipulated payload cannot address another pharmacy.

POS cart

Zustand — UI only

→

API + contract

Idempotency-Key, uuidv7

→

Server total

The only authoritative number

Every financial or inventory POST is idempotent: a retried request after a dropped connection cannot double-charge or double-receive.

03 / Product decisions

Rules a compiler can check.

01↗

Money is a string, end to end

NUMERIC(19,4) survives the wire as a string. Client arithmetic exists for preview only; the server total is the one a receipt may print.

02↗

Every financial POST is idempotent

A uuidv7 Idempotency-Key rides on /sales, /finance/payments and /inventory/grn. The flaky-connection double-post — the classic retail bug — is designed out rather than tested for.

03↗

Module boundaries fail the build

Three rules, enforced by dependency-cruiser: cross-module imports only via index.ts, components/ui never imports modules, and pages hold no logic. Architecture debt cannot be merged quietly.

04↗

A DUR block is a stop, not a toast

Error codes drive the interface. DUR_BLOCK opens a pharmacist PIN-elevation modal and only then retries the request with an explicit override — so the override is an auditable act.

05↗

Tenancy is never a client field

pharmacy_id arrives inside the JWT and nowhere else. There is no request shape a malicious client can edit to reach another tenant's data.

06↗

Storage is for session, not domain

The session token lives in sessionStorage and domain data is never put in localStorage. A shared pharmacy terminal is a shared machine, and the browser should not remember a previous patient.

04 / Routes

Five surfaces, one contract.

Auth

Login and the PIN-elevation path used when a dispense trips the DUR gate.

Dashboard

The guarded shell — sidebar per the design system, with revenue/inventory signals where a pharmacist actually looks.

POS

Search via the catalog facade, cart, payment panel, receipt printing.

Inventory

Stock levels, FEFO batches and GRN posting for received shipments.

Customers

CRM list, a per-customer page and a ledger statement that is read-only by construction.

05 / Evidence

The repository argues with itself, and wins.

15

Modules under boundary rules

from repo

03

Rules enforced in CI, not prose

from repo

41

Runtime dependencies

from repo

STRICT

TypeScript mode

from repo

Module count and boundary rules come from src/modules and the README's own boundary section; dependency count is package.json's runtime list.

Contract tests (tests/contract) and an e2e smoke spec ship in the repo. They are not re-run here, and this file makes no claim about their current pass rate.

No pharmacy count, patient count or revenue figure is claimed — the frontend repository contains no production data.

06 / Technology stack

Boring where it counts.

Next.js 14TypeScript (strict)Tailwind (token-driven)TanStack QueryZustandRadix UIZodCairo typefaceArabic RTLdependency-cruiserVitestPlaywright

Twenty runtime dependencies, chosen for state, forms, dialogs and validation — nothing exotic, because a till has to be predictable.

HAND-OFF / 010

The receipt is the contract.

Next: offline-first dispense queue for a dropped connection, with the same idempotency key replayed on reconnect rather than a new one.

Switch Reading Lens · 02

Want the practical business breakdown—what this project does, how it runs, and its core advantages?

Have a similar product or workflow in mind?

Tell me what you need and we can define deliverables, timing and cost. A finished brief is optional.

Discuss your project →

NEXT CASE ↳ FROM THE FILES

Youssef Guba