Skip to content

mykeleony/clients-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring-based REST API for Clients Management

Welcome to a professional and elegant Spring-based REST API project! I am proud to present an API that is designed to manage clients for a fictional company, utilizing the power of the Spring framework to handle various tasks such as:

Persistence

@Entity
public class Client {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    //...
}

The API uses JPA and Hibernate to handle data storage and retrieval, allowing for easy integration with a variety of databases. This ensures that our data is always accurate, up-to-date, and easily accessible.

Bean Validation

public class ClientInput {

    @NotBlank
    @Size(max = 255)
    private String name;
    //...

Utilizing the built-in validation classes capabilities of Spring within representation classes, we ensure that all incoming data is properly formatted and meets the requirements of our application. This guarantees that our data is always valid and consistent, ensuring a smooth user experience.

Exception Handling

@ExceptionHandler(BusinessException.class)
public ResponseEntity<Object> handleBusinessException(BusinessException ex, WebRequest request) {
    HttpStatus status = HttpStatus.BAD_REQUEST;

    Problem problem = new Problem();
    problem.setStatus(status.value());
    problem.setDateAndHour(OffsetDateTime.now());
    problem.setTitle(ex.getMessage());

    return handleExceptionInternal(ex, problem, new HttpHeaders(), status, request);
}

Spring's exception handling capabilities allow us to gracefully handle any errors that may occur during the execution of our API. This ensures that our API is always available and responsive, even in the face of unexpected issues.

Non-CRUD Operations Management

@ResponseStatus(HttpStatus.NO_CONTENT)
@PutMapping("/{deliveryId}/conclusion")
public void conclude(@PathVariable Long deliveryId) {
    deliveryFinalizationService.conclude(deliveryId);
}

The API uses Spring's built-in support for handling non-CRUD operations, such as pagination and sorting, to provide a more robust and user-friendly experience. This allows for easy navigation and management of large amounts of data.

Microservices

By utilizing Spring's support for microservices, we are able to break our API down into smaller, more manageable pieces, allowing for easier scaling and maintenance. This ensures that our API is always performing at its best, even as our data and user base grows.

ISO Date and Time Format

private OffsetDateTime requestMoment;

We use the ISO format for all date and time data, ensuring consistency and compatibility across different systems and languages. This guarantees that our data is always accurate and easily understood by all users.

Productivity and maintenance

In addition to Spring, the project utilize other tools such as Flyway for database migrations, DevTools for enhanced development experience and Lombok for model/data objects boilerplate code reduction.

This API is designed to be both user-friendly and technically robust, utilizing the latest industry standards and best practices. So dive in and start exploring the capabilities of this API right now!