Introduction
Introduction
This tutorial guides you through implementing time-travel capabilities in your applications using KurrentDB. You will learn how to reconstruct and query the state of your system at any point in history, an essential feature for auditing to understand data evolution.
Objectives
In this tutorial, you will:
- Learn the principles of time-traveling in event-native applications
- Project events into read models for sales reporting
- Enable time-travel by recording and querying historical states
- Explore both snapshot-based and on-demand time-travel approaches
- Discover interactive interfaces to visualize historical data
- Audit the lineage of data changes
Prerequisites
Before starting, ensure you have the following:
- A GitHub account to use GitHub Codespaces
- Basic knowledge of C#
- Familiarity with command-line operations
Tutorial Overview
This tutorial consists of the following steps:
Part 1: Set up Codespaces
- Set up your Codespaces: Start an interactive coding environment in your browser where all tools and databases are installed.
Part 2: Initialize KurrentDB with Sample Orders
- Start Databases and Append OrderPlaced Events: Start KurrentDB and append sample order events for use in reporting.
- Browse OrderPlaced Events in KurrentDB's Admin UI: Explore the event streams in the Admin UI.
Part 3: Project Events to Sales Report Read Model
- Start the Report Projection Application: Start the app that listens for
OrderPlaced
events and builds a denormalized JSON sales report read model. - Start and Browse the Report Web Application: Open the web app to view the sales report generated from the read model.
- Examine the Report Projection Application: Review how the projection app loads, updates, and saves the read model in response to events.
- Examine the Report Projection Logic: Explore how the projection logic transforms order events into the month-end sales report.
Part 4: Time Travel with Pre-computed Read Models
- Add Time-Travel Support to the Sales Report Projection: Modify the projection so the read model records sales data for every day of the month, enabling time-travel queries.
- Explore Time Travel Capabilities in the Report Web Application: Use the web app's time slider to view historical snapshots of the sales report for any day.
Part 5: Time Travel with On-demand Event Replay
- Discover the Auditing Capabilities in the Report Web Application: Use the web app to audit and reconstruct the sales report state at any point in time by replaying events on demand.
- Examine the Event Audit API: Review how the API reads and filters events from the event store to support on-demand time-travel and auditing.