Event Sourcing

Current state is determined by history of changes

Introduction

๐Ÿ“˜

Why haven't I heard of storing events before?

You have likely been exposed to the same concepts as almost all database systems use a log for storing changes applied to the database, such as the MongoDB Oplog. The current state of the database can be recreated from this transaction log is needed, which is kind of an event store. Event sourcing is the application of this concept as the foundation for your system's state.

Advantages

History: Having a true history of the system. Gives further benefits such as audit and traceability.
Answers: You never know which questions about your system/users you will ask in one year.
Time travel: Ability to put the system in any prior state. (I.e. what did the system look like last week?)
Flexibility: By storing all events your can create arbitrary read-model projections at any time in the project. This enables you to present your data in any number of ways and optimize it for the client-side.
Speed: Events are always appended, never updated or deleted which makes storing them blazing fast.

Further Reading