Skip to main content

Technology Stack

This document outlines the core technology choices for the Book Keeper application, designed for a scalable, auditable, and high-performance financial system based on CQRS and Event Sourcing principles.

Write-Side (Command Processing & State Persistence)

The write-side is responsible for processing commands and persisting the state of aggregates as a stream of immutable events. The storage mechanisms are designed to be swappable via an adapter pattern, as defined in docs/decisions.md.

Event Store

The Event Store is the source of truth for all state changes.

  • Default Choice: PostgreSQL: A robust, reliable, and well-supported relational database. It serves as the default event store, providing strong transactional guarantees.
  • High-Throughput Option: KurrentDB: A mature, feature-rich standalone option for event sourcing. An adapter has been implemented using the kurrentdbclient library, making it a fully supported and swappable backend.

Core Ledger Engine

This is the engine responsible for the atomic execution of double-entry transfers.

  • Default Choice: PostgreSQL: The PostgresLedgerAdapter provides the default implementation, using standard SQL transactions for atomic transfers.
  • High-Performance Option: TigerBeetle: The TigerBeetleLedgerAdapter has been implemented, allowing the core transaction logic to be offloaded to a specialized financial accounting database for extreme scaling scenarios.

Read-Side (Reporting & Queries)

The read-side consists of one or more specialized read models (projections) optimized for different query patterns.

  • Structured Reports: PostgreSQL is used for classic, structured financial reports like the General Ledger, Trial Balance, and Balance Sheet. The relational nature is ideal for queries requiring strong consistency and joins.
  • Search & Analytics (Future): Elasticsearch is planned for advanced use cases, such as full-text search on transaction narrations, complex data aggregation for dashboards, and real-time analytics.

Event Bus (Inter-Service Communication)

The event bus is designed around a swappable IEventBus interface, allowing the concrete implementation to be chosen via configuration.

  • Primary Choice: NATS (with JetStream): A modern, high-performance, and lightweight messaging system. It is the recommended choice due to its balance of performance and operational simplicity.
  • Alternative Option: Apache Kafka: For environments where Kafka is already the established standard, an adapter is provided to ensure seamless integration.

Authorization Engine

  • Casbin: Used for fine-grained, in-application authorization. It supports a flexible policy model (PERM) that can express both RBAC and ABAC rules.