Repository files navigation
Developed a RESTful CRUD API using Spring Boot and Java.
Implements Create, Read, Update, and Delete operations for a User resource.
Follows REST standards, clean architecture, and best practices.
Uses PostgreSQL as the relational database.
Fully containerized using Docker and Docker Compose.
How the Application Works
REST endpoints are exposed using @RestController.
HTTP requests are mapped using @GetMapping, @PostMapping, @PutMapping, and @DeleteMapping.
Business logic interacts with the database via Spring Data JPA repositories.
JPA entities are used to map Java objects to database tables.
Java Optional is used to safely handle missing data.
orElseThrow() is used to return proper HTTP 404 responses when resources are not found.
ResponseEntity is used to control HTTP status codes and response bodies.
The application connects to PostgreSQL through Docker network using service names.
Java 17
Spring Boot
Spring Data JPA
PostgreSQL
Maven
Docker
Docker Compose
How to Build and Run (Docker)
Ensure Docker and Docker Compose are installed.
Clone the repository and navigate to the project directory.
Build the application using Maven: mvn clean package.
Start the application and database containers using: docker compose up --build.
The API will be available at http://localhost:8080.
GET /users – Retrieve all users.
GET /users/{id} – Retrieve a user by ID.
POST /users – Create a new user.
PUT /users/{id} – Update an existing user.
DELETE /users/{id} – Delete a user by ID.
What I Learned From This Project
How to design RESTful APIs using Spring Boot.
Proper usage of Optional and why orElseThrow() is safer than calling get().
How ResponseEntity provides full control over HTTP responses.
The importance of constructor-based dependency injection.
How to model entities and repositories using Spring Data JPA.
How to bind Spring Boot application properties to Docker environment variables.
How Docker images work and how to choose the correct Java base image.
How to orchestrate multiple containers using Docker Compose.
How to avoid Java version mismatch issues when containerizing applications.
General backend best practices such as clean code, error handling, and API consistency.
Add DTOs and input validation.
Implement global exception handling using @ControllerAdvice.
Add pagination and sorting.
Integrate Swagger / OpenAPI documentation.
Add authentication and authorization.
You can’t perform that action at this time.