Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

305 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Internet Engineering Course Projects

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)
  • CA2CA9: “MioBook” (bookstore) evolving from CLIREST backendfull-stackcontainerized / Kubernetes
  • Test/: a small Python script that smoke-tests the MioBook API

Repository layout

  • CA1/: Maven + Java 21, JSON-driven hotel booking model
  • CA2/MioBook/: Maven + Java 21, CLI app + static HTML pages
  • CA3/miobook/: Spring Boot REST API (in-memory repositories)
  • CA4/miobook/: Spring Boot API + React (React Router) frontend
  • CA5/miobook/: adds MySQL + Spring Data JPA persistence
  • CA6/miobook/: adds Redis-backed session/token storage
  • CA7/miobook/: adds JWT auth, password hashing, and Google OAuth flow (plus more backend hardening)
  • CA8/miobook/: splits into backend/ and frontend/, adds Dockerfiles + Docker Compose
  • CA9/miobook/: final packaging: Docker Compose + Kubernetes manifests + report

Prerequisites

Depending on which CA you run:

  • Java 21 (most pom.xml set <java.version>21</java.version>)
  • Maven (or use the included Maven Wrapper mvnw / mvnw.cmd in Spring Boot phases)
  • Node.js 20+ (frontend phases)
  • Docker + Docker Compose (CA8/CA9)
  • Python 3.x + requests (optional: Test/test.py)

Architecture (MioBook, CA3+)

At a high level the backend follows a layered design, with a consistent “command” style used across phases:

  1. Controllers (controllers/)
  • Define REST endpoints (Spring @RestController)
  • Deserialize request bodies into command DTOs (commands/)
  • Enforce access control via @Authenticated(...) (AOP aspect)
  1. 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)
  1. Services (services/)
  • Business logic for the domain: auth, users, books, authors, carts, purchases
  • Compose repository calls and enforce rules (roles, credit, ownership, etc.)
  1. Repositories (repositories/)
  • CA3–CA4: in-memory collections (e.g. List<Book>)
  • CA5+: Spring Data JPA repositories backed by MySQL
  1. Models / Responses
  • models/: domain entities (User, Book, Author, Cart, Purchase, Review, …)
  • responses/: response records wrapped by a consistent BaseResponse<T>

Auth & security evolution

  • 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.

API overview (MioBook, CA9)

Base URL is http://localhost:8080/api (see server.servlet.context-path=/api).

Common endpoints (roles enforced by @Authenticated):

  • Auth
    • POST /auth/login
    • POST /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}/reviews
    • POST /books/{title}/review (customer)
  • Cart (customer)
    • POST /cart/add
    • DELETE /cart/remove
    • POST /cart/borrow
    • POST /cart/purchase
    • GET /cart/list

How to run

CA9 (recommended): Docker Compose

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.properties or environment variables):
    • SPRING_DATASOURCE_URL, SPRING_DATASOURCE_USERNAME, SPRING_DATASOURCE_PASSWORD (or SPRING_DATASOURCE_PASSWORD_FILE)
    • jwt.secret
    • google.client.id, google.client.secret, google.redirect.uri (only needed for Google login)

CA9: Kubernetes manifests

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\

CA4–CA7: run backend + frontend locally

Backend (Spring Boot, default port 9090):

cd CA7\miobook
.\mvnw.cmd spring-boot:run

Frontend (React Router template, default port 5173):

cd CA7\miobook\frontend\MioBook
npm install
npm run dev

Notes:

  • 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:7

CA3: backend-only (in-memory)

cd CA3\miobook
.\mvnw.cmd spring-boot:run

Backend will be on http://localhost:9090/api.

CA2: CLI app + static HTML

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.

CA1: Hotel booking (JSON in/out)

cd CA1
mvn -q test

The 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"

Phase-by-phase summary (what each CA added)

  • CA1 — Hotel (Java fundamentals)

    • Basic domain model (Customer, Room, Booking, Hotel)
    • JSON import/export (data.json → state output)
  • 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/
  • 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)
  • 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/ and frontend/ subprojects
    • Dockerfiles + Docker Compose (+ secrets file pattern)
  • CA9 — Deployment (Kubernetes)

    • Kubernetes manifests for database/, backend/, frontend/
    • Final report under CA9/miobook/doc/Report.pdf

Quick test (CA9 backend)

After the backend is running on http://localhost:8080/api, you can run:

pip install requests
python .\Test\test.py

This script exercises signup/login, admin book/author creation, customer cart flow, purchases, and reviews.

About

MioBook is a course project that evolves into a full-stack online bookstore, with a Spring Boot REST backend and a React frontend, plus Docker/Kubernetes deployment in later phases.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages