Skip to content

ComHem/quantum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

155 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum

Quantum webapp using Spring Boot on the backend and React on the frontend, with Maven and Webpack as build tools, hot reloading on both sides and without xml configuration.

Production

App can be reached here --> Com Hem: http://52.166.144.86/ Boxer : http://52.166.1.243/

Status

Travis CI:

Build Status

Docker

Build

docker build . -t quantum

Start

docker run --rm --name quantum -p 8080:8080 quantum

Quickstart

To run the app you just need to:

cd quantum
mvn spring-boot:run

To check everything is running you can:

# Visit the homepage
http://localhost:8080

Start developing

The Java code is available at src/main/java as usual, and the frontend files are in src/main/frontend.

Running the backend

Run QuantumApplication class from your IDE.

Running the frontend

Go to src/main/frontend and run npm start. (Run yarn (or npm install) before that if it's the first time)

Now we should work with localhost:9090 (this is where we'll see our live changes reflected) instead of localhost:8080.

Hot reloading

In the backend we make use of Spring DevTools to enable hot reloading, so every time we make a change in our files an application restart will be triggered automatically.

Keep in mind that Spring DevTools automatic restart only works if we run the application by running the main method in our app, and not if for example we run the app with maven with mvn spring-boot:run.

In the frontend we use Webpack Dev Server hot module replacement through the npm script start. Once the script is running the Dev Server will be watching for any changes on our frontend files.

This way we can be really productive since we don't have to worry about recompiling and deploying our server or client side code every time we make changes.

Profiles

The project comes prepared for being used in three different environments plus another one for testing. We use Spring Profiles in combination with Boot feature for loading properties files by naming convention (application-<profile name>.properties).

You can find the profile constants in StarterProfiles and the properties files in src/main/resources.

Security

All the boilerplate for the initial Spring Security configuration is already created. These are they key classes:

Unit and integration testing

For unit testing we included Spring Test, JUnit, Mockito and AssertJ as well as an AbstractUnitTest class that we can extend to include the boilerplate annotations and configuration for every test. UserServiceTest can serve as an example.

To create integration tests we can extend AbstractIntegrationTest and make use of Spring @sql annotation to run a databse script before every test, just like it's done in UserRepositoryTest.

Code coverage

The project is also ready to use Cobertura as a code coverage utility and Coveralls to show a nice graphical representation of the results, get a badge with the results, etc.

The only thing you need to do is to create an account in Coveralls.io and add your repo token key here in the pom.xml.

And if you want to use different tools you just need to remove the plugins from the pom.

Linting

We added ESLint preconfigured with Airbnb rules, which you can override and extend in .eslintrc.js file. To lint the code you can run npm run eslint or configure your IDE/text editor to do so.

Continuous integration and deployment

A travis.yml file is included with a minimal configuration just to use jdk 8, trigger the code analysis tool and deploy the app to Heroku using the api_key in the file.

We also included a Heroku Procfile which declares the web process type and the java command to run our app and specifies which Spring Profile we want to use.

Other ways to run the app

Run everything from Maven

mvn generate-resources spring-boot:run

The Maven goal generate-resources will execute the frontend-maven-plugin to install Node and Npm the first time, run npm install to download all the libraries that are not present already and tell webpack to generate our bundle.js. It's the equivalent of running npm run build or npm start on a terminal.

Run Maven and Webpack separately (no hot-reloading)

mvn spring-boot:run

In a second terminal:

cd src/main/frontend
npm run build

Tech stack and libraries

Backend

Frontend


About

Social media aggregator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors