Skip to content

Order microservice with Spring Boot 3, Kafka producer/consumer, OpenAPI, Testcontainers integration tests, and GitHub Actions CI. Docker & K8s ready. MIT licensed.

License

Notifications You must be signed in to change notification settings

OrcnTester/order-events-spring-kafka

Repository files navigation

Order Events — Spring Kafka (CI ready)

build java spring kafka license

Concrete domain: Order microservice.

  • POST /api/orders → validates payload, persists in-memory (for demo), publishes order.created event to Kafka.
  • GET /actuator/health → health.
  • OpenAPI docs at /swagger-ui/index.html.
  • Unit tests (JUnit/Mockito) + Integration test with Testcontainers Kafka.
  • GitHub Actions CI (build + test + package).
  • Dockerfile + docker-compose (Kafka/Zookeeper + app).

Goal: Show real-world structure with SOLID, TDD/BDD flavor, OpenAPI-first mindset, and DevOps artifacts.

Quick Start (Local Dev)

# 1) Start infra
docker-compose up -d kafka zookeeper

# 2) Run app
./mvnw spring-boot:run

# 3) Create an order
curl -X POST http://localhost:8080/api/orders   -H "Content-Type: application/json"   -d '{
    "customerId":"c-1001",
    "items":[{"sku":"SKU-1","qty":2},{"sku":"SKU-2","qty":1}],
    "currency":"TRY",
    "total": 1299.90
  }' -i

# 4) Swagger UI
open http://localhost:8080/swagger-ui/index.html

Build & Test

./mvnw clean verify

Docker

docker build -t your-docker-user/order-events-spring-kafka:latest .
docker run -p 8080:8080 -e KAFKA_BOOTSTRAP_SERVERS=localhost:9092 your-docker-user/order-events-spring-kafka:latest

Kubernetes (basic)

kubectl apply -k k8s

Tech Highlights

  • SOLID: Controller → Service → Ports (Kafka), DTO & Mapper separation.
  • Testing: Unit (Mockito), Integration (Testcontainers Kafka).
  • OpenAPI: src/main/resources/openapi.yaml + springdoc UI.
  • DevOps: GitHub Actions CI, Dockerfile, K8s with Kustomize overlay.

By: Orçun

About

Order microservice with Spring Boot 3, Kafka producer/consumer, OpenAPI, Testcontainers integration tests, and GitHub Actions CI. Docker & K8s ready. MIT licensed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published