Skip to content
forked from IgorNB/Chatty

(Chat) Sample project which illustrates JWT secured statless rest-api & websocket (through RabbitMQ) in Spring Boot

License

Notifications You must be signed in to change notification settings

lequocvuong/Chatty

 
 

Repository files navigation

Build Status SonarCloud Quality SonarCloud Coverage SonarCloud CodeSmell SonarCloud Bug License

chatty Pet-Project

See demo on youtube.

(Chat) Sample project which illustrates JWT secured statless rest-api & websocket (through RabbitMQ) in Spring Boot.

Prerequisites

Getting Started

  • 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):
  1. api: localhost:8090
  2. api swagger ui: localhost:8090/swagger-ui.html
  3. spring actuator: localhost:8090/actuator
  4. 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):
  1. nginx loadbalancer: localhost:8090
  2. api: localhost:8091 & 8092
  3. api swagger ui: localhost:8091/swagger-ui.html & 8092
  4. spring actuator (per server): localhost:8091/actuator & 8092
  5. rabbitmq ui: localhost:15672 (guest/guest)
  6. 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

Installing

No installation available. See "Getting started"

Running the tests

  • tests
./mvnw clean test
  • tests coverage (with Jacoco. Min line coverage is auto-checked 70%)
./mvnw clean verify

And coding style tests

General rules

checked with Sonar Quility Gate

Development

Controller

Regular Spring @RestController are used.

Dto, Mapper

Regular POJO's are used as Dto's. MapStruct is used as Mapper library.

Service

Regular Spring @Service's are used

Entity, Repository

Regular JPA entities and Spring Data JPA repositories are used.

Migrations

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>

Built With

Contributing

Not available

Authors

  • IgorNB

License

This project is licensed under the Apache License - see the LICENSE.txt file for details

About

(Chat) Sample project which illustrates JWT secured statless rest-api & websocket (through RabbitMQ) in Spring Boot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 91.4%
  • JavaScript 7.0%
  • HTML 1.5%
  • Dockerfile 0.1%