Event-Driven Architecture
Roll Claw is built on an event-driven architecture using event sourcing principles. This architectural approach is particularly well-suited for colony management, as it provides:
- A complete, immutable history of all activities
- Powerful historical analysis capabilities
- Reliable offline operation with eventual consistency
- Clear separation between commands (actions) and read models (views)
Core Architectural Concepts
Events as the Source of Truth
In Roll Claw, events are the primary source of truth. Every change to the system state is recorded as an event:
CatSightingRecorded
- When a cat is observedHealthStatusUpdated
- When a health condition is notedTaskCompletedEvent
- When a volunteer finishes a task
These events are stored permanently and form the basis for all state in the system.
Command-Event Flow
User interactions follow a clear flow:
- User issues a Command (e.g.,
RecordCatSighting
) - System validates the command
- Command handler generates appropriate Events (e.g.,
CatSightingRecorded
) - Events update the system state
- Read models are updated based on events
Projections and Read Models
To make the event data useful, Roll Claw creates various projections, such as:
CatProfile
- Current information about each catHealthStatus
- Current health conditions and historyTaskSchedule
- Upcoming and completed tasks
These projections are derived from events and optimized for specific query patterns.
Offline-First Approach
The event-driven architecture enables Roll Claw's offline-first approach:
Local Event Recording
When offline:
- Commands are validated locally
- Events are stored in the local device database
- Local projections are updated immediately
Synchronization
When connectivity is restored:
- Local events are synchronized with the server
- Server-side events are pulled to the device
- Conflict resolution handles any inconsistencies
- Local projections are updated with the latest events
This approach ensures that colony caretakers can continue working effectively in the field, even without consistent internet connectivity.