This repository contains a small auction platform built as four Spring Boot microservices:
auth-service– users, sign‑up / sign‑in, HTML UI pages.catalogue-auction-service– catalogue items and auction logic (Forward & Dutch).payment-service– simple payment placeholder / receipt.gateway– Spring Cloud Gateway front‑end on port8080.
The system supports Forward bidding and Dutch “buy now” auctions, with a simple HTML UI (Thymeleaf) and separate PostgreSQL databases for each service when running under Docker.
- Java 21, Spring Boot 3.5.x
- Spring Web, Spring Data JPA, Validation, Security
- Spring Cloud Gateway (reactive) on the
gatewayservice - Thymeleaf server‑side templates (auth‑service UI)
- PostgreSQL 16 (Docker profile), H2 in‑memory for local dev
- JWT via
com.auth0:java-jwt
AuctionProject/
auth-service/ # UI + auth + orchestration
catalogue-auction-service/ # catalogue items + auction engine
payment-service/ # payment placeholder
gateway/ # edge API gateway on 8080
docs/ # diagrams / notes
docker-compose.yml # multi-container environment
.env.example # example env overrides
Each service is a standalone Spring Boot application with its own pom.xml and application[-docker].properties.
HTTP ports (host → container):
8080:8080– gateway- Public entry point. Routes:
/api/auth/**→auth-service:8081/api/catalogue/**,/api/auctions/**→catalogue-auction-service:8082/api/payments/**→payment-service:8083- everything else (
/**) →auth-service:8081(HTML UI).
- Public entry point. Routes:
8081:8081– auth-service- Handles sign‑up/sign‑in, catalogue page, auction page, payment pages.
8082:8082– catalogue-auction-service- JSON APIs only (no HTML at
/), e.g./api/catalogue/items,/api/auctions/{id}.
- JSON APIs only (no HTML at
8083:8083– payment-service- JSON APIs for payments, e.g.
/api/payments/**. No HTML UI on/.
- JSON APIs for payments, e.g.
PostgreSQL containers (host → container):
postgres-auth–5433:5432, DBauthdb, userauth.postgres-catalogue–5434:5432, DBcataloguedb, usercatalogue.postgres-payment–5435:5432, DBpaymentdb, userpayment.
Each service connects to its DB using the SPRING_DATASOURCE_URL set in docker-compose.yml.
To inspect data directly you can connect with any SQL client to:
localhost:5433/authdb/authlocalhost:5434/cataloguedb/cataloguelocalhost:5435/paymentdb/payment
- Seller sets a starting price and an end time.
- Bidders can see the current highest bid and time remaining.
- Each new bid must be an integer strictly higher than the current price.
- The auction ends when the fixed time
Lelapses; the highest bidder wins. - If no bids are placed before
L, the item is removed/marked ended.
Implementation highlights:
- Entity:
CatalogueItemincatalogue-auction-service. - Validation:
AuctionService.validateForwardBidenforces type, active status, end time, and strictly increasing bids. - Updates:
AuctionService.attemptForwardBidstores the newcurrentPriceandhighestBiddertransactionally.
- Seller sets a high starting price, a reserve price, and an end time.
- A scheduler (
DutchAuctionScheduler) periodically decrements the price down to the reserve. - Any bidder may accept the current price via “Buy Now”, which ends the auction immediately at that price.
- If no one buys before time
Lelapses, the item is ended and removed.
Implementation highlights:
- Periodic price decrement:
CatalogueRepository.decrementDutchPrices()called byDutchAuctionScheduler. - Buy Now validation:
AuctionService.validateDutchBuy(type, active, not ended). - Buy Now update:
AuctionService.attemptDutchBuysetsactive=false, recordshighestBidder, and stamps the final end time.
- Item creation requires a future end time:
- API DTO
CreateItemRequestuses@FutureonendTime. - UI form
ItemFormalso uses@Futureso users cannot submit past times.
- API DTO
- Both
auth-serviceandcatalogue-auction-serviceset a consistent JVM time zone (e.g.America/Toronto) to ensure that browser times and server validation line up.
From the repo root (the directory containing docker-compose.yml):
# Build all services
docker compose build
# Start services and Postgres
docker compose upThen visit the gateway:
- UI entry point:
http://localhost:8080- Sign up / sign in.
- Access the active catalogue.
- Create Forward / Dutch auction items.
- Place bids or use Buy Now.
The individual service ports (8081, 8082, 8083) are available for API testing (e.g. with Postman), but they are not intended to serve HTML on / – a plain / request will return the default Spring “Whitelabel Error Page (404)” for those services.
Each service can also run against its default in‑memory H2 database:
cd AuctionProject/auth-service
mvn spring-boot:run
cd AuctionProject/catalogue-auction-service
mvn spring-boot:run
cd AuctionProject/payment-service
mvn spring-boot:run
cd AuctionProject/gateway
mvn spring-boot:runIn this mode:
auth-service,catalogue-auction-service, andpayment-serviceuse theirapplication.properties(H2 URLs).gatewaystill listens onhttp://localhost:8080and forwards to the other services on8081–8083.
Make sure each service is started with the correct SERVER_PORT (via properties or env) if you run them outside Docker.
.env.examplecontains example overrides for ports, DB URLs, and secrets.- To customize, copy it to
.envand adjust values, then re‑rundocker compose.
Key environment variables (per service):
SERVER_PORT– HTTP port inside the container.SPRING_DATASOURCE_URL,SPRING_DATASOURCE_USERNAME,SPRING_DATASOURCE_PASSWORD– DB connection.AUTH_SERVICE_URL,CATALOGUE_SERVICE_URL,PAYMENT_SERVICE_URL– service‑to‑service URLs.SECURITY_JWT_SECRET,SECURITY_JWT_EXP_MIN– JWT configuration for auth/gateway.
- Data is persisted in the Postgres volumes (
pgdata-*) when running via Docker; stopping containers does not wipe data unless you remove the volumes. - When running with in‑memory H2 (non‑Docker), data is lost on restart.
- The payment service is intentionally simplified: it demonstrates the flow (including a “payment placeholder” and receipt page) but does not integrate with a real payment provider.
This README reflects the current microservice layout and auction behaviour after recent changes (validation, time‑zone handling, and updated bidding/Buy Now logic).