# Developing Microservice-Based Applications Using the Silvera Domain-Specific Language
## 3 Silvera
### Silvera Concrete Syntax
#### 3.3.2 Service Registry Declaration
11\"\"\"
12...
13
14 python=GeneratorDesc(
15 language_name=\"python\",
16 language_ver=\"3.7.4\",
17 description=\"Python3.7.4 codegenerator\",
18 gen_func=generate
19)
```
Listing 10: Making the new code generator discoverable by Silvera by using _silvera_generators_ entry point. ```
1 fromsetuptoolsimportsetup
2
3 setup(
4...
5 entry_points={
6'silvera_generators':[
7'python=pygen.generator:python'
8]
9}
10)
```

**Listing 9** Implementation of a _GeneratorDesc_ object and the prototype of the _generate_ function. Silvera provides a command (silvera list-generators) that lists all registered generators in the current environment. ## 4 Eat and Drink Microservice Architecture Use Case

In this section, we present a case study in which we have used Silvera to specify the architecture of the _Eat and Drink_ application. The Eat and Drink is a distributed application for ordering food and drinks. We used Silvera to model the architecture of the Eat and Drink and to produce runnable Java code. In Section 4.1, we describe each microservice in the system, whereas in Section 4.3 we present the structure of the generated Java code. We will also compare the number of lines of code needed to specify the architecture of Eat and Drink in Silvera to the number of lines of code needed to specify the same Eat and Drink application in Java programming language. ### Eat and Drink Microservice Architecture

In this section, we describe each microservice present in the Eat and Drink and how they interact. The Eat and Drink application consists of only five microservices and serves as a short demonstration of Silvera's capabilities. In the future, we plan to test Silvera on real industrial use cases (see Section 8). Microservices that compose the Eat and Drink application are shown in Table 10. APIs of all microservices are based on REST and can be used by external users. The architecture of the Eat and Drink application is illustrated in Figure 3.

To provide a single entry point for external users, we defined _EntryGateway_ as an API gateway. All microservices are discoverable via the _ServiceRegistry_. In the following text, we describe the domain model and the API of each microservice in the system. The _User_ microservice has only one entity--_User_ with the following attributes: _username_, _password_, and _email_. The API of the _User_ microservice consists of CRUD methods and three additional methods: (i) _listUsers_--which retrieves data for all users in the system, (ii) _userExists_--which checks if the user with a given username exists in the system, and (iii) _userEmail_--which retrieves the user's email. The _Meal_ microservice has two entities: _Meal_ and _Ingredient_. Each meal has its _name_, _price_, _description_, and a list of _ingredients_. For each ingredient, it is possible to specify a name and a measure. The API of the _Meal_ microservice consists of CRUD methods defined for _Meal_ entity and methods such as: (i) _listMeals_--which retrieves all meals from the database, (ii) _mealExists_--which for a given meal name checks if the meal exists in the database, (iii) _mealPrice_--which for a given meal name returns its price, and (iv) _getIngredientsForAMeal_--which for a given meal name returns the list of the ingredients needed to prepare the meal. The _Storage_ microservice has only one entity--_Ingredient_ with attributes _name_ and _measure_. The API of the _Storage_ microservice consists of CRUD methods defined for the entity and two additional methods: (i) _list_--which retrieves the information about all ingredients from the database, and (ii) _takeIngredient_--which, if possible, takes the ingredient from the storage. The _Order_ microservice has two entities: _Order_ and _OrderItem_. Every order has information about the user who created the order, a list of _OrderItem_ entities, and a calculated price. _OrderItem_ contains information about the meal that is ordered, such as the meal name and the amount.