Skip to main content

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:
  1. Upload a template file
  2. Create an EventTemplate record
  3. Kick off Celery task
  4. Replace all object IDs (prevent duplicates)
  5. Read and bulk create events/objects

Export

Export a customer’s events to a template: Workflow:
  1. Export all events in parallel
  2. Store event data in Redis
  3. Process and dedupe objects
  4. Replace IDs with normalized references
  5. Create EventTemplate with version

Load

Load events from a template into a customer: Workflow:
  1. Read the EventTemplate
  2. Create EventTemplateLoadEvent for each event
  3. Preload objects to Redis
  4. Process events sequentially
  5. Mark each as completed

Event Template Models

ModelDescription
EventTemplateCollection of events loadable into the system
EventTemplateVersionVersion tracking for template changes
EventTemplateEventIndividual event in a template
EventTemplateObjectObject data in a template
EventTemplateLoadEventTracks 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:
  1. Store Object A once as an EventTemplateObject
  2. Replace inline copies with OBJECT: references
  3. On load, resolve references back to full objects

Use Cases

  1. Export the customer at the desired point in time
  2. Reset the customer data
  3. Load the exported template
  1. Export customer events
  2. Roll back to before the error
  3. Modify the problematic event
  4. Re-load events including the fix
  1. Export from source environment
  2. Download the template file
  3. Import to target environment
  4. Load the template to a new customer
If an event’s data becomes out of sync:
  1. Find the event in the system
  2. Use the refresh functionality
  3. Event is re-processed with current rules

Template Files

Event templates are stored as JSON files. Example structure:
{
  "template_id": "EVTP_...",
  "version": 1,
  "events": [
    {
      "event_type": "CREATE_INVESTOR",
      "event_data": {
        "investor_id": "OBJECT:investor_1",
        "name": "Test Investor"
      }
    }
  ],
  "objects": [
    {
      "object_ref": "investor_1",
      "object_type": "Investor",
      "object_data": {...}
    }
  ]
}

Next Steps