# abdellah-belcaid/book-store-managment architecture

> Architecture diagram of the GitHub repository abdellah-belcaid/book-store-managment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdellah-belcaid/book-store-managment
- Repository: https://github.com/abdellah-belcaid/book-store-managment

## Overview

#### 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: [`book-managment-back/src/main/java/com/bs/security/SecurityConfiguration.java`](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/security/SecurityConfiguration.java) (Security filter chain), [`book-managment-frent/src/app/app-routing.module.ts`](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/app-routing.module.ts) (Routes and auth guard), [`book-managment-frent/src/app/services/request-base.service.ts`](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/services/request-base.service.ts) (HTTP domain clients), [`book-managment-back/src/main/java/com/bs/service/IBookService.java`](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/service/IBookService.java) (Domain services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Angular SPA"]
  node_ng_bootstrap{{"Angular bootstrap<br/>runtime entry<br/>[main.ts]"}}
  node_ng_root["Root module<br/>Angular composition<br/>[app.module.ts]"]
  node_ng_routes["Routes and auth guard<br/>navigation"]
  node_ng_public["Public auth UI<br/>Angular feature"]
  node_ng_profile["Profile UI<br/>Angular feature"]
  node_ng_admin["Book and author admin UI<br/>Angular feature<br/>[book.component.ts]"]
  node_ng_clients["HTTP domain clients<br/>Angular services"]
  node_ng_jwt["JWT interceptor<br/>HTTP security<br/>[jwt.interceptor.ts]"]
end

subgraph group_backend["Spring Boot API"]
  node_app{{"Spring Boot application<br/>runtime entry"}}
  node_security["Security filter chain<br/>Spring Security"]
  node_jwt_filter["JWT authorization filter<br/>request filter"]
  node_auth_api["Authentication API<br/>REST controller"]
  node_auth_service["Authentication service"]
  node_jwt_provider["JWT provider<br/>token service<br/>[JwtProvider.java]"]
  node_domain_api["Book, author, user and purchase APIs<br/>REST controllers"]
  node_domain_services["Domain services<br/>service layer<br/>[IBookService.java]"]
end

subgraph group_data["Persistence"]
  node_repositories["JPA repositories<br/>data access"]
  node_models["Bookstore entities<br/>JPA models<br/>[Book.java]"]
  node_mysql[("MySQL<br/>database")]
  node_user_images["User images<br/>static storage"]
end

node_ng_bootstrap -->|"starts"| node_ng_root
node_ng_root -->|"composes"| node_ng_routes
node_ng_routes -->|"routes public users"| node_ng_public
node_ng_routes -->|"guards"| node_ng_profile
node_ng_routes -->|"guards by role"| node_ng_admin
node_ng_public -->|"uses"| node_ng_clients
node_ng_profile -->|"uses"| node_ng_clients
node_ng_admin -->|"uses"| node_ng_clients
node_ng_clients -->|"HTTP requests"| node_ng_jwt
node_ng_jwt -->|"JWT-authenticated REST"| node_security
node_security -->|"applies"| node_jwt_filter
node_security -->|"permits auth flow"| node_auth_api
node_security -->|"authorizes"| node_domain_api
node_auth_api -->|"delegates"| node_auth_service
node_auth_service -->|"issues token"| node_jwt_provider
node_domain_api -->|"delegates"| node_domain_services
node_domain_services -->|"reads and writes"| node_repositories
node_repositories -->|"maps"| node_models
node_repositories -->|"persists"| node_mysql
node_domain_services -.->|"serves user content"| node_user_images
node_app -->|"boots"| node_security

click node_ng_bootstrap "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/main.ts"
click node_ng_root "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/app.module.ts"
click node_ng_routes "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/app-routing.module.ts"
click node_ng_public "https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-frent/src/app/guest"
click node_ng_profile "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/user/profile/profile.component.ts"
click node_ng_admin "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/admin/book/book.component.ts"
click node_ng_clients "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/services/request-base.service.ts"
click node_ng_jwt "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/guards/jwt.interceptor.ts"
click node_app "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/BookStoreApplication.java"
click node_security "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/security/SecurityConfiguration.java"
click node_jwt_filter "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/security/jwt/JwtAuthorizationFilter.java"
click node_auth_api "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/controller/AuthenticationController.java"
click node_auth_service "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/service/impl/AuthenticationService.java"
click node_jwt_provider "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/security/jwt/JwtProvider.java"
click node_domain_api "https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-back/src/main/java/com/bs/controller"
click node_domain_services "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/service/IBookService.java"
click node_repositories "https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-back/src/main/java/com/bs/repository"
click node_models "https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/model/Book.java"
click node_user_images "https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-back/src/main/resources/static/images/users"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ng_bootstrap,node_ng_root,node_ng_routes,node_ng_public,node_ng_profile,node_ng_admin,node_ng_clients,node_ng_jwt toneBlue
class node_app,node_security,node_jwt_filter,node_auth_api,node_auth_service,node_jwt_provider,node_domain_api,node_domain_services toneAmber
class node_repositories,node_models,node_mysql,node_user_images toneMint
```

## Components

### Angular SPA

- [Angular bootstrap](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/main.ts): runtime entry · `book-managment-frent/src/main.ts`
- [Root module](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/app.module.ts): Angular composition · `book-managment-frent/src/app/app.module.ts`
- [Routes and auth guard](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/app-routing.module.ts): navigation · `book-managment-frent/src/app/app-routing.module.ts`
- [Public auth UI](https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-frent/src/app/guest): Angular feature · Home, login, and registration flows. · `book-managment-frent/src/app/guest`
- [Profile UI](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/user/profile/profile.component.ts): Angular feature · `book-managment-frent/src/app/user/profile/profile.component.ts`
- [Book and author admin UI](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/admin/book/book.component.ts): Angular feature · `book-managment-frent/src/app/admin/book/book.component.ts`
- [HTTP domain clients](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/services/request-base.service.ts): Angular services · Book, author, and purchase clients extend the request abstraction. · `book-managment-frent/src/app/services/request-base.service.ts`
- [JWT interceptor](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-frent/src/app/guards/jwt.interceptor.ts): HTTP security · `book-managment-frent/src/app/guards/jwt.interceptor.ts`

### Spring Boot API

- [Spring Boot application](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/BookStoreApplication.java): runtime entry · `book-managment-back/src/main/java/com/bs/BookStoreApplication.java`
- [Security filter chain](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/security/SecurityConfiguration.java): Spring Security · Secures requests and resolves authenticated users. · `book-managment-back/src/main/java/com/bs/security/SecurityConfiguration.java`
- [JWT authorization filter](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/security/jwt/JwtAuthorizationFilter.java): request filter · `book-managment-back/src/main/java/com/bs/security/jwt/JwtAuthorizationFilter.java`
- [Authentication API](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/controller/AuthenticationController.java): REST controller · `book-managment-back/src/main/java/com/bs/controller/AuthenticationController.java`
- [Authentication service](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/service/impl/AuthenticationService.java): service · Authenticates users and issues JWTs. · `book-managment-back/src/main/java/com/bs/service/impl/AuthenticationService.java`
- [JWT provider](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/security/jwt/JwtProvider.java): token service · `book-managment-back/src/main/java/com/bs/security/jwt/JwtProvider.java`
- [Book, author, user and purchase APIs](https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-back/src/main/java/com/bs/controller): REST controllers · `book-managment-back/src/main/java/com/bs/controller`
- [Domain services](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/service/IBookService.java): service layer · Interface-driven business operations. · `book-managment-back/src/main/java/com/bs/service/IBookService.java`

### Persistence

- [JPA repositories](https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-back/src/main/java/com/bs/repository): data access · Repositories isolate database access and purchase projections. · `book-managment-back/src/main/java/com/bs/repository`
- [Bookstore entities](https://github.com/abdellah-belcaid/book-store-managment/blob/main/book-managment-back/src/main/java/com/bs/model/Book.java): JPA models · Books, authors, users, and purchase history. · `book-managment-back/src/main/java/com/bs/model/Book.java`
- **MySQL**: database
- [User images](https://github.com/abdellah-belcaid/book-store-managment/tree/main/book-managment-back/src/main/resources/static/images/users): static storage · `book-managment-back/src/main/resources/static/images/users`

## Connections

- 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
