Events
Bakend uses an internal Event Bus so subsystems can communicate without direct coupling.
Every important action in Bakend produces an event. Examples:
users.createdposts.updatedauth.loginjob.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"
}
}
| Field | Description |
|---|---|
id | Unique event identifier (evt_ prefix) |
type | Dot-separated event name |
timestamp | ISO-8601 UTC time |
source | Subsystem that emitted the event |
payload | Event-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
| Feature | Milestone |
|---|---|
| Persistent event log | Post-1.0 |
| Per-record realtime channels | Post-1.0 |