Skip to content

montillha/products-api

Repository files navigation

Products API

REST API for product management built with Spring Boot, with unit tests, CI and automated releases with GitHub Actions.

Technologies

  • Java 21
  • Spring Boot 4
  • Spring Data JPA
  • PostgreSQL (Docker) / H2 (local)
  • JUnit 5 + Mockito
  • Maven
  • Docker + Docker Compose

Endpoints

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

Running with Docker

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

1. Configure environment variables

Copy the example file and edit if needed:

cp .env.example .env

The default values in .env.example work out of the box for local development.

2. Start all services

docker compose up --build

The API will be available at http://localhost:8080/products.

3. Access pgAdmin

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

Environment variables

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

Running locally (without Docker)

Uses H2 in-memory database, no configuration needed:

./mvnw spring-boot:run

Running tests

./mvnw test

CI/CD

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

About

REST API for product management built with Spring Boot, with unit tests, CI and automated releases with GitHub Actions.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages