Code Monkey home page Code Monkey logo

chatty's Introduction

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

chatty's People

Contributors

igornb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.