Project 02 / 04
Amar Dokandari
Retail management for small shops
A point-of-sale and shop management app for small shops in Bangladesh, run from a phone, in Bangla and English.
About the project
Amar Dokandari is a multi-tenant point-of-sale and shop management web app. A shop owner registers, adds branches and staff, and runs the whole business from a phone: selling at the counter, tracking stock, buying from suppliers, keeping customer credit (khata), recording expenses and reading profit reports.
The counter takes barcodes, discounts with a limit per role, coupons, VAT and split payments across cash, bKash, Nagad, card and bank, and prints 58 mm and 80 mm receipts. It keeps selling without internet and syncs later. Behind it sit stock across branches and warehouses, purchase orders and supplier dues, sales on credit, returns, an audit log, and owner, manager and cashier roles per branch. It installs as a PWA and sends push notifications.
Three things I took from it. Put a rule where it cannot be skipped: tenant isolation and ledger immutability live in the database, not in code review. Derive, don't store: computing dues and payment status from the ledger removed a whole class of bugs where the numbers don't match. And write decisions down: short decision records and a shared glossary kept the design consistent across months of solo work.
Challenges
The hard problems of this project, and how each one was solved.
- 01
Keeping every shop's data private in one shared database
PostgreSQL row-level security. Every merchant-owned table gets its policy at startup, and the API connects as a database role that cannot bypass it, so the database itself refuses to return another shop's rows, even if the code forgets a filter. A test suite tries to read across shops and must fail.
- 02
Numbers that always add up
A double-entry ledger from day one. Every sale, payment, purchase, expense and refund posts balanced journal lines; dues, cash and profit are queries on the ledger, never stored fields. Corrections are reversing entries, and the API's database role has UPDATE and DELETE revoked on ledger tables, so history cannot be rewritten, even by a bug.
- 03
Selling when the internet drops
The client generates the order's ID and checkout is idempotent, so a retried or later-synced sale never creates a duplicate. Offline sales get a temporary receipt number, queue on the device and sync when the connection returns, with the sync status visible to the cashier.
- 04
One event, counted once
One Order record for every channel, in place of separate Sales and Orders modules. A POS checkout is an order created, paid and fulfilled in one step; a sale is a completed order in reports. Payment status is not stored: it is computed from the ledger, so collecting a due never touches the order.
- 05
Knowing the real profit when costs keep changing
A moving weighted average cost per product variant. Stock that comes back through a return or void is averaged in at the cost it was sold at, so stock value always matches the ledger. Negative stock is allowed and uses the last known cost, because a real shop sells first and does the paperwork later.
- 06
Two codebases, one contract
Building the C# backend writes an OpenAPI document, and the TypeScript front end's typed client is generated from it. The front end holds no business rules and calls the backend only through that client, so a breaking API change is a compile error, not a production bug.
- 07
Trusting changes as a solo developer
About 150 tests drive the real HTTP API against a real PostgreSQL started in Docker, with no mocked database. A Playwright smoke test walks a phone-sized browser through registering a shop, selling, printing a receipt, collecting a due, taking a return and reading the report. One script runs everything before each commit.
