LiveIndependent · B2B SaaS2026

Diwan ديوان

White-label correspondence management for government and large companies · v3.0 · live demo

34% → 82%letters routed to the right department, held-out test
01The problem

Why it exists

Every Saudi organisation runs a correspondence office (الاتصالات الإدارية). Diwan numbers, routes, approves and tracks every letter until it is filed, for many organisations on one system, each with its own name, colours, logo, letterhead and numbering. Built as a product: a rules engine, analytics, an admin console and the security a regulator would ask about.

02The system

What I built

Incoming lettergap-free Hijri numbering
Semantic routingembeddings + past letters
Letter assistantsummary and draft reply
Approval and sealSHA-256 + QR verify
Audit loghash-chained
  1. Incoming, outgoing and internal letters with gap-free Hijri numbering; referrals with instructions and working-day SLAs that escalate to managers
  2. Semantic routing: multilingual embeddings compare a letter with department profiles and with the organisation's own past letters (class-balanced), combined with a word model and calibrated, plus an admin rules engine
  3. An AI letter assistant: amounts, deadlines and requested actions extracted without any model; a summary and draft reply with the free Groq tier; contained and off modes, and confidential letters never sent without permission
  4. OIDC single sign-on (Microsoft Entra-ready, no automatic accounts because access depends on clearance), SSO-only mode, sign-in throttling, network allow-lists, CSP and HSTS
  5. Approvals with time-boxed delegation (تفويض), and signed letters sealed with SHA-256 and a QR code anyone can scan to verify
  6. Clearance plus need-to-know access, a hash-chained audit log, split inbox, ⌘K command palette, analytics and a full admin console
  7. "Likely late" warnings from how long each department's past referrals actually took, conditioned on how long a letter has been open
03The result

What it achieved

Routing on 100 held-out letters: right department first rose from 34% to 82% and from 39% to 77%; it is in the top 3 for 97–98% (published with every miss). 43 end-to-end checks pass on the live system, including tenant isolation, delegation revocation and public verification. Tamper drills: editing a signed letter or a past audit entry directly in the database is detected. The end-to-end suite caught a real defect before release (signatories could not see letters awaiting their own approval). In a back-test the riskiest 20% of referrals held 50% of the late ones against 23% overall (AUC 0.64), so it is shown as a badge, not a percentage.

Stack

TypeScriptCloudflare WorkersD1 (SQLite)Multi-tenantNaive Bayes routingSHA-256 sealRBAC

Timeline

2026

My role

Solo build