Skip to main content
Version: 1.0.0-beta

Architecture

Modular monolith architecture with separate workers for async processing.

System Context

Component Architecture

Frontend (Next.js 14+)

AspectDetail
FrameworkNext.js 14+ with App Router
LanguageTypeScript 5+
StylingTailwind CSS v4
StateReact Context + Server Components
i18nArabic/English with native RTL
AuthNextAuth.js → Keycloak OIDC
Components69 custom components
Pages67 pages

Backend (FastAPI)

AspectDetail
FrameworkFastAPI (async Python 3.11+)
ORMSQLModel (SQLAlchemy + Pydantic)
Routers57 API routers
Services60+ service modules
Models45 database models
AuthJWT (Keycloak) + API keys
Middleware5-layer security chain

Background Worker

Async task processor for:

  • KRI scheduled evaluations
  • Escalation processing
  • Email notifications
  • Document retention cleanup
  • Data refresh jobs

Infrastructure Topology

ComponentPortPurpose
Frontend3006Next.js web application
Backend8005FastAPI REST API
PostgreSQL5432Data + vector store (pg16 + pgvector)
Redis6379Cache + task queue
MinIO9000/9001Object storage (S3-compatible)
Keycloak8080IAM and SSO
Prometheus9090Metrics aggregation
Grafana3003Monitoring dashboards
OTEL Collector4317Trace collection
Ollama11434Local LLM inference

Security Architecture

5-Layer Middleware Chain

Every API request passes through:

  1. CORS — domain-level isolation
  2. Security Headers — HSTS, CSP, X-Frame-Options
  3. Rate Limiting — Redis-backed DoS protection
  4. CSRF — double-submit cookie pattern
  5. Audit Middleware — immutable audit trail

Data Isolation

  • API Layer: PermissionChecker dependency
  • Query Layer: OrgScopedQuery filter
  • Database Layer: PostgreSQL RLS policies (19 policies)
  • Session Layer: app.current_org_id variable injection

AI Architecture

See AI Features and AI Governance.