A full-stack bookstore system that packages a course-scale e-commerce idea into a runnable product surface: customer shopping flows, admin operations, session-based backend APIs, a MariaDB schema, and a documented path from basic CRUD to architecture-focused optimization.
This repository was consolidated from the original frontend, backend, and SQL branches into one public monorepo so the project reads as a complete engineering artifact instead of scattered coursework snapshots.
Most bookstore demos stop at a static catalog. This project covers the operational loop of a small online store:
- Customers can register, sign in, browse books, search by keyword, manage cart items, check out, and review order history.
- Admins can manage catalog records, upload covers, inspect orders, ban or unban users, and view sales or consumption rankings.
- The frontend is environment-driven, so it can target local, staging, or deployed APIs without source edits.
- The backend exposes a Spring Boot REST API with session-aware route protection and JPA-backed domain models.
- The database folder provides a MariaDB-compatible schema and seed dataset aligned with the backend entities.
- The docs now preserve the broader architecture work behind the project without publishing private course material.
.
├── frontend/ React + Vite + Ant Design storefront and admin console
├── backend/ Spring Boot REST API, JPA models, services, controllers
├── database/ MariaDB schema and local development seed data
├── docs/ API contract and integration notes
├── extensions/ Optional source excerpts for cache, events, GraphQL, MCP, and services
└── .github/ CI for frontend build and backend compilation
| Area | Capability |
|---|---|
| Authentication | Register, login, logout, session-backed route protection |
| Storefront | Book browsing, keyword search, detail modal, cover fallback |
| Cart | Add-to-cart, quantity updates, deletion, checkout payload assembly |
| Orders | User order history, admin order list, date-range and keyword filtering |
| Profile | Profile editing, password update, avatar upload |
| Admin catalog | Create, edit, delete, paginate, search, and upload covers |
| Admin users | User search, admin privilege checks, ban/unban workflow |
| Analytics | Book sales ranking and user consumption ranking over date ranges |
The public main branch is intentionally the stable bookstore baseline. The
project also carries a sanitized architecture roadmap distilled from the
optimization work behind the same domain:
| Track | Value |
|---|---|
| Transaction and messaging | Defines how checkout can evolve from synchronous writes to event-backed status updates. |
| WebSocket and concurrency | Gives a path for user-scoped order notifications without exposing broker details to the browser. |
| Redis caching | Identifies safe cache candidates and write-after-invalidate rules for catalog reads. |
| Microservice extraction | Shows which seams are credible to split first, while keeping the monolith runnable. |
| MySQL performance | Adds concrete schema indexes for catalog, cart, order history, and ranking queries. |
| Polyglot data extensions | Frames MongoDB, Neo4j, vector search, time-series data, and Hadoop analytics as optional adapters. |
Read docs/architecture-evolution.md and docs/performance-and-data-strategy.md for the detailed, open-source-safe version.
Selected source excerpts from those experiments live in extensions/. They are published as optional reference implementations, not as dependencies of the default local startup path.
React/Vite UI
|
| cookie-capable JSON requests under /api
v
Spring Boot REST API
|
| JPA repositories and service-layer workflows
v
MariaDB schema
The API base is controlled by frontend/.env:
VITE_API_BASE_URL=http://localhost:8080The backend reads database and CORS configuration from environment variables, so no private hostnames or passwords are committed.
Clone the project:
git clone https://github.com/Aspirin0000/ebook.git
cd ebookInitialize the local database:
mysql -u root -p < database/schema.sqlStart the backend:
cd backend
export DB_USERNAME=root
export DB_PASSWORD=your_local_password
./mvnw spring-boot:runStart the frontend in another terminal:
cd frontend
npm install
cp .env.example .env
npm run devOpen the Vite URL printed in the terminal. The seed administrator is documented in database/README.md.
| Variable | Default |
|---|---|
SERVER_PORT |
8080 |
DB_URL |
jdbc:mariadb://localhost:3306/online_bookstore?useSSL=false&serverTimezone=Asia/Shanghai |
DB_USERNAME |
root |
DB_PASSWORD |
empty |
CORS_ALLOWED_ORIGINS |
http://localhost:5173,http://localhost:3000 |
JPA_DDL_AUTO |
update |
JPA_SHOW_SQL |
true |
| Domain | Representative endpoints |
|---|---|
| Auth | POST /api/auth/login, PUT /api/auth/logout |
| User | POST /api/user/register, `GET |
| Books | GET /api/books/all, GET /api/books/{id}, POST /api/books/create, PUT /api/books/edit/{id}, POST /api/books/{id}/cover, DELETE /api/books/delete/{id} |
| Cart | `GET |
| Orders | `GET |
| Rankings | GET /api/books/rank, GET /api/user/rank |
See docs/api-contract.md and backend/README.md for more implementation notes.
- The project now uses a single default branch with frontend, backend, and database assets together.
- Vite replaces Create React App to reduce dependency surface and speed up local builds.
- Backend configuration is environment-based; historical local database credentials were removed.
- The SQL schema is aligned to the current JPA entity names instead of preserving stale branch-only DDL.
- The schema includes explicit query-path indexes derived from the architecture optimization track.
- CI runs frontend dependency audit/build and backend compilation on every push to
main. - Private course exports, submitted archives, local virtual environments, and database state are ignored by default.
- Password handling remains intentionally simple for a course-scale demo. Treat the seed account as local-only and replace it before any shared deployment.
Frontend:
cd frontend
npm ci
npm audit --audit-level=high
npm run buildBackend:
cd backend
./mvnw -DskipTests package- Add a Docker Compose profile for one-command MariaDB + backend + frontend startup.
- Add a mock API mode for frontend-only demos.
- Add integration tests around login, catalog CRUD, cart checkout, and admin rankings.
- Add Redis caching behind the catalog service with fail-open behavior.
- Add optional WebSocket order notifications after checkout transaction tests are in place.
- Replace plaintext demo password storage with hashed credentials before production-style deployment.
MIT. See LICENSE.