Store all domain changes as an immutable append-only sequence of events in an event store table. State is never updated in place — it is rehydrated by replaying all events for an aggregate. Aggregates apply each event to reconstruct their current state. Publish events to Kafka after appending to the store for downstream consumers.
The event store is append-only — never update or delete events; they are the permanent record.
Aggregate state is derived by replaying events from the beginning of a stream.
Use snapshots for aggregates with long event histories — store a checkpoint every N events.
Publish events to Kafka after appending so projections and other services can subscribe.
Event sourcing pairs naturally with CQRS — the write model appends events; the read model builds projections.
Imagine you need to add a new command to an existing NestJS microservice that uses event sourcing. Walk me through the steps you’d take to record the event and update the read model.
If a message fails to be published to the event store in your NestJS microservice, what would happen to the transaction, and how would you handle the error?
How would you configure a NestJS microservice to connect to a Kafka topic that serves as your event store?
We have a user registration flow where the command service emits a UserCreated event, but the projection service isn’t reflecting the new user. What debugging steps would you take?
Explain the trade‑offs between storing events in a relational database versus an append‑only log like Kafka when using NestJS microservices.
During a deployment, you notice that replaying events to rebuild a read model takes much longer than expected. What design changes could you make to improve replay performance?
Design a strategy for handling schema evolution of events in a NestJS microservice architecture that must stay backward compatible.
How would you ensure exactly‑once processing of events across multiple NestJS microservice instances under high load?
Discuss how you would implement snapshotting in a NestJS event‑sourced system to keep aggregate reconstruction fast, and what pitfalls to watch for.
Our organization wants to migrate a legacy monolith to an event‑sourced, NestJS microservice ecosystem. What high‑level migration plan would you propose, and how would you manage data consistency during the cut‑over?
When multiple teams own different bounded contexts that share events, how do you govern event contracts and versioning to avoid breaking changes across NestJS services?
At scale, what operational concerns (e.g., monitoring, replay, disaster recovery) arise with event sourcing in NestJS microservices, and how would you address them architecturally?