See demo on youtube.
(Chat) Sample project which illustrates JWT secured statless rest-api & websocket (through RabbitMQ) in Spring Boot.
- get source code
git clone https://github.com/IgorNB/chatty.git
- install front-end dependencies
npm install
- Start development environment (with not needed to be installed in-memory H2 dataBase and in-memory MQ). Run the following commands in two separate terminals to create a blissful development experience where your browser auto-refreshes when files change on your hard drive You will get (relative to host):
- api: localhost:8090
- api swagger ui: localhost:8090/swagger-ui.html
- spring actuator: localhost:8090/actuator
- front-end ui sample: localhost:8080
./mvnw
npm start
- Alternative is to start full environment in separate docker containers (1 nginx loadbalancer, >1 Spring backend services, 1 Postgres DB database, 1 RabbitMQ MQ). Please wait - it takes some time after container is up. You will get (relative to host):
- nginx loadbalancer: localhost:8090
- api: localhost:8091 & 8092
- api swagger ui: localhost:8091/swagger-ui.html & 8092
- spring actuator (per server): localhost:8091/actuator & 8092
- rabbitmq ui: localhost:15672 (guest/guest)
- front-end ui sample: localhost:8080
mvnw clean install -DskipTests
docker-compose build
docker-compose up -d --remove-orphans
npm start
and to remove
docker-compose stop
docker-compose rm
No installation available. See "Getting started"
- tests
./mvnw clean test
- tests coverage (with Jacoco. Min line coverage is auto-checked 70%)
./mvnw clean verify
checked with Sonar Quility Gate
Regular Spring @RestController
are used.
Regular POJO
's are used as Dto's. MapStruct is used as Mapper library.
Regular Spring @Service
's are used
Regular JPA
entities and Spring Data JPA repositories are used.
Entity changes are applyed to DB on application start (Liquibase is used). Liquibase changesets are used to illustrate production ready development lifecycle (instead of Hibernate Hbm2dll which is deprecated for usage in production).
- To speed up development changeSet should be generated automatically, then reviewed by developer and included in commit. Use next command to auto-generate changeset (note that liquibase.contexts=gen is used to skip test data load, which should be marked with "context: test" in changeSet files):
mvn clean compile liquibase:clearCheckSums liquibase:dropAll liquibase:update -Dliquibase.contexts=gen liquibase:diff
- Review auto-generataed changeSet file, make changes if needed and run next command to check your test data can be loaded in your new DB schema (or just start application and this will be done automatically):
mvn clean compile liquibase:clearCheckSums liquibase:dropAll liquibase:update liquibase:diff
- Changeset will be also automatically applied on start up, but if you want to see DB without starting application run next command:
mvn liquibase:update
- Changeset can be auto-generated in xml, yaml or SQL (database specific) format. To change it, please, change value of the next property in .POM file:
<liquibase.changeLogFile.format>
- Spring - web framework
- MapStruct - mapper library
- Apache Commons Lang 3 - helper utilities for the java.lang API
- Maven - dependency Management
- Junit5 - testing framework
- Mockito - mocking framework for unit tests
- AssertJ - fluent assertions library
- Jacoco - code coverage library
- Sonar Cube - Continuous Code Quality provider
- Travis CI - Continuous Integration provider
Not available
- IgorNB
This project is licensed under the Apache License - see the LICENSE.txt file for details