Skip to content
/ Libby Public

(OTUS Spring course part 2) Sample project which illustrates rest-api integration of Spring Boot and React-admin

License

Notifications You must be signed in to change notification settings

IgorNB/Libby

Repository files navigation

Build Status SonarCloud Quality SonarCloud Coverage SonarCloud CodeSmell SonarCloud Bug License

Libby Pet-Project

See demo on youtube.

This application is a sample project which illustrates rest-api integration of

Prerequisites

Getting Started

  • get source code
git clone https://github.com/IgorNB/Libby.git
  • install front-end dependencies
npm install
  • Start (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)
./mvnw
npm start
Books ~10.000
Book_Ratings ~1.000.000
Users ~1.000.000

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

Architectural rules

checked with ArchUnit in ./test-architecture tests bundle. One of the most popular and general package structure for Spring Web App is selected. For example almost the same package structure is used in Jhipster with the following main changes:

  • dto and mapping packages are moved from service to controller
  • controller package is divided to independent groups (called adapter) to make it easier to control and lower code coupling

So, architectural unit tests check that

  • any layer (onion) uses only classes from layers with lower #, but not from bigger #. Layers (onions) # are the following:
# layer package
6 adapter controller.adapter
5 infrastructure controller.core
4 application config
3 service service, security
2 repository repository
1 domain domain

  • any adapter does not use classes from any other adapter
  • there are no circle dependencies

Deployment

Not available

Development

Controller

Regular Spring @RestController are used. You can use implements GenricUIApiController to check compatibility of your own controller with react-admin api in compile time (this is optional).

@Querydsl is used in public Page<> findAll(@QuerydslPredicate(root = .. endpoints to provide search by any field functionality. This is used for

  • user filtering in UI
  • relation-ship queries by react-admin

Dto, Mapper

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

Service

Regular Spring @Service's are used

Entity

Regular JPA entities 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

  • Spring - web framework
  • react-admin - frontend Framework for building admin applications running in the browser on top of REST/GraphQL APIs, using ES6, React and Material Design
  • 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

Contributing

Not available

Authors

  • IgorNB

License

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

About

(OTUS Spring course part 2) Sample project which illustrates rest-api integration of Spring Boot and React-admin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages