🌐 English · العربية → · Bilingual index
Qwizin — Architecture Documentation
Status: Draft v0.1 · Date: 2026-07-20 · Tech Lead: Amir Haroun Scope: Research and design documentation only. No implementation has been started.
🧭 Open the NAVIGATOR →#
Document map · find-by-question index · feature → data-flow index · identifier registry · all 25 open questions · risk quick-reference · status board.
⛔ Read First — Four Blockers#
These must be resolved before engineering begins. Three require Saudi legal counsel, not further research.
| # | Blocker | Why it blocks | Owner |
|---|---|---|---|
| 1 | SAMA licensing — does collecting buyer funds and disbursing to consultants require payment-institution authorisation? | Could invalidate the entire payments design. Go/no-go input, not a design detail. | Financial-services counsel |
| 2 | ZATCA e-invoicing — applicability, plus a hard architectural constraint | Invoice hash-chaining is stateful and strictly ordered — it conflicts with horizontal scaling. Unmentioned in every source document. | Tax advisor + Architect |
| 3 | Corrected roles & permissions matrix | SRC-BRD §11 is internally inconsistent (CONF-03). Authorization cannot be designed from it as written. |
Sponsor / BA |
| 4 | OQ-08 — are consultations recorded? |
Swings video infrastructure cost by ~80 % and changes the PDPL data classification. | Sponsor |
Do not spend engineering effort on payments or invoicing until 1 and 2 are answered. They determine what gets built, not merely how.
Reading Order#
Start here#
| Document | What it gives you |
|---|---|
00-requirements-baseline.md |
Distilled requirements from all 12 source documents. Actors, modules, constraints, and the five contradictions found in the sources. Traceability root — every other document references its identifiers. |
01-quality-attribute-scenarios.md |
21 measurable scenarios replacing the adjectives ("secure", "scalable") in the source docs. Establishes that the system's dominant qualities are not the ones the documents emphasise. |
arc42/11-risks-and-technical-debt.md |
16 ranked risks. Read this before the design documents — several change what is worth designing. |
The architecture#
| Document | What it gives you |
|---|---|
arc42/03-context-and-containers.md |
C4 Level 1 (system context) and Level 2 (containers). External dependency register. Why not microservices, and what was deliberately deferred. |
arc42/05-building-block-view.md |
C4 Level 3. Twelve modules, their public contracts, the inter-module event catalogue, dependency rules — and the CI machinery that enforces them. Guards R-08, the only risk marked effectively irreversible. |
arc42/06-runtime-view.md |
The six architecturally critical flows. Auth & token lifecycle, document upload pipeline, booking→payment→consultation, assessment→certification, marketplace search, tenant-scoped access. |
arc42/06b-feature-flows-core.md |
Level-0 system data-flow map (4 pipelines) + flows F-01…F-09: registration by type, profiles, employee provisioning, activation state machine, consultant directory, on-site consultation, template catalogue, customized template requests, training assignment & progress. |
arc42/06c-feature-flows-commerce-admin.md |
Flows C-00…C-09: money-flow topology, consultation payment state machine, subscriptions & dunning, featured listings & ranking, payouts, admin roles & queues, content management, reporting/KPIs, notification fan-out. |
| arc42/07-deployment-view.md | Regions, environments, node pools, data tier, network topology, disaster recovery (in-Kingdom, no cross-border), launch capacity sizing. |
| arc42/08-crosscutting-concepts.md | Bilingual/Arabic handling, error contract, idempotency & concurrency, money/time/ID conventions, observability, configuration, testing strategy, retention & deletion. |
Deep dives#
| Document | What it gives you |
|---|---|
deep-dives/devops-containerization-orchestration.md |
Container strategy, K8s topology, three independent load-balancing paths, autoscaling signals per workload, CI/CD, staged hardening roadmap ordered by risk-reduction-per-hour. |
deep-dives/security-architecture.md |
Seven trust boundaries, tenant-isolation mechanism, upload pipeline, identity & authorization, assessment/certificate integrity, audit logging, STRIDE threat model, prioritised implementation order. |
Decision records#
| ADR | Decision | Status |
|---|---|---|
ADR-0001 |
Oracle Cloud Riyadh + Jeddah DR, in-Kingdom | Proposed — conditional on 4 verification items |
ADR-0002 |
Modular monolith over microservices | Accepted |
ADR-0003 |
Kubernetes, managed control plane | Accepted — with recorded reservation |
ADR-0005 |
Provider-agnostic video port; provider deferred | Proposed — conditional on OQ-08 + legal ruling |
ADR-0007 |
Shared DB + PostgreSQL RLS, five-layer enforcement | Accepted |
ADR-0004 (payment port), ADR-0006 (search engine), and the capacity/cost model are deliberately unwritten. Each depends on evidence that does not yet exist — a legal ruling, a measured Arabic bake-off, and provider quotes respectively. Writing them now would produce decisions with nothing behind them.
Baseline Decisions#
| Decision | Choice | Rationale |
|---|---|---|
| Hosting | KSA in-region — Oracle OCI Riyadh, Jeddah DR | Only provider with two GA in-Kingdom regions (real in-country DR); uniform global pricing vs Google Dammam's ~+88 % premium |
| Architecture style | Laravel modular monolith + extracted sidecars | Components with genuinely different scaling profiles (PDF rendering, malware scanning, search, media) are extracted — the real benefit of microservices, without the distributed-systems cost |
| Orchestration | Kubernetes (managed OKE) | Architect decision; operational burden recorded as R-09 |
| Clients | Mobile-first, web later | API-first backend; no BFF — one client type means a BFF is a proxy to itself |
| Backend | Laravel 13 + PHP 8.4, PHP-FPM (not Octane initially) | Octane's persistent workers materially raise cross-tenant leak risk (R-05) for performance the launch scale does not need |
| Database | PostgreSQL with Row-Level Security | Only tenant-isolation layer that fails closed regardless of application bugs |
| Video | Deferred behind a port | See ADR-0005 |
| Payments | Deferred behind a port | Blocked on OQ-01 and the SAMA question |
Findings That Overturned Assumptions#
Recorded because acting on the original assumptions would have produced a worse system.
- PDPL does not mandate in-Kingdom storage for private-sector personal data. Article 29 permits cross-border transfer under conditions (SCCs, BCRs, or accreditation, plus a risk assessment). In-Kingdom hosting remains correct — but because it eliminates the transfer-compliance workstream and pre-satisfies the CST government-data rule, not because it is legally forced. Sources conflict; counsel required.
- AWS has no verifiable GA region in Saudi Arabia. AWS's own documentation lists only Bahrain and UAE in the Middle East, contradicting several secondary sources claiming a January 2026 launch.
- LiveKit does not escape Kubernetes' hostNetwork constraint. Its own docs require host networking and one pod per node — architecturally identical to Jitsi's JVB. "LiveKit is the cloud-native one" is false as commonly stated.
- Recording destroys Jitsi's cost advantage. Jibri joins as a third participant, which forces 1-to-1 calls out of P2P mode and back through the bridge — killing the ~80 % saving and adding the most expensive tier. Both effects flow from one product decision (
OQ-08). - Meilisearch has no stemming and no query-time boosting, and its OSS build has no HA (replication and sharding are BSL-licensed Enterprise). Both matter directly for Arabic recall and for featured-listing monetisation.
- Laravel has no LTS. The last was version 6 (2019). Laravel 12's bugfix window closes 2026-08-13. An annual major upgrade must be budgeted as routine work.
Gate::beforereturningfalsebreaks every policy in the application — the intuitive way to implement "account must be approved" is a documented footgun that also disables super-admin review.
Source Documents#
The twelve files in the parent directory. Note that six of them — the SOP, HACCP, food-safety, and audit workbooks — are content specimens for the template library, not system specifications. Their structure matters for one reason: the audit workbooks are row-per-control checklists, signalling that "downloadable template" is a transitional form of what becomes an interactive digital audit instrument (SEAM-03).
Research Provenance & Limits#
This documentation is backed by parallel research across KSA cloud/regulatory landscape, video infrastructure, Laravel architecture patterns, and security/compliance.
Two honest limitations:
- The session's web-search budget was exhausted, and several research strands terminated early. Items that could not be verified against primary sources are explicitly marked UNVERIFIED throughout rather than filled in from memory. Cost figures and regulatory claims are precisely where a plausible-sounding wrong number does damage — none appear here unless retrieved or labelled as structural inference.
- Nothing here is a legal opinion. The SAMA, ZATCA, and PDPL sections are scoping frameworks and question lists for counsel, not answers.
Principal open verification items are listed in arc42/11-risks-and-technical-debt.md R-16.
Recommended Next Steps#
Before any code:
- Engage Saudi counsel on SAMA, ZATCA, and PDPL operational duties
- Obtain the corrected roles & permissions matrix (
CONF-03) - Rule on
OQ-08(recording) andCONF-01(training scope)
Cheap spikes that retire disproportionate risk: 4. Arabic search bake-off — 2–3 days, ~500 real listings, all four engines with a normalisation pipeline in front. One-way door. 5. Arabic PDF render — 1 day. Produce one real bilingual certificate and show it to an Arabic speaker. 6. Verify OCI region service matrix and CST registration class — hours, and gates ADR-0001
Build before the second module exists:
7. Enforcement harness — Deptrac (note: deptrac/deptrac, the old qossmic/deptrac is abandoned) + architecture tests + the two-tenant adversarial suite. Retrofitting boundaries onto six modules costs ~20× more.
8. Transactional outbox + EventBus interface — about a day, the cheapest extraction insurance available
9. RLS policies alongside the first tenant-scoped migration — adding RLS to a populated table needs a maintenance window
Deliberately not written yet — each blocked on evidence rather than effort:
| Artifact | Blocked on |
|---|---|
| ADR-0004 — payment port | OQ-10 SAMA ruling. The legal answer changes the payment topology, not just its parameters. |
| ADR-0006 — search engine | The Arabic bake-off spike. This is a one-way door that needs measured recall on real listings, not an opinion. |
| Capacity & cost model | OQ-08 recording decision + provider quotes. Video is the dominant variable cost and swings ~80 % on that one answer. |