Back to Projects

Tasyir Pro

A multi-tenant retail SaaS that takes a shop from supplier purchase to legal invoice — catalogue, stock, point of sale and payments, in French, Arabic and English.

Current2026

Duration

May 2026 – Present

Contributors

3 contributors

Technologies

10+ tech

Tasyir Pro

Tasyir Pro is a multi-tenant retail management platform live at tasyirpro.com. It gives small shops — electronics, office supplies and similar stores — one place to run the whole cycle: supplier purchases, catalogue, stock, point of sale, payments and legal invoices, in French, Arabic and English.

The problem#

Small retailers in Morocco often run on three disconnected tools: a spreadsheet for stock, a paper receipt book at the counter, and a separate program — or an accountant — for invoices. Each one is a source of drift. Stock in the spreadsheet stops matching the shelf, prices on receipts stop matching what the supplier last charged, and invoice numbers get skipped or duplicated, which is a legal problem rather than a cosmetic one.

The goal of Tasyir Pro is to replace all three with one application in which every number has exactly one origin: a purchase sets the cost and the sell price, a sale decrements the stock it actually moved, and an invoice can only exist as the outcome of a validated sale.

What it does#

  • Catalogue with variants and codes — every variant is a full sellable product, each product can carry several QR or EAN codes, and SKUs are generated from a configurable pattern
  • Purchasing — supplier purchases with HT/TTC lines and supplier discounts; receiving goods updates stock and the weighted average cost
  • Configurable pricing — the shop chooses how sell prices are derived from purchases, and how far a cashier can discount
  • Sales and POS — barcode scanning, including a phone used as a wireless scanner; a capped customer discount with a logged manager override; stock that can never go negative
  • Payments — cash, card, transfer, cheque and customer credit, with allocations across documents, per-customer credit limits and reminders for cheques coming due
  • Legal invoicing — delivery notes, invoices and credit notes numbered from an unbroken per-series yearly sequence, grouped invoices, and frozen legal mentions (ICE, IF, RC, Patente)
  • Team and permissions — owners, managers and staff, with sensitive changes recorded in an audit log
  • Three languages — French, Arabic (right-to-left) and English, in the app and in printed PDF documents

Architecture#

Tasyir Pro is a Next.js App Router application organised in feature modules with strict dependency rules between layers:

app/ (pages, route handlers, server actions)
   │  parse and validate input, call one service
   ▼
service.ts     business rules, permissions, transactions
   │
   ▼
repository.ts  Prisma queries, scoped to the current shop
   │
   ▼
PostgreSQL     composite (shopId, id) keys

Lint rules enforce the layering: pages never touch the database, and only repositories import Prisma. That sounds bureaucratic for a single Next.js app, but it is what makes the tenancy guarantee below enforceable — if any file could import the database client, any file could forget the shop.

Around that core: documents are rendered to PDF with React PDF in all three languages, uploaded files and attachments live in Vercel Blob, rate limiting runs on Upstash Redis, and input validation uses Zod schemas derived from the same resource declarations the UI uses.

Tenant isolation in the data layer#

One installation hosts many shops. The classic way to do that is a shopId column and a where: { shopId } on every query — which works until the one query where someone forgets it. A single missing filter in a multi-tenant app is a data leak, and code review is not a reliable place to catch an absence.

So isolation does not depend on remembering:

  1. Repositories never receive the global Prisma client. They receive a tenant-scoped client that adds the current shop to every read, update and delete, and checks it on every create.
  2. The unscoped client refuses tenant models outright, so the escape hatch isn't silently available.
  3. Lint rules stop everything outside repositories from importing the database at all.
  4. In PostgreSQL, tenant tables use composite (shopId, id) keys, and foreign keys include the shop. A sale line from shop A physically cannot reference a product from shop B — the database rejects it, whatever the application code does.

The last layer is the one I value most. The first three make mistakes unlikely; the fourth makes a whole class of them impossible.

Moroccan invoices must follow an unbroken numbering sequence per series and per year, and carry the company's legal identifiers. That turns out to be one of the harder parts of the system.

  • Documents use separate series — delivery notes (BL-), invoices (FA-) and credit notes (AV-) — each numbered from an atomic per-shop sequence per series and year, so two cashiers validating at the same instant can't get the same number or leave a gap.
  • A document can't be dated before the last validated one in its series. Backdating is allowed — shops do enter yesterday's sales — but never in a way that breaks chronological order.
  • Validated invoices are read-only. Corrections go through full or partial credit notes, which return goods to stock unless the goods are marked as damaged.
  • Each invoice freezes the company's legal identifiers (ICE, IF, RC, Patente) at the moment it is issued, so changing the shop's settings next year doesn't rewrite last year's invoices.
  • Several delivery notes can be grouped into a single invoice for business customers billed monthly.

Money without floating point#

Every amount goes through decimal.js with explicit scales and rounding rules — never JavaScript numbers or database floats. Prices, discounts, HT/TTC conversions and totals all compound, and floating-point error that is invisible on one line becomes a one-centime mismatch between an invoice total and the sum of its lines. On a legal document, that is not acceptable.

Quantities are decimals too, so a shop can sell by the metre or the kilogram, and the "no negative stock" rule applies to fractional quantities the same way it applies to whole units.

A resource framework instead of hand-written screens#

A retail back office is dozens of resources — products, brands, categories, suppliers, customers, purchases, sales, payments — and each one needs a paginated list, simple and advanced search, a full-page form, internal comments with attachments, and a printed layout.

Rather than writing each of those screens by hand, each resource is declared once in a fields file. Validation schemas, search filters, list columns, form layouts and print fields are all derived from that declaration. Adding a field means changing one file, and the list, the form, the search and the PDF all agree on it automatically.

Rebuilding without stopping delivery#

The current version is a full rebuild of the first release. The prototype proved the product, but its structure couldn't carry the requirements that came from a real client's daily use: configurable pricing strategies, a discount cap a cashier can't exceed but a manager can override, decimal quantities, and strict tenant isolation.

The client was already waiting to run their shop on it, so a long rewrite in the dark wasn't an option. The rebuild was split into small steps the client validated one at a time — the resource framework, then the catalogue, purchasing, sales, and finally legal documents — and the proven parts of v1 were carried over rather than rewritten: the tax helpers, scan de-duplication and the PDF components.

Results#

  • Live at tasyirpro.com, shaped by the day-to-day requirements of a real client shop
  • Rebuilt from the first release in small, client-validated steps on a modular, tenant-safe architecture
  • Invoicing built for Moroccan shops — unbroken yearly numbering, credit notes, and ICE, IF, RC and Patente frozen on every invoice
  • Fully usable in French, Arabic (RTL) and English, including printed documents

Team#

Built with Hassan Outhami and Younes Ramchoun.

Share:Share on Twitter / XShare on LinkedInShare on Facebook

More Projects

Dr Maroc
2024Current
A healthcare SaaS live at drmaroc.com, grown from a single app into a platform: four Angular portals in one Nx monorepo, a modular Spring Boot backend, self-hosted Keycloak, shared contracts, and a delivery pipeline where GitHub is the source of truth.
AngularNxNext.js+8
ngx-auth-client
2026Current
A published npm package that exposes Angular authentication as signals instead of getters, ships Keycloak and HTTP adapters behind a provider-agnostic port, and keeps tokens out of localStorage entirely.
AngularTypeScriptKeycloak+7