How ismasan/sourced_todo works
Main Components
• Web Application Layer: Represented by files such as app.rb, config.ru, boot.rb, and the UI directories. This layer is built with Sinatra and serves as the server-driven reactive UI with pages, layouts, and UI components.
• Domain Logic / Business Layer: Found in the domains/todos directory, which contains the core logic for managing lists, listings, and Slack dispatching related to TODO items. This layer handles command processing and event generation.
• Background Workers and Reactor Processes: The bin/workers.rb script indicates a dedicated worker process that, likely, processes events asynchronously (i.e., applying CQRS and ensuring eventual consistency).
• External Service Integration: Slack integration is evident from both the README instructions and domains/todos/slack_dispatcher.rb, which sends notifications to a Slack channel when a TODO item is marked done.
• Infrastructure & Deployment: The Dockerfile, docker-compose.yml, Procfile, and environment configuration files (env.example) indicate that the project also supports containerized deployment and process management.
Component Relationships and Data Flow
• Commands: Show how user requests (through the Sinatra web UI) trigger commands (e.g., add, update, complete a TODO item).
• Workers/Reactors: From the event store, background workers (bin/workers.rb) consume events to update read models or send external notifications (Slack notifier).
• UI Updates: The server-driven UI (powered by Datastar for streaming updates) reacts to changes in the event store – emphasizing synchronization across multiple client sessions/tabs.
• External Communication: Connections from the domain logic to external systems (Slack), initiated by the slack_dispatcher.
Architectural Patterns and Principles
• CQRS and Event Sourcing: Clearly denote the separation between the write model (command handling) and the read model (projections which are updated based on events). Emphasize that every action is first a command then translated into an event.
• Asynchronous / Eventually Consistent Processing: Indicate that the application uses background workers to apply changes asynchronously, ensuring that the UI is eventually updated as the system processes events.
• Domain-Driven Design: The separation into domains and UI layers signifies a clear division of responsibilities (business logic vs. presentation).
Relevant Technologies and Frameworks
• Ruby and Sinatra for the web layer.
• Postgres as the event store and event bus.
• Sourced library for handling event sourcing mechanisms.
• Datastar for streaming and reactive UI updates.
• Docker/Docker Compose for containerized deployment.
• Slack for sending notifications on completed TODO items.