This repository is organized as a set of course phases (CAs). Each CA# folder is a snapshot of the project at that phase, not a single evolving codebase.
CA1: standalone Java (Hotel booking)CA2→CA9: “MioBook” (bookstore) evolving from CLI → REST backend → full-stack → containerized / KubernetesTest/: a small Python script that smoke-tests the MioBook API
CA1/: Maven + Java 21, JSON-driven hotel booking modelCA2/MioBook/: Maven + Java 21, CLI app + static HTML pagesCA3/miobook/: Spring Boot REST API (in-memory repositories)CA4/miobook/: Spring Boot API + React (React Router) frontendCA5/miobook/: adds MySQL + Spring Data JPA persistenceCA6/miobook/: adds Redis-backed session/token storageCA7/miobook/: adds JWT auth, password hashing, and Google OAuth flow (plus more backend hardening)CA8/miobook/: splits intobackend/andfrontend/, adds Dockerfiles + Docker ComposeCA9/miobook/: final packaging: Docker Compose + Kubernetes manifests + report
Depending on which CA you run:
- Java
21(mostpom.xmlset<java.version>21</java.version>) - Maven (or use the included Maven Wrapper
mvnw/mvnw.cmdin Spring Boot phases) - Node.js
20+(frontend phases) - Docker + Docker Compose (CA8/CA9)
- Python
3.x+requests(optional:Test/test.py)
At a high level the backend follows a layered design, with a consistent “command” style used across phases:
- Controllers (
controllers/)
- Define REST endpoints (Spring
@RestController) - Deserialize request bodies into command DTOs (
commands/) - Enforce access control via
@Authenticated(...)(AOP aspect)
- Commands (
commands/)
- Represent one use-case (e.g.
AddBook,Login,PurchaseCart) - Validate input (Jakarta Validation + custom
JsonValidator) - Call into the relevant service via
command.execute(service)
- Services (
services/)
- Business logic for the domain: auth, users, books, authors, carts, purchases
- Compose repository calls and enforce rules (roles, credit, ownership, etc.)
- Repositories (
repositories/)
- CA3–CA4: in-memory collections (e.g.
List<Book>) - CA5+: Spring Data JPA repositories backed by MySQL
- Models / Responses
models/: domain entities (User, Book, Author, Cart, Purchase, Review, …)responses/: response records wrapped by a consistentBaseResponse<T>
- CA6: random bearer token stored in Redis (
session:<token> → username/role) - CA7–CA9: stateless JWT bearer token (
username,role, … claims) validated by an AOP aspect - Password hashing uses Apache Shiro (
Sha256Hash+ random salt) in later phases.
Base URL is http://localhost:8080/api (see server.servlet.context-path=/api).
Common endpoints (roles enforced by @Authenticated):
- Auth
POST /auth/loginPOST /auth/logout(customer/admin)GET /auth/user(customer/admin)GET /auth/google/callback?code=...
- Users
POST /user(signup)GET /users/{username}POST /credit(customer)GET /purchase-history(customer)GET /purchased-books(customer)
- Authors (admin-only for management)
POST /author(admin)GET /authors(admin)GET /authors/{name}
- Books
POST /book(admin)GET /get-books(admin)GET /books(search with query params)GET /books/{title}GET /books/{title}/content(customer)GET /books/{title}/reviewsPOST /books/{title}/review(customer)
- Cart (customer)
POST /cart/addDELETE /cart/removePOST /cart/borrowPOST /cart/purchaseGET /cart/list
Prereqs: Docker Desktop (or Docker Engine) with Compose.
cd CA9\miobook
docker compose up --build- Frontend:
http://localhost:5173 - Backend:
http://localhost:8080/api
Configuration notes:
- Compose expects a DB password secret file at
CA9/miobook/secrets/db_password.txt. - The repo contains example secrets/config values for coursework; treat them as placeholders and rotate/remove them for any real deployment.
- Useful backend config knobs (via
application.propertiesor environment variables):SPRING_DATASOURCE_URL,SPRING_DATASOURCE_USERNAME,SPRING_DATASOURCE_PASSWORD(orSPRING_DATASOURCE_PASSWORD_FILE)jwt.secretgoogle.client.id,google.client.secret,google.redirect.uri(only needed for Google login)
Manifests live in CA9/miobook/kubernetes/ (see CA9/miobook/kubernetes/apply.txt for the apply order).
cd CA9\miobook\kubernetes
kubectl apply -f .\database\
kubectl apply -f .\backend\
kubectl apply -f .\frontend\Backend (Spring Boot, default port 9090):
cd CA7\miobook
.\mvnw.cmd spring-boot:runFrontend (React Router template, default port 5173):
cd CA7\miobook\frontend\MioBook
npm install
npm run devNotes:
- In these phases, some frontend code calls
http://localhost:9090/api/...directly (not via a proxy). - CA5–CA7 require a running MySQL instance; CA6 additionally requires Redis (see the CA’s
application.properties).
Quick local dependencies (optional, using Docker):
# MySQL (for CA5–CA7)
docker run --name miobook-mysql -e MYSQL_ROOT_PASSWORD="<password>" -e MYSQL_DATABASE=miobook -p 3306:3306 -d mysql:8
# Redis (for CA6)
docker run --name miobook-redis -p 6379:6379 -d redis:7cd CA3\miobook
.\mvnw.cmd spring-boot:runBackend will be on http://localhost:9090/api.
CLI:
cd CA2\MioBook
mvn -q org.codehaus.mojo:exec-maven-plugin:3.1.0:java -Dexec.mainClass="org.miobook.Main"Static pages:
- Open files under
CA2/MioBook/frontend/pages/in a browser.
cd CA1
mvn -q testThe entry point is org.example.Main (reads CA1/data.json, writes CA1/state.json).
To run the program from the command line:
cd CA1
mvn -q org.codehaus.mojo:exec-maven-plugin:3.1.0:java -Dexec.mainClass="org.example.Main"-
CA1 — Hotel (Java fundamentals)
- Basic domain model (
Customer,Room,Booking,Hotel) - JSON import/export (
data.json→ state output)
- Basic domain model (
-
CA2 — MioBook v0 (CLI + validation)
- CLI command processor (
cli/,commands/) - Domain model for bookstore (users, authors, books, carts, purchases, reviews)
- Input validation helpers (
infrastructure/JsonValidator, custom deserializers) - Static HTML pages scaffold under
frontend/
- CLI command processor (
-
CA3 — MioBook REST API (Spring Boot)
- Spring Boot backend with controllers/services/responses
- In-memory repositories (lists) to keep the focus on API + logic
-
CA4 — Full-stack (adds React frontend + backend hardening)
- Frontend app under
frontend/MioBook - Backend “production shape” improvements (exception types, config package, response envelope)
- Frontend app under
-
CA5 — Persistence
- MySQL + Spring Data JPA repositories
- Entities persisted instead of in-memory collections
-
CA6 — Redis sessions
- Token/session storage in Redis (bearer token → session hash)
- Authentication aspect consults Redis for role/identity
-
CA7 — JWT + stronger auth
- JWT-based auth with role enforcement at the API boundary
- Password hashing (salted) and Google OAuth callback flow
-
CA8 — Containerization
- Split
backend/andfrontend/subprojects - Dockerfiles + Docker Compose (+ secrets file pattern)
- Split
-
CA9 — Deployment (Kubernetes)
- Kubernetes manifests for
database/,backend/,frontend/ - Final report under
CA9/miobook/doc/Report.pdf
- Kubernetes manifests for
After the backend is running on http://localhost:8080/api, you can run:
pip install requests
python .\Test\test.pyThis script exercises signup/login, admin book/author creation, customer cart flow, purchases, and reviews.