How abdellah-belcaid/book-store-managment works
Purpose and topology
A two-project book-store management system: an Angular single-page application (SPA) consumes a Spring Boot REST backend. Core capabilities are JWT login, role-based access, book/author administration, user profiles, and purchase/order history. MySQL is the declared persistence service.
Runtime entry points
• Backend starts through Spring Boot at book-managment-back/src/main/java/com/bs/BookStoreApplication.java; Maven build/dependency boundary is book-managment-back/pom.xml.
• Frontend bootstraps Angular from book-managment-frent/src/main.ts, with root composition in book-managment-frent/src/app/app.module.ts.
• Runtime properties, including backend infrastructure settings, reside in book-managment-back/src/main/resources/application.properties; Angular environment endpoints are under book-managment-frent/src/environments.
Frontend navigation and UI domains
• Route composition and authorization-gated navigation are centered on book-managment-frent/src/app/app-routing.module.ts and book-managment-frent/src/app/guards/auth.guard.ts.
• Public flows cover home, login, and registration in book-managment-frent/src/app/guest.
• Authenticated user flows provide profile editing in book-managment-frent/src/app/user/profile/profile.component.ts.
• Administrative UI owns book and author CRUD in book-managment-frent/src/app/admin/book/book.component.ts and book-managment-frent/src/app/admin/author/author.component.ts.
• Angular Material is consolidated through book-managment-frent/src/app/app-material.module.ts.
Client-to-server boundary
Angular services encapsulate HTTP access and domain models; components should not directly define backend calls. The base request abstraction is book-managment-frent/src/app/services/request-base.service.ts; domain clients include book-managment-frent/src/app/services/book.service.ts, book-managment-frent/src/app/services/author.service.ts, and book-managment-frent/src/app/services/purchase.service.ts. Shared client contracts are represented by book-managment-frent/src/app/models/book.model.ts and related model files.
Authentication and authorization pipeline
Login/registration requests enter book-managment-back/src/main/java/com/bs/controller/AuthenticationController.java, then authentication service logic in book-managment-back/src/main/java/com/bs/service/impl/AuthenticationService.java issues JWTs via book-managment-back/src/main/java/com/bs/security/jwt/JwtProvider.java.
The frontend attaches JWTs through book-managment-frent/src/app/guards/jwt.interceptor.ts. Backend security configuration and request filtering are in book-managment-back/src/main/java/com/bs/security/SecurityConfiguration.java and book-managment-back/src/main/java/com/bs/security/jwt/JwtAuthorizationFilter.java; user identity loads through CustomUserDetailsService.
Backend domain and API layers
REST controllers form the external API boundary: BookController.java, AuthorController.java, UserController.java, and PurchaseHistoryController.java under book-managment-back/src/main/java/com/bs/controller. They delegate to interface-driven services and implementations, notably service/IBookService.java and service/impl/BookService.java. InternalApiController.java plus InternalApiAuthenticationFilter.java indicates a separately protected internal API path.
Persistence and business data flow
JPA-style models define the primary persisted graph: model/Book.java, model/Author.java, model/User.java, and model/PurchaseHistory.java. Services apply domain operations and call repositories such as repository/BookRepository.java, repository/AuthorRepository.java, and repository/IPurchaseHistoryRepository.java, which isolate MySQL access. Purchase-history projections (repository/projection/IPurchaseItem.java) provide a read-oriented purchase item boundary. User image/static content is stored beneath book-managment-back/src/main/resources/static/images/users.
Main entry points: SecurityConfiguration.java Security filter chain · app-routing.module.ts Routes and auth guard · request-base.service.ts HTTP domain clients · IBookService.java Domain services
Components 20
Angular SPA
- Angular bootstrap
book-managment-frent/src/main.ts - Root module
book-managment-frent/src/app/app.module.ts - Routes and auth guard
book-managment-frent/src/app/app-routing.module.ts - Public auth UI · Home, login, and registration flows.
book-managment-frent/src/app/guest - Profile UI
book-managment-frent/src/app/user/profile/profile.component.ts - Book and author admin UI
book-managment-frent/src/app/admin/book/book.component.ts - HTTP domain clients · Book, author, and purchase clients extend the request abstraction.
book-managment-frent/src/app/services/request-base.service.ts - JWT interceptor
book-managment-frent/src/app/guards/jwt.interceptor.ts
Spring Boot API
- Spring Boot application
book-managment-back/src/main/java/com/bs/BookStoreApplication.java - Security filter chain · Secures requests and resolves authenticated users.
book-managment-back/src/main/java/com/bs/security/SecurityConfiguration.java - JWT authorization filter
book-managment-back/src/main/java/com/bs/security/jwt/JwtAuthorizationFilter.java - Authentication API
book-managment-back/src/main/java/com/bs/controller/AuthenticationController.java - Authentication service · Authenticates users and issues JWTs.
book-managment-back/src/main/java/com/bs/service/impl/AuthenticationService.java - JWT provider
book-managment-back/src/main/java/com/bs/security/jwt/JwtProvider.java - Book, author, user and purchase APIs
book-managment-back/src/main/java/com/bs/controller - Domain services · Interface-driven business operations.
book-managment-back/src/main/java/com/bs/service/IBookService.java
Persistence
- JPA repositories · Repositories isolate database access and purchase projections.
book-managment-back/src/main/java/com/bs/repository - Bookstore entities · Books, authors, users, and purchase history.
book-managment-back/src/main/java/com/bs/model/Book.java - MySQL
- User images
book-managment-back/src/main/resources/static/images/users
Connections 21
- Angular bootstrap → Root module: starts
- Root module → Routes and auth guard: composes
- Routes and auth guard → Public auth UI: routes public users
- Routes and auth guard → Profile UI: guards
- Routes and auth guard → Book and author admin UI: guards by role
- Public auth UI → HTTP domain clients: uses
- Profile UI → HTTP domain clients: uses
- Book and author admin UI → HTTP domain clients: uses
- HTTP domain clients → JWT interceptor: HTTP requests
- JWT interceptor → Security filter chain: JWT-authenticated REST
- Security filter chain → JWT authorization filter: applies
- Security filter chain → Authentication API: permits auth flow
- Security filter chain → Book, author, user and purchase APIs: authorizes
- Authentication API → Authentication service: delegates
- Authentication service → JWT provider: issues token
- Book, author, user and purchase APIs → Domain services: delegates
- Domain services → JPA repositories: reads and writes
- JPA repositories → Bookstore entities: maps
- JPA repositories → MySQL: persists
- Domain services → User images: serves user content
- Spring Boot application → Security filter chain: boots