See demo on youtube.
This application is a sample project which illustrates rest-api integration of
- Spring Boot (37k stars backend)
- React-admin (7.8k stars front-end).
- 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
- On Application start liquibase and Spring-Batch load data from csv files. This is real world book data from https://www.kaggle.com/bshirude2/goodreads-content-based-book-recommendation/data. Data has the following amount distribution:
Books ~10.000
Book_Ratings ~1.000.000
Users ~1.000.000
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
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
andmapping
packages are moved fromservice
tocontroller
controller
package is divided to independent groups (calledadapter
) 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 otheradapter
- there are no circle dependencies
Not available
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
Regular POJO
's are used as Dto's. MapStruct is used as Mapper library.
Regular Spring @Service
's are used
Regular JPA
entities 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
- 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
Not available
- IgorNB
This project is licensed under the Apache License - see the LICENSE.txt file for details