Live Demo: https://safy-platform-eg.web.app (Guest Mode available: explore without creating an account)
ملخص تنفيذي بالعربية
صافي (Safy) هو تطبيق ويب تقدمي (PWA) ثنائي اللغة ومُصمَّم بالأساس للغة العربية والاتجاه من اليمين إلى اليسار (RTL-First)، يهدف إلى تنظيم الميزانية الشخصية والمصروفات المشتركة في السكن التشاركي داخل مصر. يعمل التطبيق في بيئة تجمع بين النقد وInstaPay دون طلب بيانات بنكية أو تقديم استشارات استثمارية، مع لوحة عمليات للمُؤجِّر (/landlord) وبنية تشغيلية جاهزة لوكلاء الذكاء الاصطناعي بتكلفة إطلاق 0 دولار شهرياً وحجم حزمة دخول يبلغ 31.55 kB فقط (gzip).
1. Why We Built Safy
In Egypt's day-to-day economy, young professionals and students live in a hybrid cash + InstaPay reality. Bank-scraping aggregators fail here for two reasons: most shared flat expenses happen in cash or P2P transfers, and users rightly hesitate to hand over banking credentials.
Safy draws a strict boundary around personal budgeting and shared-flat expense organization:
- Personal Safe-to-Spend vs. Shared-Flat Float: Keep your true personal disposable balance isolated from pooled rent, utilities, and groceries ("who owes whom" across roommates).
- Sakan Ops: Structured flatmate settlements, recurring bill splits, and transparent balances without spreadsheets.
-
/landlordWorkspace: A dedicated, lazy-loaded workspace for small landlords managing rooms, leases, and maintenance logs. - Clear Product & Regulatory Scope: Strictly personal budgeting and shared-flat expense organization (no bank login and no investment advice).
2. Five CI-Enforced Non-Functional Requirements
Rather than treating performance, RTL quality, and portability as guidelines, we encoded five Non-Functional Requirements (NFRs) directly into CI gates:
- Entry JS Budget (
< 50 kBgzip): Currently31.55 kBgzip for the entry bundle. Every kilobyte matters on mid-range Android devices over congested 4G connections. - Zero-Tolerance RTL Hygiene (
lint:rtl):0violations enforced in CI. Physical CSS directional properties (ml-*,mr-*,text-left,right-0) fail the build; logical properties (ms-*,me-*,text-start,inset-inline-end) are mandatory. - Exact Monetary Math & FRA Guardrails: All money is stored and computed in integer piasters (
100piasters =1EGP), never IEEE-754 floats, alongside strict copy and feature guardrails compliant with Egypt's Financial Regulatory Authority (FRA) boundaries (no investment advice, no credit underwriting, no bank credential ingestion). -
$0/monthLaunch + Vendor Portability (check:portability): Built to run on free tiers at launch ($0/mo) while guaranteeing zero lock-in. Ourcheck:portabilitystatic gate scans114files with0violations to prevent cloud-specific SDK leakage into domain logic. - Solo-Founder Operability (
manual_onlyAI Ops): Operations cannot require 24/7 babysitting or runaway LLM bills. AI-assisted ops run inmanual_onlymode (0background tokens burned passively), keeping the founder in the loop.
3. Implementation Highlights
Zero-Dependency Sentry Poster (ErrorBoundary.tsx, lines 36–83)
Importing the official @sentry/react SDK blows up a sub-50 kB entry budget. Instead, ErrorBoundary.tsx (lines 36–83) implements a minimal, zero-dependency fetch poster directly to Sentry's /store/ endpoint with DSN parsing, stack formatting, and environment tagging in under 50 lines of TypeScript. That preserves production error visibility at effectively 0 kB overhead.
core.* vs. Private ops.* RLS Across 24 Postgres Migrations
Across 24 Postgres migrations, user-facing domain tables live in core.* protected by strict Row-Level Security (RLS) policies scoped to the authenticated user and flat membership, while operational telemetry, audit trails, and agent proposals are isolated inside a private ops.* schema inaccessible to standard client JWTs.
Dual-Auth admin-ops Edge API
Our admin-ops surface exposes a compact, agent-ready operational contract with dual authentication (founder JWT or scoped ops token):
-
GET /summary(< 2 KBpayload): Token-efficient operational snapshot designed so an AI agent or CLI can diagnose system health in a single tiny read. -
GET /tools: Self-describing operational capabilities manifest. -
manual_onlyExecution (0background tokens): Agents never spin autonomously in the background; actions execute only on explicit trigger. -
always_on_notifyProposals inops.admin_notifications: Deterministic backend triggers write structured proposals and alerts intoops.admin_notificationswithout invoking an LLM until the founder inspects them.
Decoupled @nawa/admin-kit & Route-Level Code Splitting
All admin UI primitives are isolated behind an AdminOpsAdapter interface inside @nawa/admin-kit. Combined with route-level lazy loading:
- Entry JS:
31.55 kBgzip - Lazy
/adminchunk:8.65 kBgzip - Lazy
/landlordchunk:8.47 kBgzip
4. Trade-Offs Table & Verified Numbers
| Dimension | Decision | Trade-Off Accepted | Verified Metric |
|---|---|---|---|
| Error Reporting | Custom /store/ poster in ErrorBoundary.tsx (L36–83) | No automatic breadcrumbs/replay | 31.55 kB entry JS gzip (< 50 kB budget) |
| Admin & Landlord UI | Lazy routes + @nawa/admin-kit (AdminOpsAdapter) | Slight first-navigation chunk fetch | 8.65 kB (/admin), 8.47 kB (/landlord) |
| Arabic / RTL Support | Logical CSS enforced via lint:rtl | Stricter lint errors during UI iteration | 0 RTL violations |
| Cloud Lock-In | Ports/adapters enforced via check:portability | Extra abstraction boilerplate | 114 files scanned, 0 violations |
| Database Isolation | core.* vs. private ops.* schemas + RLS | Explicit cross-schema SQL functions | 24 Postgres migrations |
| Workspace Health | Strict monorepo TypeScript project refs | Slower cold CI check vs. loose tsconfig | 11/11 packages passing typecheck |
| AI & Infra Cost | manual_only ops + always_on_notify triggers | No autonomous background triage | $0/mo launch cost (0 background tokens) |
5. Lessons for Solo Founders & Solution Architects
- Enforce NFRs as CI gates on Day 1, not "before launch." A
< 50 kBbundle budget or0-violation RTL rule only stays cheap if every PR is checked automatically. - Design operational APIs for agents and humans. A
< 2 KBGET /summaryendpoint andGET /toolscontract cost almost nothing to build, yet turn maintenance into a fast, low-token workflow. - Separate deterministic triggers from LLM inference. Writing proposals to
ops.admin_notificationsdeterministically keeps background token spend at0while preserving real-time awareness. - Build portability boundaries before you need to migrate. Scanning
114files withcheck:portabilityensures your$0/molaunch stack never becomes a permanent prison.
Try the live PWA (Guest Mode supported, no signup required): https://safy-platform-eg.web.app

