Skip to main content

Concepts and Architecture

This section provides a detailed overview of the fundamental concepts and architectural design of Thalo, helping you understand how the different components work together to provide a robust event sourcing platform.

Understanding Event Sourcing

Event sourcing is a design pattern where changes to the application state are stored as a series of events, rather than just the final state. This approach offers several advantages:

  • Complete State History: Every change to the state is recorded, enabling full traceability and providing an audit trail.
  • Replayability: It's possible to revert to any previous state or project different state scenarios by replaying events.
  • Scalability and Performance: By decoupling data commands from state updates, event sourcing can lead to more scalable and performant systems.

Overview of Wasmtime and Sled

Wasmtime

Wasmtime is a standalone runtime for WebAssembly (wasm) that Thalo utilizes for executing wasm-compiled aggregates. It provides:

  • High-Performance Execution: Optimized for efficient and fast execution of wasm binaries.
  • Isolation: Ensures safe execution of code, keeping the runtime environment secure.

Sled

Sled is an embedded database used by Thalo as an event store. Key features include:

  • Lightweight and Fast: Designed for high-throughput and low-latency operations.
  • Reliability: Offers robust data persistence and recovery mechanisms.

Thalo's Architecture

Thalo's architecture is designed to harness the power of event sourcing, wasm, and an embedded database. It consists of:

  • Wasmtime Integration: For running wasm-compiled aggregates.
  • Sled Event Store: Acts as the storage backend for events.
  • Runtime Environment: Manages the execution of aggregates and handling of events.

Core Concepts

Aggregates

Aggregates are the core building blocks in Thalo. They encapsulate a group of related objects into a single unit for data modification. Each aggregate:

  • Handles Commands: To perform actions or make changes.
  • Generates Events: To represent state changes.

Events

Events are immutable records of state changes. They are stored chronologically and used to rebuild the state of an aggregate.

Commands

Commands are instructions that tell an aggregate what operation to perform. They are processed by aggregates, resulting in the generation of events.

Projections

Projections are derived states created by processing a series of events. They provide a view of the system's state for various purposes like queries or external integrations.