Vinícius A dos Santos

Vinícius A dos Santos

About MeEmail Me
LinkedInGitHubEmail

Awesome Backend - Part 1 - User Stories and C4 Level 1 Diagram

BDD
architecture
c4model

Hi, everyone! This is part 1 of the Awesome Backend series. More info at Awesome Backend - High Available, robust, modern, backend architecture hands-on
For this part, I'm going to write business use cases and present de first level of the C4 Model So, hands-on!


About the tech stack

  • BDD way of writing User Stories;
  • C4 Model: A simple, easy to write, architecture diagram model;
  • PlantUML: A component that allows to quickly write diagrams as code;

Functional flowchart

I'm building the checkout process of a fictional online store.
So let's think about the flow and possible scenarios the application should cover:

happy-checkout-flow-chart.puml on GitHub

This is the happy path, but things may always not work as expected:

  • A product in the order may be sold out between the "add to cart" event and "order submitted" event;
  • The payment may be denied by the payment broker. There is also an improvement in the flow I can see: the last three actions may occur at the same time, in parallel.

Including these details in the flow, this is the result:

checkout-flow-chart.puml on GitHub

User Stories

Now that we have mapped the application flow, we can write user stories.
I'm going to follow BDD way of describing how the app should behave:

Feature: Awesome Online Store product ordering.
As an Awesome Online Store's customer...
I want to be able to order products from the store...
So that I can enjoy the comfort of buying things without leaving home.

Scenario 1

  • Given: a list of products available in stock and a compliant payment method...
  • When: the customer submits the order...
  • Then: decrease stock, send the user an order confirmation email, and trigger the shipment of the order.

Scenario 2

  • Given: a list of products with one or more products of the list unavailable in stock and an accordant payment method...
  • When: the customer submits the order...
  • Then: send the user an email apologizing for the inconvenience.

Scenario 3

  • Given: a list of products available in stock and a noncomplying payment method...
  • When: the customer submits the order...
  • Then: send the user an email informing them that his payment was denied by the payment broker and the reason.

This is an exercise, the focus here is on software. There are a lot of details to consider for a real ordering process.

C4 Model - Level 1 - Context Diagram

It's time to assume the Software Architect role.
The Context Diagram of C4 Model is really useful to contextualize the System aside from other external Systems and actors.
It is useful for anyone, in a technical role or not, to have a view of how and who the System interacts with.

context.puml on github

That's it for now.
See you soon on the next posts.

See all posts series at Awesome Backend - High Available, robust, modern, backend architecture hands-on

← Back to home