Skip to content

About

Demo spring MS to be used as submodule

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

demo-spring

A simple Spring Boot microservice used as a shared dependency across POC repositories (Kong, Kafka, etc.). It provides a basic in-memory Product REST API built with Kotlin and Spring WebFlux.

The intention is to pull this repo in as a git submodule when you need a running HTTP target for testing API gateway routing (Kong), event streaming integration (Kafka), or any other infrastructure POC — without needing to spin up a dedicated service each time.


What it does

Exposes a reactive CRUD REST API over an in-memory product store:

Method Path Description Status
GET /products List all products 200
GET /products/{id} Get product by id 200
POST /products Create a product 201
DELETE /products/{id} Delete a product 204

Example request

curl -X POST http://localhost:8080/products \
  -H "Content-Type: application/json" \
  -d '{"name":"Widget","price":9.99,"category":"gadgets"}'
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Widget",
  "price": 9.99,
  "category": "gadgets"
}

Stack

  • Spring Boot 4.1 (Spring WebFlux — reactive)
  • Kotlin / JVM 21
  • Gradle (Kotlin DSL)
  • In-memory store — no database required

Running locally

Prerequisites: JDK 21

./gradlew bootRun

Service starts on http://localhost:8080.


Running with Docker

docker compose up --build

Service starts on http://localhost:8080.

To stop:

docker compose down

Tests

Unit tests

./gradlew test --tests "com.example.demo.unit.*"

Covers ProductService (reactive StepVerifier) and ProductController (@WebFluxTest with mocked service).

Integration tests (Cucumber / BDD)

./gradlew test --tests "com.example.demo.integration.CucumberIT"

Scenarios in src/test/resources/features/products.feature spin up the full server (@SpringBootTest) and exercise the API end-to-end via WebTestClient.

All tests

./gradlew test

Using as a git submodule

Add to another repo (e.g. kong-poc or kafka-poc):

git submodule add <this-repo-url> demo-spring
git submodule update --init --recursive

Then in the parent repo's docker-compose.yml, reference the submodule's service:

services:
  demo-spring:
    build: ./demo-spring
    ports:
      - "8080:8080"

This keeps the demo service versioned alongside each POC without duplicating code.

About

Demo spring MS to be used as submodule

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages