Executive System Architecture Summary
APEX is engineered as a Dual-Client B2B SaaS Platform (React Web SPA + React Native Expo Mobile Client) powered by a Metadata-Driven Calculation Engine and a 33-Table PostgreSQL Relational Spine. Every saved estimate atomically snapshots its formula version, material prices, waste margins, and live USD-to-DZD exchange rates.
- Zero-Deploy Dynamic Formula Engine: Administrators configure N civil engineering categories, equations, and dynamic input fields directly from the database without code deployments.
- Transactional Cost Snapshotting: Atomic PostgreSQL transactions freeze unit prices, waste factors, and FX rates to protect historical budgets from market volatility.
- Cross-Platform Field & Office Clients: Shared API contracts serving a responsive React Web SPA and a 35+ screen Expo SDK 52 mobile client with full Arabic RTL mirroring.
- SaaS Quota & AI Governance: Subscription middleware enforcing per-tier project limits and metered Groq LLaMA-3.3-70B engineering consultations.
End-to-End Dual-Client Runtime Topology (Hover over any node to trace connections)
Unified Express API serving both React SPA (Web) and React Native (Expo 52) clients with live USD-to-DZD synchronization.
Interactive SVG · Hover nodes to inspect paths
Relational Estimation Spine & Transactional Snapshot Model (Hover tables to highlight foreign-key links)
Each leaf calculation executes inside a single SQL transaction, freezing formula versions, material waste margins, and currency rates.
Interactive Schema Spine
33-Table Relational Schema Inventory
| Functional Domain | Core Tables | Count |
|---|---|---|
| Identity & Auth | users, refresh_tokens, password_reset_tokens |
3 |
| SaaS Entitlements | plan_types, plans, features, subscriptions |
4 |
| Estimation Spine | projects, estimation, project_details, estimation_detail_material, estimation_detail_service |
5 |
| Dynamic Formula Engine | categories, formulas, formula_output, field_definitions, field_types, units, coefficients |
7 |
| Price Catalog & FX | material_config, resource_catalog, service_config, financial_settings, exchange_rate_log |
5 |
| Bilingual Content Hub | articles, article_types, tags, article_tags, likes, saves, predefined_questions, app_translations |
8 |
| AI Consultation Audit | ai_usage_history |
1 |
| Total Architecture | 7 Cohesive Business Domains | 33 |
Core Engineering Pillars & Client Capabilities
| Subsystem | Architectural Implementation |
|---|---|
|
Dynamic Engine Zero-Deploy Formulas |
Evaluates NON_MATERIAL and MATERIAL expressions dynamically at runtime using database-driven field_definitions and coefficients. |
|
Mobile Engineering 5-Tier Expo SDK 52 App |
Built across 5 decoupled layers (Presentation, Hooks/Context, Services, API Mappers, Infrastructure) with 35+ screens and native PDF export via expo-print. |
|
Resilience Silent Token Lifecycle |
Axios request/response interceptors inject Bearer tokens and automatically execute silent 7-day refresh cycles on HTTP 401 without interrupting field workflows. |
|
Localization Full RTL & Bilingual JSONB |
Complete Arabic Right-to-Left (RTL) layout mirroring alongside English, backed by bilingual database columns and localized AI assistant responses. |
|
FX Resilience 3-Tier Currency Fallback |
Fetches live USD-to-DZD rates with a 3-second timeout, applies administrative market_factor multipliers, and falls back to cached exchange_rate_log entries offline. |