osandadileepa / user-data

Example project to show user related data in a REST api with simple Spring Boot project with MySQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting Started

Application get all user details available in database and have the ability to create new user, edit any user and delete any user

Development Environment setup

Make sure following are available

  • JDK 11
  • Docker and Docker Compose
  • MySQL 5.7

MySQL instance details

  • MySQL instance should be exposed in localhost in port 3308 (http://localhost:3308). If you don't have an instance please use the docker compose in src/docker
  • Default database store should be created with the credentials available in the yml file.

Application source and development environment

  • Backend available at src/main/java
  • Docker environment available at src/main/docker
  • MySQL instance can be generated by using docker-compose file at src/main/docker(command : docker-compose up)
  • Backend will be available by using following command at the project root.
SPRING_PROFILES_ACTIVE=dev ./gradlew bootRun

Start the application

  • MySQL instance should available at locally, port 3308 (http://localhost:3308) with correct credentials in order to jar file to work.
  • Use the following command to create the executable jar.
./gradlew bootJar or ./gradlew clean build (to build with tests passes)
  • After jar file is successfully created use the following command to start the application.
java -jar -Dspring.profiles.active=dev build/libs/user-data-0.0.1-SNAPSHOT.jar

After executing above command application present at http://localhost:8080

Test cases

  • All the test cases written to test application core logics are available at src/test/java

API Documentation with Open API

Swagger UI and API docs available at http://localhost:8080/swagger/ui.html

Docker based production build

  • Docker based build solution has implemented using Dockerfile and docker compose file also available to create the necessary environments.
  • Docker images is created with jar file and MySQL instance is also added to the docker environment to have all dependencies in production
  • Using the following command in the root directory to execute the build.
docker-compose up --build -d

About

Example project to show user related data in a REST api with simple Spring Boot project with MySQL


Languages

Language:Java 98.9%Language:Dockerfile 1.1%