Events System
The events system records all changes in Maybern, enabling powerful features like rollback, export/import, and audit trails.What is an Event?
An event is a record of a change in the system. Events enable:- Rollback: Undo changes by replaying events
- Export/Import: Move customer data between environments
- Audit Trail: Track who changed what and when
- Refresh: Re-apply an event if data becomes stale
Event Types
CustomerEvent
Customer-level activity: creating investors, fund families, etc.
FundFamilyEvent
Fund family activity: closings, posting fees, capital calls, etc.
FundFamilySubEvent
Sub-events within a fund family event: individual capital call or distribution.
StateTransitionEvent
State changes: moving from draft to complete status.
Event Features
Import
Import events from a JSON template file: Workflow:- Upload a template file
- Create an EventTemplate record
- Kick off Celery task
- Replace all object IDs (prevent duplicates)
- Read and bulk create events/objects
Export
Export a customer’s events to a template: Workflow:- Export all events in parallel
- Store event data in Redis
- Process and dedupe objects
- Replace IDs with normalized references
- Create EventTemplate with version
Load
Load events from a template into a customer: Workflow:- Read the EventTemplate
- Create EventTemplateLoadEvent for each event
- Preload objects to Redis
- Process events sequentially
- Mark each as completed
Event Template Models
| Model | Description |
|---|---|
EventTemplate | Collection of events loadable into the system |
EventTemplateVersion | Version tracking for template changes |
EventTemplateEvent | Individual event in a template |
EventTemplateObject | Object data in a template |
EventTemplateLoadEvent | Tracks status when loading a template |
Object Deduplication
When exporting, duplicate objects are consolidated: Problem: Event 1 and Event 2 both reference Object A. Without deduplication, we’d store two copies. Solution:- Store Object A once as an
EventTemplateObject - Replace inline copies with
OBJECT:references - On load, resolve references back to full objects
Use Cases
Roll Back a Customer
Roll Back a Customer
- Export the customer at the desired point in time
- Reset the customer data
- Load the exported template
Fix and Roll Forward
Fix and Roll Forward
- Export customer events
- Roll back to before the error
- Modify the problematic event
- Re-load events including the fix
Clone Customer to New Environment
Clone Customer to New Environment
- Export from source environment
- Download the template file
- Import to target environment
- Load the template to a new customer
Refresh Stale Data
Refresh Stale Data
If an event’s data becomes out of sync:
- Find the event in the system
- Use the refresh functionality
- Event is re-processed with current rules