A layered REST API built with Spring Boot 3, demonstrating clean architecture with proper separation between Controller, Service, and Repository layers.
| Layer | Technology |
|---|---|
| Framework | Spring Boot 3 |
| Language | Java 17 |
| Database | H2 (in-memory) / PostgreSQL-ready |
| ORM | Spring Data JPA / Hibernate |
| Docs | SpringDoc OpenAPI (Swagger UI) |
| Build | Maven |
HTTP Request
│
▼
┌─────────────┐
│ Controller │ → Handles HTTP, delegates to service
└──────┬──────┘
│
▼
┌─────────────┐
│ Service │ → Business logic, validation
└──────┬──────┘
│
▼
┌─────────────┐
│ Repository │ → Data access via Spring Data JPA
└──────┬──────┘
│
▼
Database
Requirements: Java 17+, Maven 3.8+
git clone https://github.com/cherohn/Spring-Basic-REST-API.git
cd Spring-Basic-REST-API
mvn spring-boot:runAccess Swagger UI at: http://localhost:8080/swagger-ui.html
| Method | Path | Description |
|---|---|---|
| GET | /api/items |
List all items |
| GET | /api/items/{id} |
Get item by ID |
| POST | /api/items |
Create new item |
| PUT | /api/items/{id} |
Update item |
| DELETE | /api/items/{id} |
Delete item |
- How Spring's dependency injection connects the layers without tight coupling
- How JPA maps Java objects to database tables and handles queries automatically
- How to document APIs with OpenAPI so they're immediately usable by other developers
Matheus Garcez — github.com/cherohn · linkedin.com/in/matheus-garcez-172377249