The Golden Book
A platform for selling new and antique books, with five applications on one shared Java core.
Highlights
- REST API documented with OpenAPI and Swagger UI, with per-client rate limiting and Redis caching.
- A Java middleware holds the business rules shared by the API, the web store and the desktop app.
- The SPA and the mobile app use a typed client generated from the OpenAPI specification.
The problem
A bookshop needs to sell on the web and on mobile, and also run the business from a desktop. If each application had its own rules, they would end up giving different results.
The solution
Business rules and data access live in a single Java library, the middleware. The REST API, the web store built with Servlets and JSP, and the Swing desktop app all depend on it. The React SPA and the mobile app consume the API.
Technical decisions
- Thin API: it validates input, applies rate limiting and caching, and delegates the logic to the middleware.
- Rate limiting with Bucket4j, in a JAX-RS filter that answers 429 when the limit is exceeded.
- Criteria-based search: the SQL is built from the filters and the results are paginated.
Current status
I am refactoring the whole project with Spring, which I am learning. This page describes the version published on GitHub. The mobile app is at an early stage: authentication and the home screen are in place.