# Developing Microservice-Based Applications Using the Silvera Domain-Specific Language
## 3 Silvera
### Silvera Concrete Syntax
#### 3.3.2 Service Registry Declaration
The API of the _Order_ microservice contains CRUD methods for the _Order_ entity and the _listOrders_ method, which retrieves all orders from the database. Methods _createOrder_, _updateOrder_, and _deleteOrder_ publish corresponding messages to the message broker after they are successfully completed. These messages are used by the _EmailNotifier_ microservice to notify the user about the order status. The _EmailNotifier_ microservice has one _Notification_ entity that contains an order ID and a user's email as attributes. The API of this microservice has _listNotifications_ and _listHistoryForUser_ methods. The first method retrieves all notifications from the database, whereas the second method retrieves notifications only for a selected user. In addition to these publicly available methods, this microservice also contains three internal API methods: \begin{table}
\begin{tabular}{l l} \hline \hline
**Microservice** & **Description** \\ \hline _User_ & Provides user-related operations. \\ \hline _Meal_ & Provides means for adding meals to the menu. \\ \hline _Order_ & Provides means for creating orders. \\ \hline _Storage_ & Contains information about availability of ingredients used for preparing a meal. \\ \hline _EmailNotifier_ & Notifies users about the order status via email. \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Microservices that compose Eat and Drink application and their descriptions. ### Eat and Drink Architecture Evaluation

Silvera evaluated the Eat and Drink application during compilation. As shown by Table 11, there are a few outliers for metrics _WSIC_, _AIS_, and _ADS_. _WSIC_ values for microservices _User_ and _Meal_ are larger than the system average. Lower _WSIC_ values are more favorable for the maintainability of a service. However, after we compared the APIs of all services in the system, we decided that the current implementation of _User_ and _Meal_ is good enough for this use case. The microservice _Order_ depends on three other microservices: _User_, _Meal_, and _Storage_. Based on the _ADS_ value calculated for the _Order_ microservice, we can see that this microservice could be problematic due to high coupling with its dependencies. However, this is expected since the _Order_ microservice is a central part of the application where the main business logic is implemented. Since no other microservice depends on the _Order_ microservice, its _AIS_ and _ACS_ values are both 0. Microservices: _User_, _Meal_, _Storage_, and _EmailNotifier_ have no dependencies towards other microservices, hence the zeros for their _ADS_ and _ACS_ values. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Metric**} & \multirow{2}{*}{
\begin{tabular}{c} **System** \\ **Average** \\ \end{tabular} } & \multirow{2}{*}{**User**} & \multirow{2}{*}{**Meal**} & \multirow{2}{*}{**Storage**} & \multirow{2}{*}{**Order**} & \multirow{2}{*}{**EmailNotifier**} \\ \cline{1-1}  & & & & & & & \\ \hline _WSIC_ & 3.2 & **4** & **5.5** & 3 & 1 & 2.5 \\ \hline _NVS_ & 1 & 1 & 1 & 1 & 1 & 1 \\ \hline _AIS_ & 0.6 & **1** & **1** & **1** & 0 & 0 \\ \hline _ADS_ & 0.6 & 0 & 0 & 0 & **3** & 0 \\ \hline _ACS_ & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline \hline \end{tabular}
\end{table} 
Table 11: The results of metrics-based evaluation of Eat and Drink application. Figure 3: The architecture of the Eat and Drink application. Solid, black connections represent dependencies. The label on dependency connection shows which method is required by dependent. Green, dashed connections represent service registrations. Orange, dashed connections represent a message publishing, and labels on these connections represent messages that are being published. ### Eat and Drink Code Generation

As stated in Section 3.4, the Silvera compiler can have an arbitrary number of code generators, each specialized for a particular programming language or framework. In the case of _Eat and Drink_, we used the built-in code generator.