This project is a study on building a RESTful API using Spring Webflux. It aims to demonstrate the use of reactive programming principles.
- Spring Webflux: A reactive web framework for building scalable and high-performance web applications.
- Gradle: A build automation tool for managing dependencies, compiling, and packaging the project.
- Java 17: The programming language used for developing the project.
- MongoDB Reactive: A reactive MongoDB driver for interacting with the database.
- Lombok: A library for reducing boilerplate code and improving developer productivity.
- Mapstruct: A library for mapping between Java beans and DTOs.
The project is structured into the following modules:
- src/main/java: Contains the Java source code for the project, including the API controllers, services, and entities.
- controller: Contains the REST controllers for handling HTTP requests.
- entity: Contains the data entity for the API, including the
User
class. - mapper: Contains the mapper classes for the User entity and request.
- repository: Contains the class for interacting with the database.
- service: Contains the service classes for the project.
- validator: Contains the annotation interface to validate requests inputs.
The project provides the following API endpoints:
- POST /users: Creates a new user.
- GET /users: Retrieves a list of all users.
- GET /users/{id}: Retrieves a user by ID.
- PUT /users/{id}: Updates a user by ID.
- DELETE /users/{id}: Deletes a user by ID.
To run the project, follow these steps:
- Clone the repository to your local machine.
- Navigate to the project directory and run
docker compose up -d
to start MongoDB local instance. - Run
gradle bootRun
to start the application. - Use a tool like Postman or cURL to test the API endpoints.