Stepping.js ——Two steps to complete the front and back end separation architecture design

Time:2020-10-23

One week ago, I participated in a workshop on “modeling and design” of the company. In a sense, this is a workshop on architecture design and software modeling. And then there was an inspiration Stepping.js 。

When we end the event storm, we need to take pictures or other means to record the relevant content. Therefore, it is not easy to organize these documents. In fact, we only need a DSL (domain specific language), and we can directly convert this document into images, documents and so on.

So I wrote a tool called stepping to simplify this work.

Stepping

Step 1: install stepping

In order to use stepping, we need to install stepping firstyarnperhapsnpmTo install:yarn global add stepping

Step 2: design domain model

In addition, we also need to design domain models related to the system, such as:

Stepping.js ——Two steps to complete the front and back end separation architecture design

The model is described in the form of DSL

Domain: inventory subdomain
  Aggregate: inventory
    Event: inventory has increased
    Event: inventory restored
    Event: inventory deducted
    Event: inventory locked
    Command: edit inventory

  Aggregate: goods
    Event: product created
    Command: add product

Save this file asphodal.ddd, and then executestepping -i phodal.ddd。 You can get onestepping.svgThis SVG file can get the above domain model.

Stepping.js ——Two steps to complete the front and back end separation architecture design

At the same time, if you want, you can also write the relevant aggregate model in this DDD file:

Aggregate detail: product
  model: product
    field: 
      id: int
      name: string
      number: string
      manufacturers: string

We’ll do it againstepping -i phodal.dddYou can get a sample API interface that separates the front end and the back end, that is:

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 0,
            "name": "name",
            "number": 0,
            "manufacturers": "manufacturers"
        }
    ]
}

Combined with Moco or pretender, you can directly become a mock server.

In the future, we will also integrate this model with Django – just write the DSL of the design draft and generate relevant documents.

Finally, let’s understand what a domain storm is.

Event storm

The event storm is to bring all the key participants together in a spacious room for a meeting and use post it notes to describe what’s going on in the system.

An orange post it note represents an event in a field. It uses a past tense to describe what happened. The format is generally: XX has XX. So, we need to sort out all the relevant systemseventBusiness and developers need to storm together. For an order, there will be some related events:

  • Order created

  • Order paid

  • Order complained

  • Order cancelled

The related post it notes will be generated:

Stepping.js ——Two steps to complete the front and back end separation architecture design

Then, the sequence of these events is sorted according to the time axis of the events

Stepping.js ——Two steps to complete the front and back end separation architecture design

Then, we need to combine the relevant operations of the software users, and write the relevant operationscommand。 Then, combine thesecommandAndevent。 For example, the order related orders are:

  • Submitting an order can trigger the event “order created”

  • By submitting a complaint, the event “order has been complained” can be triggered

  • wait

After that, we have all the system relatedEvents and commands

Stepping.js ——Two steps to complete the front and back end separation architecture design

In other words, these are relatedEvents and commandsIt is the function that we need to complete when we write detailed code. Finally, after completing the relevant aggregation, we can get a complete model

Stepping.js ——Two steps to complete the front and back end separation architecture design

Based on this model, we can easily design microservices.

Stepping.js ——Two steps to complete the front and back end separation architecture design

Welcome to try it out and make suggestions on GitHub:https://github.com/phodal/ste…