Most architecture overviews read like a wall of theory that promises a lot but leaves you staring at a blank editor by the end. This guide flips that script. If you have fifteen minutes, a working terminal, and zero patience for fluff, you can get Muerte's event-driven core running and wired to two isolated services before your coffee goes cold. Every step below is ordered so you never have to scroll back up to remember what you just did.
Why the Event Bus Beats Ad-Hoc Callbacks for Time-Poor Teams
The single biggest time-saver in Muerte is its central event bus. Instead of each service reaching into another's internals, you publish a typed event and move on. For a busy dev, that means you can change one handler without grepping the whole codebase for breakage. The bus also gives you a natural audit trail: every state mutation traces back to a specific event, so when a bug surfaces at 2 a.m., you replay the sequence instead of guessing. Think of it as your built-in undo button for production data.
Your 15-Minute Setup Checklist
- Clone and scaffold (2 min): Run the Muerte CLI init command, accept the default module structure, and confirm the bus file compiles with no errors.
- Define your first event type (2 min): In the events directory, create a
UserCreatedevent with just two fields:userIdandtimestamp. Resist the urge to add metadata you do not need yet. - Publish from your entry point (3 min): In the service that creates users, call
bus.publish(new UserCreated(...))inside the same transaction that writes the record. One line, no extra boilerplate. - Subscribe a second service (4 min): Create a
NotificationServicethat listens forUserCreatedand logs a welcome message. This proves isolation: the user service knows nothing about notifications. - Verify state integrity (2 min): Trigger the flow once, then query both services. The user record and the notification log should match on
userId. If they diverge, check that both services share the same bus instance or are connected through the network adapter. - Tag your commit and move on (2 min): Add a short
READMEsnippet noting which events exist and which services subscribe. Future-you will thank present-you.
That is the entire loop. No Dockerfile, no Kubernetes, no microservice choreography. Two processes, one shared bus, done.
Keeping State Clean While Juggling Deadlines
The most common mistake busy developers make is mutating shared state directly from inside a handler. In Muerte, the rule is simple: handlers read the current snapshot, compute a new value, and emit a state-change event back onto the bus. The bus applies it atomically. This keeps every service's local cache consistent without a single lock statement. Practical tip: wrap each handler body in a small try/catch that re-publishes the event on failure with an incremented retry counter. Set the ceiling to three; beyond that, park the event in a dead-letter queue and alert your team. You will catch 95 percent of edge cases without babysitting a terminal.
Three Quick FAQs for People Short on Time
Do I need to understand every Muerte module before I can ship?
No. The event bus, two services, and one state-change pattern cover the first feature you will build. Deeper modules (saga orchestration, CQRS projections) layer on top once your core loop is stable.
What if two services publish conflicting events at the same instant?
Muerte's bus resolves this with a deterministic ordering key (event timestamp plus publisher ID). If a true conflict arises, the bus rejects the later event and surfaces it to the publisher for reconciliation. You never silently overwrite state.
Can I swap the in-memory bus for Redis or Kafka later?
Yes. The bus interface is transport-agnostic. Swap the adapter behind the same IPublisher / ISubscriber contracts, redeploy, and no service code changes. Plan the abstraction from day one so the swap takes an afternoon, not a sprint.