🏗️ System Architecture Overview
BayanCore is designed as a compliance-first, AI-native business operating system built on top of an ERPNext core. The system architecture separates user interaction, business execution, local compliance validation, and cloud infrastructure.
1. Bounded Contexts & Layers
The system is organized into five logical tiers:
- Experience Layer: A headless React/Next.js frontend providing RTL-native layout, dual calendar support, and mobile PWA workspaces.
- API Gateway Layer: Manages routing, rate-limiting, JWT signature validation (via Clerk), and transaction logging.
- Execution Layer (ERPNext Kernel): Frappe framework executing transactional business logic (GL postings, salary runs, stock entries) without modifications to ERPNext core files.
- Compliance Layer (Guardian Service): An isolated microservice that intercept transactions (like invoices) to validate against Saudi regulatory schemas (ZATCA UBL 2.1) and signs them cryptographically.
- Intelligence Layer (AI Service): Private LLM inference nodes executing semantic search (RAG) and tool call orchestration inside Saudi borders.