Giter Site home page Giter Site logo

standard-springboot-api's Introduction

standard-springboot-api

Java Docker

A modern boilerplate or project structure for Springboot API with common toolkit πŸ› 

Table of contents

Project structure

.
β”œβ”€β”€ bin/
β”œβ”€β”€ docker/
β”œβ”€β”€ scripts/
β”œβ”€β”€ src
    β”œβ”€β”€ main
        β”œβ”€β”€ java/
            β”œβ”€β”€ com.kelvn/
                β”œβ”€β”€ config/
                β”œβ”€β”€ controller/
                β”œβ”€β”€ dto/
                β”œβ”€β”€ enums/
                β”œβ”€β”€ exception/
                β”œβ”€β”€ model/
                β”œβ”€β”€ repository/
                β”œβ”€β”€ security/
                β”œβ”€β”€ service/
                β”œβ”€β”€ utils/
        β”œβ”€β”€ resources/
β”œβ”€β”€ target/
β”œβ”€β”€ .gitignore
β”œβ”€β”€ pom.xml
β”œβ”€β”€ README.md

Prerequisites

Usage

  • Generating Qmodel (QueryDsl)

    mvn clean install

    Note: Model classes will be generated into folder target/generated-sources/**/model, copy it to src for using purpose

  • Generating cryptographic keys

    Warning: The openssl extension is required

    openssl version
    • To generates a new RSA private key with a length of 2048 bits

      openssl genrsa -out keypair.pem 2048
    • To extracts the public key

      openssl rsa -in keypair.pem -pubout -out public.pem
    • To converts the private key into the PKCS#8 format

      openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out private.pem

    Note: Or simply

     sh bin/setup-jwt-key.sh
  • πŸ’… Formatting

    • To implement automated code formatting

      mvn spotless:apply
    • To validate if code was formatted

      mvn spotless:check
  • Githooks

    • To setup pre-commit

      cp scripts/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit

      Note: Or simply

      sh bin/setup-pre-commit.sh

      Note: To not run pre-commit

      git commit -m "${message}" --no-verify
  • Deployment

    sh bin/build-and-push-image.sh -e ${env}

    Note: Bonus

    • To build project

      mvn clean install -DskipTests -P ${env}
    • To execute .jar file

      java -jar ${filename}.jar

References

  • Visit here to learn more about Best Practices in Spring Boot Project Structure
  • Visit here to learn more about πŸ’‰Dependency Injection
  • Visit here to learn more about Base Entity or AbstractPersistable for alternatives
  • Visit here to learn more about Database Audit
  • Visit here to learn more about Soft Delete functionality
  • Visit here to learn more about production-grade dynamic filters using QueryDSL
  • Visit here to learn more about Spring Security + JWTs
  • Visit here to learn more about Log request and responses of REST APIs
  • Visit here to learn more about Spring Boot REST API Error Handling
  • Visit here to learn more about ModelMapper with more complex objects
  • Visit here to learn more about Spotless formatting with Git pre-commit hook
  • Visit here to learn more about RabbitMQ
  • Visit Google, Spring blog to learn more about OAuth 2.0 for Client-side and OAuth 2.0 Playground, Graph API Explorer for testing purpose
  • Visit Official Docs, JPA Buddy to learn more about Dynamic Entity Graph

License

(C)2023

standard-springboot-api's People

Contributors

khanh-mati avatar kelvn-dev avatar

Watchers

 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.