Project was transferred from an old account - igordzie97
- Description
- Architecture
- Technologies
- Most important endpoints
- Cypress Automated Tests
- Zipkin
- Addresses
- Docker Swarm
- Documentation
The project puropse is to create the backend system which will support the bookstore activities.
System architecture is based on microservices. Communication between them is done using Feign Client.
The following microservices are highlighted:
- Bookstore-Gateway - gateway service that provides dynamic routing between microservices and filtering based on permissions.
- Bookstore-Products - products service, adding authors, books and data presentation.
- Bookstore-Orders - orders service, making order based on created basket.
- Bookstore-Baskets - basket service, assigning basket to user, value calculation.
- Bookstore-Accounts - registration, authentification and authorization service.
- Bookstore-Storage - save and file presentation service.
- Eureka-Service - holds the information about all available microservies.
- Java 11 + Spring Boot - Backend
- FeignClient - Communication between microservices
- ZUUL Proxy - API gateway
- Eureka Server - Microservices register
- Swagger - Automated documentation for describing RESTful APIs (expressed using JSON)
- Elastic, Logstash, Kibana, Zipkin - Application monitoring
- Docker / Docker Swarm - App containerization
- POST /accounts-service/registration - user registration (FormData interface).
- username, password, email, name, surname
- POST /accounts-service/auth - user authentication (FormData interface).
- username, password
- Bearer token as a response. Token is attached to every request and it has one of four roles encoded: admin, employee, user, notRegisteredUser.
-
POST /products-service/admin/author - adding author.
-
POST /products-service/admin/book - adding book.
-
GET /baskets-service/cart - creating basket, cookie with basket id is saved for using in the next requests.
-
POST /baskets-service/cart/{PRODUCT_ID} - adding product to basket.
-
DELETE /baskets-service/cart/{PRODUCT_ID} - deleting product from basket.
-
POST /orders-service/order - checking products availability and creating the order based on saved cookie.
- When we send request with Bearer token attached - in the response we will also see the ID of logged user.
Automated tests are based on JavaScript framework, Cypress. It suites really well for both frontend and backend automation.
Setting up (within cypress-bookstore folder):
npm install
- installing all modules which are defined in package.jsonnpm run open
- open Cypress Test Runner
Accounts-service/Accounts.spec.js - tests of accounts service:
- user registration, signing in, admin account check.
Products-service/Products.spec.js - tests of products service:
- adding author, adding book, resources presentation.
Baskets-Orders-service/Baskets-Orders.spec.js - complex tests of baskets and orders services:
- getting specific book, creating basket, adding and removing products from basket, making orders based on specific basket.
After running all servies and making requests between them, we can see logs from specific services (clicking on run query
). Whole configuration is added to docker-compose.
Setting up without docker compose: run -d -p 9411:9411 openzipkin/zipkin
.
- Main Gateway: http://localhost:9091
- Swagger: http://localhost:9091/swagger-ui.html
- Zipkin: http://localhost:9411
- Kibana: http://localhost:5601 (credentials: elastic / password)
docker swarm init
- starting master node swarmdocker-compose build
- creating images which will be deployed on stackdocker-compose pull
- pulling images which don't have Dockerfiledocker stack deploy --compose-file docker-compose.yml bookstore
- stack deployment to swarmdocker stack services bookstore
- checking status of all servies
Deleting stack and quiting from swarm node:
docker stack rm bookstore
- deleting stackdocker swarm leave --force
- quiting from swarm node
- Igor Dzierwa
- Adrian Nędza
- Konrad Makuch