GithubHelp home page GithubHelp logo

andersonmeurer / spring-boot-3-rest-api-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from digitalinnovationone/spring-boot-3-rest-api-template

0.0 0.0 0.0 122 KB

Home Page: https://dio.me

License: MIT License

Java 99.25% Procfile 0.75%

spring-boot-3-rest-api-template's Introduction

DIO Spring Boot RESTful API Template

Welcome to the DIO Spring Boot RESTful API Template! This project serves as a foundational template for creating RESTful APIs using Spring Boot 3, Spring Data JPA, and OpenAPI (Swagger) for API documentation. We have utilized the power of Java 17, the latest LTS version of Java, to build this project.

As an edtech company, DIO is committed to providing valuable resources for developers and this project is no exception. It stands as a quick start guide to jump-start your API development with the best practices embedded.

Table of Contents

Key Features:

  • Java 17: Leveraging the latest LTS version of Java, improving readability and efficiency.
  • Spring Boot 3: An upgraded version of Spring Boot, enhancing developer productivity with its auto-configuration feature. Generated using Spring Initializr.
  • Spring Data JPA: Simplifying the database access layer by reducing the boilerplate code.
  • OpenAPI (Swagger): Integrated with OpenAPI 3, enabling seamless API documentation for better understanding and testing.

Project Structure:

The project is organized into several packages, each serving a specific purpose:

  • controller: This package contains our Rest Controllers. Here, we expose our endpoints, following the REST architectural style. DTOs are used in this layer to define the consumption interfaces appropriately, avoiding the exposure of unnecessary model attributes.

  • exception: define our custom exceptions and a global exception handler for dealing with Spring's exceptions.

  • model: where our entities are defined, using JPA (Jakarta) annotations for ORM with our SQL database.

  • repository: In this package, we handle data access using interfaces provided by Spring Data JPA.

  • service: where our business logic lives. Here we validate our data, handle business exceptions, and manage access to our SQL database through repositories.

  • Application.java: This is the main class to run our project. It initializes our Spring application and connects all the components together.

Please note that this structure is a simple suggestion for educational purposes. Each developer is free to adapt and modify this structure according to their project needs and standards.

Setup

These instructions guide you through cloning the repository and starting the application in Unix or Windows environments, with the development profile enabled.

  1. Clone the repository: git clone https://github.com/digitalinnovationone/spring-boot-3-rest-api-template.git
  2. Start the application in the Unix environment: ./gradlew bootrun --args='--spring.profiles.active=dev'
  3. Start the application in the Windows environment: gradle.bat bootrun --args='--spring.profiles.active=dev'

Project Details:

The project focuses on a Heroes API as an example, which includes basic CRUD operations and gain experience (XP) system. It adheres to the best practices of RESTful principles, such as idempotent operations and the use of appropriate HTTP status codes.

Exception handling is globally managed with a @RestControllerAdvice to ensure consistent handling of exceptions throughout the entire application.

The project also includes the setup for an H2 database (an in-memory database) for testing purposes and development environment. For the production environment on Railway, PostgreSQL database is used.

API Usage (Swagger UI Documentation)

The API documentation can be found on Swagger UI. To view it, please visit: Swagger UI.

Hosting on Railway

Both this project and your PostgreSQL database are hosted on Railway.app. To access our demo application, visit:

Contribution

We welcome contributions! If you encounter any issues or have suggestions for improvements, don't hesitate to open an issue or submit a pull request.

License

This project is licensed under the MIT License. Please refer to the (LICENSE) file for details.

Authors


Venilton FalvoJr

LinkedIn

Camila Cavalcante

LinkedIn

Rafa Skoberg

LinkedIn

spring-boot-3-rest-api-template's People

Contributors

falvojr avatar cami-la 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.