> For the complete documentation index, see [llms.txt](https://andifalk.gitbook.io/cloud-native-microservices-security/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andifalk.gitbook.io/cloud-native-microservices-security/introduction/application-architecture.md).

# Demo Application Architecture

For the hands-on workshop labs you will be provided a complete spring mvc web server application together with a corresponding spring mvc thymeleaf web client app.

**Table of Contents**

* [Application Component View](/cloud-native-microservices-security/introduction/application-architecture.md#application-components)
* [Server Architecture](/cloud-native-microservices-security/introduction/application-architecture.md#server-architecture)
  * [REST Api](/cloud-native-microservices-security/introduction/application-architecture.md#rest-api)
  * [Server Layers](/cloud-native-microservices-security/introduction/application-architecture.md#server-layers)
  * [Users and Roles](/cloud-native-microservices-security/introduction/application-architecture.md#server-users-and-roles)
  * [Provided application](/cloud-native-microservices-security/introduction/application-architecture.md#provided-server-application)
* [Client Architecture](/cloud-native-microservices-security/introduction/application-architecture.md#client-architecture)
  * [Client Layers](/cloud-native-microservices-security/introduction/application-architecture.md#client-layers)
  * [Users and Roles](/cloud-native-microservices-security/introduction/application-architecture.md#client-users-and-roles)
  * [Provided application](/cloud-native-microservices-security/introduction/application-architecture.md#provided-client-application)

## Application Components

The server application provides a RESTful service for administering books and users (a very *lightweight* books library).

Use cases of this application are:

* Administer books (Creating/editing/deleting books)
* List available books
* Borrow a book
* Return a borrowed book
* Administer library users&#x20;

## Server Architecture

The RESTful service for books and users is build using the Spring MVC annotation model and Spring HATEOAS.

The application also contains a complete documentation for the RESTful API that is automatically generated with spring rest docs. You can find this in the directory *'build/asciidoc/html5'* after performing a full gradle build or online here: [REST API documentation](https://andifalk.github.io/cloud-native-microservices-security/api-doc.html).

The initial server application is not secured at all.

### Server Layers

The domain model of the server application is quite simple and just consists of *Book* and *User* models.\
The packages of the application are organized according to the different application layers:

* **web**: Contains the complete RESTful service
* **service**: The service classes (quite simple for workshop, usually these contain the business logic)
* **data**: All domain models and repositories

Each layer is organized the same way for the *book* and *user* domains.

In addition there more packages with supporting functions:

* **common**: Classes that are reused in multiple other packages
* **config**: All spring configuration classes

### REST API

To call the provided REST API you can use curl or httpie. For details on how to call the REST API please consult the [REST API documentation](https://andifalk.github.io/cloud-native-microservices-security/api-doc.html) which also provides sample requests for curl and httpie.

### Server Users and roles

There are three target user roles for this application:

* LIBRARY\_USER: Standard library user who can list, borrow and return his currently borrowed books
* LIBRARY\_CURATOR: A curator user who can add, edit or delete books
* LIBRARY\_ADMIN: An administrator user who can list, add or remove users

**Important:** We will use the following users in all subsequent labs from now on:

| Username | Email                      | Password | Role             |
| -------- | -------------------------- | -------- | ---------------- |
| bwayne   | <bruce.wayne@example.com>  | wayne    | LIBRARY\_USER    |
| bbanner  | <bruce.banner@example.com> | banner   | LIBRARY\_USER    |
| pparker  | <peter.parker@example.com> | parker   | LIBRARY\_CURATOR |
| ckent    | <clark.kent@example.com>   | kent     | LIBRARY\_ADMIN   |

These users are automatically created and persisted upon application start. We will these users later for implementing the different authentication mechanisms.

### Provided Server application

You can find the provided initial server application beneath the [lab 1 folder](/cloud-native-microservices-security/hands-on-labs/lab1.md) as [library-server](https://github.com/andifalk/cloud-native-microservices-security/tree/d42239788f309efcc28eb7657b176d2968b92bc7/lab1/library-server/README.md).
