Selected work / Chapter 02

Mizan ميزان

Arabic for “balance” — the instrument, and the idea of a fair, traceable measurement

Testing, inspection & certification

Testing, inspection and certification records for ISO/IEC 17025 labs

A platform for inspection and calibration bodies: offline field inspections on JSONSchema-driven forms, a strict sign-off chain with separation of duties, and signed PDF certificates anyone can verify by QR code.

Open live demo Demo password Mizan#2026 · roles to try
Used by
Inspectors, Technical reviewers, Quality managers, Laboratory admins, Plant safety officers and clients
Built with
Angular 21 · Django 5.2 LTS · Django REST Framework · PostgreSQL 16 · Celery + Redis · Docker Compose · JSONSchema · ReportLab · Ed25519 · Angular service worker
Languages
English and Arabic, with full right-to-left layouts
Source
Private repository — available on request by email
Mizan approval screen where the quality manager reviews a pressure-gauge calibration before signing the certificate.
Fig. 1 Quality-manager approval of a pressure-gauge calibration

The problemWhat the operation is up against.

Inspection and calibration bodies in the Gulf’s industrial cities — Jubail, Yanbu, Mussafah — work for petrochemical plants, ports and utilities whose safety officers must trust a certificate on sight. Most of these laboratories still run on paper checklists, spreadsheets and PDFs assembled by hand.

Accreditation under ISO/IEC 17025 asks for things paper handles badly: reference instruments that were in calibration on the day of the work, segregation of duties between whoever measures, reviews and signs, a complete record of every change, and certificates nobody can quietly edit afterwards. And inspectors work inside plants, switchgear rooms and offshore sites with no network.

Who uses it5 roles, one system.

  • Inspectors

    Run inspections on a phone or tablet, offline, on forms that refuse an expired reference instrument, with photos stamped with GPS, heading and time.

  • Technical reviewers

    Check results and sign off, or return the job with revision notes.

  • Quality managers

    Approve as the signatory, re-entering their password, which issues the signed certificate.

  • Laboratory admins

    Maintain the reference-standards register and the form library, and verify the audit chain.

  • Plant safety officers and clients

    Scan the QR code on a certificate to check that it is genuine and unaltered.

What was builtThe working parts.

  • Forms from JSONSchema

    Inspection templates are JSONSchema 2020-12 with rendering hints — Arabic labels, units, photo slots, acceptance criteria. An Angular engine turns any schema into nested reactive forms, and a builder edits drafts with a live preview. The library covers ultrasonic thickness surveys, torque-wrench calibration, crane load tests and pressure-gauge calibration.

  • Versioned, immutable templates

    Publishing version N+1 supersedes N in one transaction; published versions cannot be edited, and every order pins the exact version and its schema hash, so old certificates re-render and re-verify.

  • Offline inspector app

    Orders, templates and the standards register are cached on the device. Saves, photos and submissions queue in an outbox with device IDs and device time, and sync on reconnect, every 30 seconds and through Background Sync.

  • Reference-instrument checks

    Picking a master instrument whose calibration has expired, or that was withdrawn, blocks the run on the device and on the server. Offline runs are judged on the day they were performed, and the register shows every order measured with each instrument.

  • Evidence photos

    A GPS fix is mandatory and the compass heading comes from the device or a hand-bearing compass. Time, position, heading and order number are burned into the image, and the server re-checks them.

  • Sign-off with separation of duties

    Inspector → technical reviewer → quality manager. Nobody reviews their own inspection, the signatory is never the inspector or the reviewer of that order, and each must be authorised for the discipline.

  • A hash-chained audit trail

    Every change is an append-only entry with field-level diffs. Entries form a SHA-256 chain per laboratory; a verification endpoint names the first altered or missing entry, and a database trigger rejects updates and deletes.

  • Signed certificates, public verification

    At approval the certificate content is frozen as canonical JSON, hashed with SHA-256 and signed with the laboratory’s Ed25519 key. The vector PDF carries results charts and a QR code to a public page that reports authentic, altered, revoked or link mismatch — re-checking the payload hash, the signature, the live record and the PDF hash.

Design rulesThe rules it keeps.

The decisions that make the system trustworthy, enforced on the server and in the database rather than left to the screen.

The server is the authority.

The app runs a TypeScript mirror of the evaluators for a live offline preview, but the numbers stored and printed are computed in Python on the server.

Field facts are judged when they happened.

A run synced two days late is validated against the instruments’ calibration on the day it was performed, not today.

Certificates print the signed payload, never live rows.

A re-render reproduces exactly what was approved, and verification compares the live record with the payload to catch edits made behind the application’s back.

The QR hash is the capability.

Certificate numbers are guessable; the full SHA-256 in the link is not, so the public page never shows a certificate without it.

ArchitectureHow it fits together.

An Angular app with a service-worker inspector PWA, a Django REST API, Celery workers that render certificates, and PostgreSQL holding forms and results as JSONB.

Front end
Angular 21 (standalone, zoneless, signals), a recursive JSONSchema-to-reactive-forms engine, a TypeScript mirror of the evaluators with SVG charts, a Dexie outbox and the Angular service worker.
API
Django 5.2 LTS and Django REST Framework; role permissions enforced again inside the workflow service; canonical JSON, SHA-256 hashing and Ed25519 signing with a key derived from a secret, never stored in the database.
Documents
Celery workers render multi-page vector A4 certificates with ReportLab; a daily digest e-mails instruments coming due for calibration.
Data
PostgreSQL 16: JSONB with GIN indexes for schemas and field data, row-level security per laboratory, triggers that make issued certificates and approved orders immutable.
Delivery
Docker Compose with NGINX serving the PWA and protected media, Gunicorn, Celery worker and beat. CI runs pytest against PostgreSQL, the Vitest suite, the production build and a Trivy scan.

Quality evidenceTested where it matters.

  • 87 backend tests (pytest); the row-level-security and trigger tests run against PostgreSQL in CI. Ruff lint and format checks and a migration-drift check.
  • 29 frontend unit tests (Vitest) covering the evaluator mirror, the schema-form engine, the offline outbox and English/Arabic translation parity; the production build enforces bundle budgets.
  • GitHub Actions runs both suites, builds the backend and web images and scans them with Trivy.

ScreensOn the desk and in the field.

Redesigned around laboratory rigour and documentary trust: ink navy on warm paper, with an oxblood seal colour reserved for signatures and certificates. Records read like documents of record, queues are dense sortable tables, and each order’s state is a small three-step sign-off meter that reads without colour. IBM Plex Sans and IBM Plex Sans Arabic for the interface, Source Serif 4 and Noto Naskh Arabic for titles — the same fonts are embedded in the PDF certificates.

Try the demoSign in as any role.

The demo runs on realistic seeded data, with a second tenant to show that one customer never sees another’s records.

The sign-in page offers each demo role in one click, and the demo data resets every night at 00:30 UTC.

Demo users
UserRoleWhat to try
inspectorInspectorOn a phone-sized window: pick the expired gauge UTG-YNB-02 and watch the run block, switch instruments, fill the thickness grid, take a photo, go offline, submit, reconnect.
inspector2Calibration technicianFinish the torque-wrench calibration and watch the ISO 6789-2 results update.
reviewerTechnical reviewerSign off the crane load test, or return it with revision notes.
qmQuality managerApprove the pressure-gauge calibration with password re-entry, then open the certificate and its public QR page.
seniorInspector, reviewer and signatoryHolds all three roles, yet cannot review an inspection they performed or approve one they reviewed.
adminLaboratory adminStandards register and reverse traceability, form builder, audit-chain verification.
mls_adminAdmin of a second laboratorySees none of the first laboratory’s data.

Password for every demo user Mizan#2026

  • Certificates are English-only, as is common practice in GCC testing and inspection; the interface is fully bilingual.

Out of scopeNot built yet — on purpose.

  • Arabic text on the PDF certificates — the interface is bilingual; certificates are in English.
  • A hardware security module or cloud KMS for the signing key.
  • Per-person cryptographic signatures — the laboratory key signs after the quality manager re-authenticates.
  • A drag-and-drop form designer — the builder edits JSONSchema with a live preview.

Work togetherNeed a platform like Mizan?

Tell me about the operation and the rules it can’t break.

Also on GitHub