REST API for product management built with Spring Boot, with unit tests, CI and automated releases with GitHub Actions.
- Java 21
- Spring Boot 4
- Spring Data JPA
- PostgreSQL (Docker) / H2 (local)
- JUnit 5 + Mockito
- Maven
- Docker + Docker Compose
| Method | Endpoint | Description |
|---|---|---|
| GET | /products | List all products |
| GET | /products/{id} | Get product by id |
| POST | /products | Create product |
| PUT | /products/{id} | Update product |
| DELETE | /products/{id} | Delete product |
The recommended way to run the project is with Docker Compose, which sets up 3 services automatically:
| Service | Description | Port |
|---|---|---|
products-api |
Spring Boot REST API | 8080 |
postgres |
PostgreSQL database | 5432 |
pgadmin |
Database admin UI | 5050 |
Copy the example file and edit if needed:
cp .env.example .envThe default values in .env.example work out of the box for local development.
docker compose up --buildThe API will be available at http://localhost:8080/products.
Open http://localhost:5050 in your browser and log in with the credentials from your .env file (default password: admin123).
To connect to the database inside pgAdmin:
- Host:
postgres - Port:
5432 - Database:
productsdb - Username:
products_user - Password:
products_pass
| Variable | Description | Default |
|---|---|---|
POSTGRES_DB |
Database name | productsdb |
POSTGRES_USER |
Database user | products_user |
POSTGRES_PASSWORD |
Database password | products_pass |
API_PORT |
API exposed port | 8080 |
PGADMIN_EMAIL |
pgAdmin login email | admin@products.com |
PGADMIN_PASSWORD |
pgAdmin login password | admin123 |
PGADMIN_PORT |
pgAdmin exposed port | 5050 |
Uses H2 in-memory database, no configuration needed:
./mvnw spring-boot:run./mvnw test| Workflow | Trigger | Action |
|---|---|---|
| CI - Tests | Push/PR to main | Runs all tests |
| Release | Tag v* |
Builds and publishes .jar to GitHub Releases |
| Docker Image Publish | Push to main / Release | Builds and pushes Docker image to ghcr.io |
The Docker image is publicly available at:
ghcr.io/montillha/products-api:main