Skip to content

Core Concepts — Modules, DI & Architecture

Granit is not a collection of independent utilities. Every design decision flows from a small set of principles: modules compose with explicit dependency declarations, data is always scoped to its tenant, events cross boundaries without coupling, and compliance is structural rather than bolted on.

Understanding these concepts gives you the mental model to use Granit effectively and extend it without surprises.

graph TD
    MS[Module System] --> DI[Dependency Injection]
    DI --> Config[Configuration]
    DI --> P[Persistence]
    P --> CQRS[CQRS]
    P --> MT[Multi-Tenancy]
    P --> C[Compliance]
    CQRS --> C
    MS --> Msg[Messaging]
    Msg --> CQRS
    Msg --> WO[Wolverine Optionality]
    Msg --> C
    MT --> SM[Security Model]
    SM --> C

Start with the Module System — every other concept builds on it.

  • Module System[DependsOn], topological sort, conditional modules, two-phase lifecycle
  • Dependency Injection — module service registration, Options pattern, PostConfigure
  • Configuration — Options (startup), Settings (runtime), Module Config (frontend read-only)
  • Persistence — isolated DbContext, interceptors (audit, soft delete, versioning), automatic query filters
  • CQRS — Reader/Writer separation, compliance-driven data access, least-privilege injection
  • Multi-Tenancy — three isolation strategies, transparent query filters, async-safe tenant context
  • Messaging — domain events, integration events, transactional outbox, automatic context propagation
  • Wolverine Optionality — Channel fallback, crash behavior, when you actually need a message bus
  • Security Model — JWT authentication, provider-agnostic RBAC, per-role caching, back-channel logout
  • Compliance — GDPR and ISO 27001 enforcement as structural patterns
  • Framework vs Modules — classification boundary and dependency rules between horizontal framework and vertical business modules
  • Bundles — meta-packages and the fluent GranitBuilder API for quick onboarding