How commanded/eventstore works
Main Components
• EventStore Application: At the center is the EventStore module (see lib/event_store.ex and lib/event_store/application.ex) that sets up and starts the supervision tree.
• Storage Layer: Highlight modules that manage appending events, reading streams, handling snapshots, and executing SQL statements (lib/event_store/storage, lib/event_store/sql, and related EEx templates).
• Serialization Layer: Include components for event data serialization such as the JSON (and JSONB) serializers.
• Subscriptions & Notifications: Identify the subscription logic (lib/event_store/subscriptions/*) and notifications (lib/event_store/notifications/*) that enable components to subscribe to events and handle acknowledgements.
• Cluster and Configuration: Represent cluster configuration files (in the cluster directory) and the configuration management in “config/” files. Show how the system’s behavior is influenced by different environments (bench, dev, test).
• Mix Tasks & Migrations: Indicate the management tasks (lib/mix/tasks/* and lib/event_store/tasks/*) for bootstrapping, migrating, and administering the event store.
• Benchmarking: Although it might not be a core architectural component, include a reference note to the “bench” directory which is used for performance measurement and tuning.
Relationships and Interactions
• Subscription system as an interaction connecting “EventStore” to “Subscribers” (which could be external processes or GenServers) via the notifications subsystem.
• Where configuration (various config files and cluster settings) influences the behavior of the system.
Architectural Patterns and Design Principles
• Supervision & Fault Tolerance: Indicate the supervisor tree (lib/event_store/supervisor.ex and related modules) managing child processes.
• Modularity: Emphasize the clear separation between components (storage, serialization, subscriptions) so that each can be evolved or replaced independently.
• Clustering: Mark the support for running in a distributed environment via the cluster configuration files.
• Extensibility: Note how Mix tasks and configuration parsers establish hooks for administration, migrations, and modifications.
Relevant Technologies and Frameworks
• Elixir (OTP/Supervision Trees, GenServers)
• PostgreSQL for durable storage, including SQL scripts (priv/event_store/migrations and lib/event_store/sql/statements)
• EEx templates used for SQL generation
• Benchmarks rely on Erlang’s external term format serialization (as mentioned in the README)