Skip to content

Create the first service

Add service with cli

A service is a logical group of functions and subscriptions. This is where the domain driven aspect comes in. In our example, we will use the classic example - Users.

At the end, we want to have two domains - User and Email.

We will need to have this functionality:

  • sign up a new user
  • get a user by email
  • send a welcome email to user

Set up a new service

First, we need to create a new service. You can simply add a new service by using the CLI tool.

purista add service

The CLI will guide you through all steps, and will create all files for your. In the first step, you will asked for the name of our new service. We will start with User.

? What is the name (or domain) of your new service (something like: user or account)


Service names should be short and in best case a single word - like user or email. They should reflect a single entity or domain name. You can enter the name in natural way. The CLI tool will take care of casing and whitespaces. For example, if you have a domain bank account, you can simply type in bank account. The CLI tool will convert it to something like bankAccount

After you have confirm your input by pressing the enter key, you will be asked for a short description of the service.

? What is the matter of service "user"

Here, you should enter some short, general description, which will be used for some human-facing documentation. So, please provide here something like: manages data related to users.

In the last step, you will be asked for the version of your service. It defaults to 1, which you can simply confirm by pressing the enter key. If you need to create a new version of an existing service, you can enter any integer number larger than 1.

Version number of this service (1)

Now, all files should be generated.

Start the service