“Scootered”: NodeJS Event-Sourced Microservice Implementation, from Scratch

We did the first of a three meetup series where we implement a CQRS/ES microservice based system, start to finish. Thanks all who made it on Thursday, hope to see you for the next one on  June 14th!  If you aren’t in Vancouver, BC – we’ll be streaming the session.

Requirements: Event stormed, of course!

We never did find a better, simpler and more entertaining way to understand requirements than event storming, so we did that. Participants settled on building an electric scooter sharing system, like Vancouver’s MobiBikes but with charging stations. Lively discussions about the ubiquitous language of the “scooter sharing” bounded context was ongoing when the evening ended. Here’s one possible “happy path” which tells the story of a scooter being added to the inventory, assigned to a docking/charging station and being checked out by a member (click to enlarge):

Scooter Sharing Event Storming

That diagram came courtesy of https://webeventstorming.com where event stormings can be entered in Event Markdown Language (EMD).

To try it out, copy/paste the following into webeventstorming.com: 

Event Markdown

# Scooter Sharing

Add Dockingstation-> lat, long, description
Dockingstation Added // lat, long, description
Dockingstation Lookup* // dockingstationId, lat, long, description

Add Scooter to Inventory-> serialNumber
Scooter Added To Inventory // serialNumber
ScooterLookup* //scooterId, serialNumber

Move Scooter to Dockingstation-> dockingstationId, scooterId
Dockingstation Inventory Added // dockingstationId, scooterId, dateTime
Scooter Charging Started // dockingstationId, scooterId, dateTime
Scooter Battery Charging Log* // scooterId, serialNumber, dockingstationId, chargingStartTime, chargingEndTime

Register Scooter Sharing Member-> email
Member Registered // email
Member Lookup* // memberId, email

Check out scooter-> // scooterId, memberId, dockingstationId, dateTime
Scooter Checked Out // scooterId, memberId, dockingstationId, dateTime
Scooter Charging Ended // scooterId, dateTime

Return Scooter-> scooterId, dockingstationId, dateTime, memberId
Scooter Returned // scooterId, dockingstationId, dateTime, memerId
Scooter Charging Started

Next Time

The next session is on June 14th:

  • User Experience. We’ll design ourselves a nice UI, starting from the event storming, with dotted lines from screen mockups to commands showing how the user journey unfolds.
  • Building the Scooter Sharing API. We’ll take the “Event Markdown” and turn it directly into NodeJS using some tooling Adaptech have recently open soured. This is going to be an event sourced system which using the Eventstore database and (optionally) Postgres or Cassandra for queries and lookups. There’s a tutorial at https://docs.letseventsource.org/ if you’d like to get a head start.

See you there!


By Robert Reppel

 

 

Comments are closed, but trackbacks and pingbacks are open.

Top