# arun9123/capgemini_sprint_bookstore architecture

> Architecture diagram of the GitHub repository arun9123/capgemini_sprint_bookstore, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arun9123/capgemini_sprint_bookstore
- Repository: https://github.com/arun9123/capgemini_sprint_bookstore

## Overview

This repository is split into two separate Spring Boot applications: a backend API in `BookStore/` and a server-rendered UI in `BookStore-UI/`. The backend owns the domain model, persistence, and REST endpoints; the UI is a thin client that renders pages and calls the backend over HTTP.

1. **Backend core is a layered REST service**
   - `com.capgemini.BookStore` contains `controllers`, `service`/`service.impl`, `repository`, `model`, `dto`, and `exception`.
   - Request flow is conventional: controller → service → repository → database, with DTOs used to shape API responses and inputs.

2. **Domain model centers on bookstore entities**
   - The main persisted entities are `Book`, `Author`, `Category`, `Publisher`, `State`, `Reviewer`, `Inventory`, `BookCondition`, `BookReview`, `PermRole`, `User`, `PurchaseLog`, and `ShoppingCart`.
   - The README’s class diagram matches the backend model and shows the key relationships, including book-category, book-publisher, publisher-state, book-author, book-review, inventory-book-condition, user-role, and purchase/cart associations.

3. **Join entities and composite IDs matter**
   - Several many-to-many or transaction-style relationships are modeled explicitly with composite IDs: `BookAuthor`, `BookReview`, `PurchaseLog`, and `ShoppingCart`.
   - These are important architecture boundaries because they represent link tables and business events rather than simple master data.

4. **Service layer encapsulates business rules**
   - Each domain area has a dedicated service interface and implementation pair, such as `BookServiceImpl`, `InventoryServiceImpl`, `PurchaseLogServiceImpl`, and `ShoppingCartServiceImpl`.
   - Exceptions like `DuplicateResourceException`, `ResourceNotFoundException`, and `InventoryNotAvailableException` indicate business-rule enforcement in the service layer, not just CRUD passthrough.

5. **Persistence is repository-driven**
   - Repositories such as `BookRepo`, `AuthorRepo`, `InventoryRepo`, `UserRepo`, and others suggest Spring Data JPA-style persistence.
   - The `model/id` package shows explicit composite key classes, which is a strong indicator that the database schema includes join tables and composite primary keys.

6. **DTOs are used heavily for API contracts**
   - The backend has a large `dto` package with many specialized response shapes like `BookWithAuthorsDTO`, `BookWithInventoryDTO`, `PublisherRatingDTO`, `CategoryReviewCountDTO`, and `ReviewerRatingDTO`.
   - This means controllers likely do not expose entities directly for most endpoints; instead they project domain data into use-case-specific payloads.

7. **Controllers are organized by business capability**
   - There are separate controllers for authors, books, book-author links, book conditions, reviews, categories, inventory, publishers, purchase logs, reviewers, shopping carts, states, users, roles, and health checks.
   - This suggests a resource-oriented API surface rather than a single monolithic endpoint layer.

8. **Cross-cutting backend configuration is limited but important**
   - `CorsConfig` and `MapperConfig` indicate frontend/backend cross-origin access and object mapping configuration.
   - Multiple environment files (`application-dev.properties`, `application-prod.properties`, `application-remote.properties`, and test properties) show the backend is deployed in different runtime profiles.

9. **UI is a separate Spring Boot web app**
   - `BookStore-UI` has its own `pom.xml`, boot application class, controller, config, model, registry, and `templates`/`static` folders.
   - It is likely a Thymeleaf-based server-side rendered app, since HTML templates are present and there is no SPA framework in the tree.

10. **UI acts as a client to the backend API**
   - `ApiClient` is the key integration point: UI controllers send requests to backend endpoints and then render the returned data.
   - `ApiEndpoint`, `Member`, and `MemberRegistry` suggest the UI also maintains a small local model/registry for browsing available APIs or sample members.

11. **UI page flow is presentation-first**
   - Templates such as `members.html`, `member-apis.html`, `api-input.html`, and `api-result.html` indicate the UI is meant for interactive API exploration or admin-style browsing rather than full domain editing.
   - Static assets are minimal, with CSS and images supporting the rendered pages.

12. **Testing is broad and mirrors the backend structure**
   - The backend includes controller, service, and integration tests for nearly every major domain area.
   - This is useful architecturally because it confirms the primary boundaries: controller tests for HTTP behavior, service tests for business logic, and integration tests for end-to-end persistence/API behavior.

13. **Operational entry points**
   - Both applications have their own main Spring Boot entry classes: `BookStoreApplication` and `BookStoreUiApplication`.
   - Postman resources and globals in `.postman/` and `postman/` support direct API validation against the backend, independent of the UI.

For an architecture diagram, the most important flow is: browser → UI Spring MVC controller → API client → backend REST controller → service layer → repository/JPA → database, with DTOs and exceptions shaping the contract between layers.

Main entry points: [`BookStore/src/main/java/com/capgemini/BookStore/controllers/BookController.java`](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/controllers/BookController.java) (REST controllers), [`BookStore/src/main/java/com/capgemini/BookStore/service/BookService.java`](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/service/BookService.java) (Services), [`BookStore-UI/src/main/java/com/capgemini/BookStoreUI/controller/TeamController.java`](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/controller/TeamController.java) (Page controller), [`BookStore/src/main/java/com/capgemini/BookStore/repository/BookRepo.java`](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/repository/BookRepo.java) (Repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend API"]
  node_backend_app(("API app<br/>Spring Boot entrypoint"))
  node_backend_config["Config<br/>[CorsConfig.java]"]
  node_backend_controllers["REST controllers<br/>HTTP API layer"]
  node_backend_services["Services<br/>business layer<br/>[BookService.java]"]
  node_backend_repos["Repositories<br/>JPA persistence<br/>[BookRepo.java]"]
  node_backend_models[("Domain model<br/>entities + ids<br/>[Book.java]")]
  node_backend_dtos["DTOs<br/>API contracts<br/>[BookDTO.java]"]
  node_backend_exceptions["Exceptions<br/>error handling"]
  node_backend_db[("Database<br/>persistence store")]
  node_postman["Postman assets<br/>API validation"]
end

subgraph group_ui["UI App"]
  node_ui_app(("UI app<br/>Spring Boot entrypoint"))
  node_ui_controller["Page controller<br/>MVC controller"]
  node_ui_client["API client<br/>HTTP client<br/>[ApiClient.java]"]
  node_ui_templates["Templates<br/>server views<br/>[members.html]"]
  node_ui_model["UI model<br/>view model<br/>[ApiEndpoint.java]"]
  node_ui_registry["Registry<br/>lookup state"]
  node_ui_config["UI config<br/>app config<br/>[AppConfig.java]"]
  node_ui_static["Static assets<br/>css/images<br/>[style.css]"]
end

node_backend_app -->|"starts"| node_backend_controllers
node_backend_controllers -->|"delegates"| node_backend_services
node_backend_services -->|"queries"| node_backend_repos
node_backend_repos -->|"maps"| node_backend_models
node_backend_repos -->|"stores"| node_backend_db
node_backend_services -->|"projects"| node_backend_dtos
node_backend_controllers -->|"accepts/returns"| node_backend_dtos
node_backend_services -->|"raises"| node_backend_exceptions
node_backend_exceptions -->|"maps errors"| node_backend_controllers
node_backend_config -->|"enables"| node_backend_controllers
node_ui_app -->|"starts"| node_ui_controller
node_ui_controller -->|"calls"| node_ui_client
node_ui_controller -->|"renders"| node_ui_templates
node_ui_client -->|"HTTP API"| node_backend_controllers
node_ui_controller -->|"uses"| node_ui_model
node_ui_model -->|"catalogs"| node_ui_registry
node_ui_config -->|"configures"| node_ui_client
node_ui_templates -->|"styled by"| node_ui_static
node_postman -.->|"validates"| node_backend_controllers

click node_backend_app "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/BookStoreApplication.java"
click node_backend_config "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/config/CorsConfig.java"
click node_backend_controllers "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/controllers/BookController.java"
click node_backend_services "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/service/BookService.java"
click node_backend_repos "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/repository/BookRepo.java"
click node_backend_models "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/model/Book.java"
click node_backend_dtos "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/dto/BookDTO.java"
click node_backend_exceptions "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/exception/GlobalExceptionHandler.java"
click node_ui_app "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/BookStoreUiApplication.java"
click node_ui_controller "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/controller/TeamController.java"
click node_ui_client "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/client/ApiClient.java"
click node_ui_templates "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/resources/templates/members.html"
click node_ui_model "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/model/ApiEndpoint.java"
click node_ui_registry "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/registry/MemberRegistry.java"
click node_ui_config "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/config/AppConfig.java"
click node_ui_static "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/resources/static/css/style.css"
click node_postman "https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/postman/globals/workspace.globals.yaml"

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_backend_app,node_backend_config,node_backend_controllers,node_backend_services,node_backend_repos,node_backend_models,node_backend_dtos,node_backend_exceptions,node_backend_db,node_postman toneBlue
class node_ui_app,node_ui_controller,node_ui_client,node_ui_templates,node_ui_model,node_ui_registry,node_ui_config,node_ui_static toneAmber
```

## Components

### Backend API

Spring Boot REST service owning bookstore domain, persistence, and API contracts.

- [API app](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/BookStoreApplication.java): Spring Boot entrypoint · Bootstraps the backend application. · `BookStore/src/main/java/com/capgemini/BookStore/BookStoreApplication.java`
- [Config](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/config/CorsConfig.java): cross-cutting config · CORS and object-mapping configuration for the backend. · `BookStore/src/main/java/com/capgemini/BookStore/config/CorsConfig.java`
- [REST controllers](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/controllers/BookController.java): HTTP API layer · Resource-oriented endpoints for books, authors, inventory, reviews, carts, users, and health. · `BookStore/src/main/java/com/capgemini/BookStore/controllers/BookController.java`
- [Services](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/service/BookService.java): business layer · Domain services and implementations that enforce business rules and orchestration. · `BookStore/src/main/java/com/capgemini/BookStore/service/BookService.java`
- [Repositories](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/repository/BookRepo.java): JPA persistence · Spring Data repositories for bookstore entities and link tables. · `BookStore/src/main/java/com/capgemini/BookStore/repository/BookRepo.java`
- [Domain model](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/model/Book.java): entities + ids · Persisted bookstore entities plus composite ID classes for join and transaction records. · `BookStore/src/main/java/com/capgemini/BookStore/model/Book.java`
- [DTOs](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/dto/BookDTO.java): API contracts · Specialized request/response shapes used to project domain data for APIs. · `BookStore/src/main/java/com/capgemini/BookStore/dto/BookDTO.java`
- [Exceptions](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore/src/main/java/com/capgemini/BookStore/exception/GlobalExceptionHandler.java): error handling · Domain and API error types plus global exception mapping. · `BookStore/src/main/java/com/capgemini/BookStore/exception/GlobalExceptionHandler.java`
- **Database**: persistence store · Relational backing store accessed through JPA repositories.
- [Postman assets](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/postman/globals/workspace.globals.yaml): API validation · Shared Postman resources and globals for direct backend testing. · `postman/globals/workspace.globals.yaml`

### UI App

Separate Spring Boot server-rendered frontend that calls the backend over HTTP.

- [UI app](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/BookStoreUiApplication.java): Spring Boot entrypoint · Bootstraps the server-rendered frontend application. · `BookStore-UI/src/main/java/com/capgemini/BookStoreUI/BookStoreUiApplication.java`
- [Page controller](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/controller/TeamController.java): MVC controller · Drives browser-facing page flow for member and API browsing. · `BookStore-UI/src/main/java/com/capgemini/BookStoreUI/controller/TeamController.java`
- [API client](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/client/ApiClient.java): HTTP client · Calls backend REST endpoints and passes results back to the UI layer. · `BookStore-UI/src/main/java/com/capgemini/BookStoreUI/client/ApiClient.java`
- [Templates](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/resources/templates/members.html): server views · Thymeleaf-style HTML pages for browsing members, APIs, and results. · `BookStore-UI/src/main/resources/templates/members.html`
- [UI model](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/model/ApiEndpoint.java): view model · Local UI data structures for endpoints and members. · `BookStore-UI/src/main/java/com/capgemini/BookStoreUI/model/ApiEndpoint.java`
- [Registry](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/registry/MemberRegistry.java): lookup state · Holds available members and API metadata for page rendering. · `BookStore-UI/src/main/java/com/capgemini/BookStoreUI/registry/MemberRegistry.java`
- [UI config](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/java/com/capgemini/BookStoreUI/config/AppConfig.java): app config · Frontend-specific application configuration. · `BookStore-UI/src/main/java/com/capgemini/BookStoreUI/config/AppConfig.java`
- [Static assets](https://github.com/arun9123/capgemini_sprint_bookstore/blob/main/BookStore-UI/src/main/resources/static/css/style.css): css/images · Minimal CSS and images used by the rendered pages. · `BookStore-UI/src/main/resources/static/css/style.css`

## Connections

- API app → REST controllers: starts · Application exposes REST endpoints through controllers.
- REST controllers → Services: delegates · Controllers hand off request handling to services.
- Services → Repositories: queries · Services use repositories for persistence operations.
- Repositories → Domain model: maps · Repositories persist entity and composite-key models.
- Repositories → Database: stores · JPA repositories read and write the database.
- Services → DTOs: projects · Services shape responses through DTOs.
- REST controllers → DTOs: accepts/returns · HTTP layer uses DTOs for API contracts.
- Services → Exceptions: raises · Business rules surface as domain exceptions.
- Exceptions → REST controllers: maps errors · Global handler turns exceptions into API responses.
- Config → REST controllers: enables · Cross-origin and mapping configuration support the API layer.
- UI app → Page controller: starts · UI bootstraps its MVC controllers.
- Page controller → API client: calls · Page controllers invoke the backend API client.
- Page controller → Templates: renders · Controllers select server-side templates.
- API client → REST controllers: HTTP API · UI talks to the backend REST layer over HTTP.
- Page controller → UI model: uses · Controllers populate local view models.
- UI model → Registry: catalogs · Registry organizes the available members and API metadata.
- UI config → API client: configures · UI app wiring supports backend client usage.
- Templates → Static assets: styled by · Templates are paired with minimal static assets.
- Postman assets → REST controllers: validates · Postman resources exercise backend endpoints directly.
