Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Sourcing #676

Open
8 tasks
MuhammadKhalilzadeh opened this issue Feb 3, 2025 · 0 comments
Open
8 tasks

Event Sourcing #676

MuhammadKhalilzadeh opened this issue Feb 3, 2025 · 0 comments
Labels
backend Backend related tasks/issues enhancement New feature or request frontend Frontend related tasks/issues Main Main issues have sub-issues, breaking them to smaller tasks
Milestone

Comments

@MuhammadKhalilzadeh
Copy link
Collaborator

Event Sourcing

Event Sourcing is a pattern where changes to the application state are stored as a sequence of events. Instead of storing the current state, you store the history of events that led to the current state.

Things that we need to consider:

  • - Event Store: You need a dedicated database or table to store events. Our PostgreSQL can be used for this purpose, but we may also think about using Redis here as well.
  • - Event Schema: Define a schema for events (e.g., event_id, aggregate_metadata, event_type, timestamp, etc).
  • - Aggregates: Events are associated with aggregates (e.g., a user, order, etc.). Each aggregate has a unique ID.
  • - Event Handlers: Implement handlers to process events and update read models or trigger side effects.
  • - Snapshotting: For performance, consider periodically storing snapshots of the aggregate state to avoid replaying too many events.

Implementation in Clean Architecture:

  • Infrastructure Layer:

  • Implement the event store (e.g., a PostgreSQL table for events).

  • Provide repositories for reading/writing events.

  • Application Layer:

  • Implement event handlers and command handlers that produce events.

  • Use a message bus or event dispatcher to publish events.

  • Presentation Layer:

  • Expose APIs or interfaces to query the current state (read models) or replay events for debugging.

@MuhammadKhalilzadeh MuhammadKhalilzadeh added backend Backend related tasks/issues enhancement New feature or request frontend Frontend related tasks/issues labels Feb 3, 2025
@MuhammadKhalilzadeh MuhammadKhalilzadeh added this to the 1.1 milestone Feb 3, 2025
@MuhammadKhalilzadeh MuhammadKhalilzadeh added the Main Main issues have sub-issues, breaking them to smaller tasks label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related tasks/issues enhancement New feature or request frontend Frontend related tasks/issues Main Main issues have sub-issues, breaking them to smaller tasks
Projects
None yet
Development

No branches or pull requests

1 participant