# Sample Application Architecture

## Architecture

As part of this workshop we will implement the following sample application architecture.

![Architecture](/files/7hnewp15bVotSgsrgdTB)

We will use the provided existing two microservices (customer and product services) to route these through the Spring Cloud Gateway.

* **Spring Cloud Gateway**: This is the component we will implement and extend during several labs
* **Customer Service**: A backend service providing a REST API for retrieving customers
* **Product Service**: A backend service providing a REST API for retrieving products
* **Spring Authorization Server**: An OAuth 2.1 & OpenID Connect 1.0 compliant authorization server that will be used to implement the cross-cutting gateway feature for user authentication with JSON web tokens (JWT)

## Configuration

These microservices are configured to be reachable via the following URL addresses (Port 8080 is the default port in spring boot).

Service URLs:

| Service                         | URL                     | Secure URL (TLS Lab)     |
| ------------------------------- | ----------------------- | ------------------------ |
| Spring Authorization Server     | <http://localhost:9000> | --                       |
| Spring Cloud Gateway            | <http://localhost:9090> | <https://localhost:8443> |
| Customer Service (Customer API) | <http://localhost:9091> | --                       |
| Product Service (Products API)  | <http://localhost:9092> | <https://localhost:8444> |

## Project contents

After importing the project into your IDE you should see a project structure like in the following picture. Here the VS Code project is shown, it may look different in other IDE's.

![Project Structure](/files/x0fs5wRvKLFetLsdnTfl)

The main contents for this workshop consist of the following directories:

* **rate-limiter-client**: In addition to the components of the sample architecture there is also a helper client provided for testing the rate limiter in lab 2. You find this tool in this directory.
* **reactive-playground**: In this subdirectory you find a demo application that provides a unit test class with lots of examples on implementing reactive streams using project reactor.
* **microservices**: Here you find the provided backend microservices, both implemented using Java and Spring Boot and providing a REST API. You find these in the following subdirectories:
  * customer-service
  * product-service
* **labs**: In this directory you find several workshop labs. Each lab contains two subdirectories:
  * **initial**: This is always the starting point for each workshop lab (this way attendees can always jump in with the next lab even if somebody could not finish the previous lab).
    * api-gateway: This is the initial spring cloud gateway microservice to start the workshop lab
  * **solution**: This is the reference solution for this workshop (please do NOT look into this now)
    * api-gateway: This is the reference solution of the corresponding lab for the spring cloud gateway microservice

> **Note:** Lab 4 also contains the product-service microservice as part of the *initial* and *solution* folders. This is required as part of the secure communication topic of lab 4.

> **Info:** You can find more information on building OAuth 2.0/OIDC secured microservices with spring in [Spring Boot Reference Documentation](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-security-oauth2) and in [Spring Security Reference Documentation](https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2)

So let's start with our first hands-on lab.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andifalk.gitbook.io/spring-cloud-gateway-workshop/introduction/architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
