A multi vendor clothing marketplace built from 10 Spring Boot microservices behind one API gateway, with a Next.js storefront. Checkout runs as a Kafka saga that reserves stock, charges with Stripe, and undoes its own work when a step fails.
Cloth Shop is an online clothing marketplace where many sellers list their products and customers buy from all of them in one cart. It is split into ten small Spring Boot services. Each one owns one part of the business (products, orders, payments, sellers, carts and so on) and has its own database. A single API gateway sits in front of them, and a Next.js storefront is the only app that talks to that gateway.
The interesting part is checkout. Instead of one big database transaction, an order moves through a chain of events over Apache Kafka: the order is created, stock is reserved, then the card is charged through Stripe. If any step fails, the system runs the opposite step to clean up, so an order is never left half finished. This pattern is called a saga.
There are three kinds of users: customers, sellers and admins. All three sign in through Keycloak, an open-source login server. The project also has monitoring (Prometheus, Grafana, Zipkin), a Jenkins CI pipeline for every service, and a Docker Compose setup for running the whole system on one cloud VM.
Architecture
FE
Service
Next.js 16
GW
Service
Spring Cloud Gateway
KC
Service
Keycloak (OIDC)
CUST
Service
Spring Boot
PROD
Service
Spring Boot
SELL
Service
Spring Boot
CART
Service
Spring Boot
ORD
Service
Spring Boot
PAY
Service
Spring Boot
NOTIF
Service
Spring Boot
CDB
Database
MongoDB
PDB
Database
PostgreSQL
SDB
Database
PostgreSQL
RDS
Database
Redis
ODB
Database
PostgreSQL
PYDB
Database
PostgreSQL
NDB
Database
MongoDB
MIN
Service
MinIO (S3-compatible)
KFK
Queue
Apache Kafka
KFK
Service
Stripe API
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.
Technical decisions
Optimistic locking + idempotency keys
Reason
Stops overselling under concurrent buying and stops double charges on retried requests, without locking rows for long.
Alternatives considered
Pessimistic database locks a distributed lock in Redis
Trade-offs
Losers of a race must retry or fail, and clients must send an Idempotency Key.
Security
• Keycloak (OAuth2 / OpenID Connect) with three realm roles: customer, seller and admin. A custom converter reads Keycloak's nested realm_access.roles claim, which Spring Security doesn't read by default.
• Stripe webhooks are checked by their signature, not by a login token.
• All secrets are listed in .env.example, and the real .env is kept out of git.
Observability
Every service exposes Prometheus metrics, which feed a pre built Grafana dashboard. Zipkin traces one request across all the services it touches.
Testing
Three layers:
1. Unit tests (JUnit 5 + Mockito) in every service: 94 test methods across 25 test classes.
2. Integration tests (Testcontainers) for order-service's Kafka listeners, against a real PostgreSQL 16 and a real Kafka.
3. End-to-end tests (Playwright): 4 spec files covering catalog, auth gates, customer checkout and the seller flow.
Future improvements
• Ignore duplicate Kafka messages on the consumer side, so a redelivered event can't reserve stock or charge twice.
• Extend the Testcontainers integration tests from order service to product service and payment-service.
• Bring the product database's Flyway migration history up to date (newer changes currently rely on Hibernate's auto update).
• Add HTTPS with a real domain for the live demo.
• Add alerting (Alertmanager) once there is real traffic to set thresholds from.