Skip to main content

🏗️ 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:

  1. Experience Layer: A headless React/Next.js frontend providing RTL-native layout, dual calendar support, and mobile PWA workspaces.
  2. API Gateway Layer: Manages routing, rate-limiting, JWT signature validation (via Clerk), and transaction logging.
  3. Execution Layer (ERPNext Kernel): Frappe framework executing transactional business logic (GL postings, salary runs, stock entries) without modifications to ERPNext core files.
  4. 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.
  5. Intelligence Layer (AI Service): Private LLM inference nodes executing semantic search (RAG) and tool call orchestration inside Saudi borders.

2. C4 Level 1: System Context Diagram


3. C4 Level 2: Container Diagram