Events

Bakend uses an internal Event Bus so subsystems can communicate without direct coupling.

Every important action in Bakend produces an event. Examples:

  • users.created
  • posts.updated
  • auth.login
  • job.completed

See RFC-0000 for the full event model.

Event Schema

All events share the same structure:

{
  "id": "evt_123",
  "type": "users.created",
  "timestamp": "2026-06-08T12:00:00Z",
  "source": "collections",
  "payload": {
    "id": "user_1",
    "email": "john@example.com"
  }
}
FieldDescription
idUnique event identifier (evt_ prefix)
typeDot-separated event name
timestampISO-8601 UTC time
sourceSubsystem that emitted the event
payloadEvent-specific data

Subscribing

const unsubscribe = eventBus.on("users.created", (event) => {
  console.log(event.payload);
});

unsubscribe();

Handlers may be synchronous or async. Async handlers do not block emit().

Publishing

eventBus.emit("users.created", {
  source: "collections",
  payload: { id: "user_1", email: "john@example.com" },
});

If source is omitted, it defaults to "system".

Error Handling

Handler failures are logged and isolated. A failing handler does not prevent other handlers from running, and does not crash Bakend.

Realtime (Milestone 9)

Clients subscribe to Event Bus channels over WebSocket at /api/realtime. Wildcard subscriptions (posts.*) are supported. See Realtime.

What Is Not Available Yet

FeatureMilestone
Persistent event logPost-1.0
Per-record realtime channelsPost-1.0