Skip to content

misakaAron/springboot-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Spring Boot REST API

A production-ready REST API built with Spring Boot, JPA, Security, and OpenAPI documentation.

Features

  • RESTful API: Clean, consistent endpoints
  • JWT Authentication: Secure authentication with JWT tokens
  • Database: PostgreSQL with JPA/Hibernate
  • Validation: Input validation with Jakarta Validation
  • Error Handling: Global exception handling
  • API Documentation: Swagger UI with OpenAPI 3
  • CORS Support: Cross-origin resource sharing
  • Pagination: Pageable responses

Tech Stack

  • Java 17
  • Spring Boot 3.1.5
  • Spring Security
  • Spring Data JPA
  • PostgreSQL
  • JWT (jjwt)
  • Lombok
  • OpenAPI 3 (Swagger)

API Endpoints

Authentication

  • POST /api/v1/auth/login - Login with credentials
  • POST /api/v1/auth/refresh - Refresh access token

Users

  • GET /api/v1/users - Get all users
  • GET /api/v1/users/{id} - Get user by ID
  • POST /api/v1/users - Create new user
  • PUT /api/v1/users/{id} - Update user
  • DELETE /api/v1/users/{id} - Delete user

Products

  • GET /api/v1/products - Get all products (paginated)
  • GET /api/v1/products/search?query={query} - Search products
  • POST /api/v1/products - Create new product
  • PUT /api/v1/products/{id} - Update product
  • DELETE /api/v1/products/{id} - Delete product

Getting Started

Prerequisites

  • Java 17+
  • Maven
  • PostgreSQL

Setup

  1. Create database:
CREATE DATABASE apidb;
  1. Configure database in application.yml

  2. Run the application:

mvn spring-boot:run
  1. Access API documentation:

Project Structure

src/main/java/com/leo/api/
├── controller/     # REST controllers
├── model/         # Entity classes
├── dto/           # Data transfer objects
├── service/       # Business logic
├── repository/    # Data access layer
├── config/        # Configuration classes
└── exception/     # Exception handling

Docker Support (Optional)

FROM openjdk:17-jdk-slim
COPY target/springboot-api-*.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]

License

MIT

About

Production-ready REST API with Spring Boot 3, JPA, Spring Security, JWT and Swagger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages