Skip to content

Kimosabey/chronicle-ledger

Repository files navigation

Chronicle Ledger

Thumbnail

Modern Event-Sourced Banking System with CQRS & CockroachDB

Status License Pattern

Chronicle Ledger is a financial auditing system that prioritizes data integrity above all else. By using Event Sourcing, it ensures that no financial state is ever overwritten; instead, every transaction is stored as an immutable event. It implements CQRS to separate high-throughput writes (CockroachDB) from lightning-fast reads (PostgreSQL), bridged by NATS JetStream.


🚀 Quick Start

Run the entire distributed ledger (DBs + Bus + APIs) in 2 steps:

# 1. Start Infrastructure
docker-compose up -d

# 2. Start Application Services
npm install && npm run dev

Detailed Setup: See GETTING_STARTED.md.


📸 Demo & Architecture

Real-Time Auditor Dashboard

Dashboard Live event log streaming and account materialization.

System Architecture

Architecture CQRS Split: Write API (Event Store) -> NATS -> Read Processor -> Projected View.

Transaction Workflow

Workflow Step-by-step: Command validation, Event persistence, and View migration.

Deep Dive: See ARCHITECTURE.md for Causal Consistency and Schema details.


✨ Key Features

  • 📜 Immutable Event Log: Uses CockroachDB to store append-only financial records.
  • ⚡ CQRS Implementation: Completely decouples Write Scaling from Read Performance.
  • ⏰ Time-Travel Debugging: Ability to query account state at any historical microsecond.
  • 🛡️ Double-Spend Protection: Optimistic Concurrency Control (OCC) at the event layer.
  • 🌊 Async Projection: NATS JetStream ensures the Read side stays eventually consistent with 100% RELIABILITY.

🏗️ The Protective Journey

How a simple deposit becomes an unhackable record:

  1. Command: User submits "Deposit $100" via the Write API.
  2. Verify: API validates current version (Concurrency check).
  3. Persist: The "Deposited" event is committed to the CockroachDB Event Store.
  4. Publish: NATS JetStream picks up the new event and broadcasts it.
  5. Project: The Read Processor consumes the event and updates the PostgreSQL Materialized View.
  6. Query: The user sees their updated balance instantly via the Query API.

📚 Documentation

Document Description
System Architecture Event Schemas, NATS topology, and CQRS trade-offs.
Getting Started Docker environment, DB init, and Load tests.
Failure Scenarios Handling "Offline Processors" and NATS persistence.
Interview Q&A "Event Sourcing vs CRUD", "Why CockroachDB?".

🔧 Tech Stack

Component Technology Role
Write Store CockroachDB Distributed, Immutable Event Log.
Read Store PostgreSQL High-performance Projected Views.
Messaging NATS JetStream Resilient Async Event Bus.
Frontend Next.js 14 Real-time Audit & Visualization.

👤 Author

Harshan Aiyappa
Senior Full-Stack Hybrid AI Engineer
Voice AI • Distributed Systems • Infrastructure

Portfolio GitHub LinkedIn X


📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

Releases

No releases published

Packages

 
 
 

Contributors