# bhavesh27/ecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/bhavesh27/ecommerce
- Repository: https://github.com/bhavesh27/ecommerce

## Overview

#### Purpose and Deployment

This is a server-rendered Java e-commerce application for books/e-books. It is packaged as a Maven web application and deployed to Tomcat (JDK 8/Maven 3 expected). Browser requests are handled by Spring MVC and rendered as JSP pages; persistence uses Hibernate/JPA with an HSQLDB-oriented configuration per the README.

Key deployment/build boundary: `ECommerce/pom.xml`, `ECommerce/src/main/webapp/web.xml`.

#### Bootstrap and Framework Configuration

Servlet application startup is Java-config driven. Spring MVC initialization, security initialization, root/web contexts, Hibernate setup, and checkout flow wiring are concentrated in:

- `ECommerce/src/main/java/com/example/configuration/SpringMvcInitializer.java`
- `ECommerce/src/main/java/com/example/configuration/SecurityWebApplicationInitializer.java`
- `ECommerce/src/main/java/com/example/configuration/HibernateConfiguration.java`
- `ECommerce/src/main/java/com/example/configuration/SecurityConfiguration.java`
- `ECommerce/src/main/java/com/example/configuration/WebFlowConfig.java`

These form the main infrastructure boundary: HTTP dispatch, authentication/authorization, ORM/session/transaction access, and stateful checkout-flow support are framework-managed rather than implemented in controllers.

#### HTTP and Presentation Layer

Controllers are the request entry points and assemble model data for JSP views. The public/account shopping surface is partitioned by product browsing, cart, orders, accounts, and wishlists:

- `ECommerce/src/main/java/com/example/controller/ProductController.java`
- `ECommerce/src/main/java/com/example/controller/CartController.java`
- `ECommerce/src/main/java/com/example/controller/OrderController.java`
- `ECommerce/src/main/java/com/example/controller/UserAccountController.java`
- `ECommerce/src/main/java/com/example/controller/WishlistController.java`

Views reside under `WEB-INF`, preventing direct JSP access. Representative customer UI paths are `ECommerce/src/main/webapp/WEB-INF/views/productpage.jsp`, `ECommerce/src/main/webapp/WEB-INF/views/user/userCart/cart.jsp`, and `ECommerce/src/main/webapp/WEB-INF/views/flow/checkout/checkout-flow.xml`.

#### Commerce Domain and Checkout State

Persistent business state is modeled as entities/data-transfer objects for users, roles, product catalog, cart/wishlist, and order/shipping concepts:

- `ECommerce/src/main/java/com/example/model/Product.java`
- `ECommerce/src/main/java/com/example/model/User.java`
- `ECommerce/src/main/java/com/example/model/Cart.java`
- `ECommerce/src/main/java/com/example/model/CustomerOrder.java`
- `ECommerce/src/main/java/com/example/model/ShippingDetails.java`

The expected purchase path is product selection → user cart → checkout web flow → order/shipping persistence. Checkout is explicitly modeled as a Spring Web Flow definition, separating multi-step transaction state from ordinary controller request handling.

#### Catalog, User, and Administrative Operations

The product catalog is organized around products, categories, and suppliers. Administrative controllers expose a distinct management surface for these resources and users:

- `ECommerce/src/main/java/com/example/controller/admin/AdminProductController.java`
- `ECommerce/src/main/java/com/example/controller/admin/AdminCategoryController.java`
- `ECommerce/src/main/java/com/example/controller/admin/AdminSupplierController.java`
- `ECommerce/src/main/java/com/example/controller/admin/AdminUserController.java`

Admin pages are isolated under `ECommerce/src/main/webapp/WEB-INF/views/admin/`, notably product and category edit/list pages. Access to this branch is expected to be mediated by Spring Security and role models such as `ECommerce/src/main/java/com/example/model/Roles.java`.

#### Service and Persistence Boundaries

Business-facing service interfaces/implementations encapsulate catalog, supplier, user, and mail operations, while DAO interfaces/implementations isolate Hibernate persistence. This creates the primary internal flow: controller → service where present → DAO → Hibernate database.

- `ECommerce/src/main/java/com/example/service/impl/ProductServiceImpl.java`
- `ECommerce/src/main/java/com/example/service/impl/UserServiceImpl.java`
- `ECommerce/src/main/java/com/example/dao/impl/ProductDaoImpl.java`
- `ECommerce/src/main/java/com/example/dao/impl/OrderDaoImpl.java`
- `ECommerce/src/main/java/com/example/dao/impl/CartDaoImpl.java`

Cart, order, and wishlist DAOs exist directly even where corresponding service abstractions are not listed, making persistence APIs a material integration boundary.

#### Security and External Services

Spring Security governs login, protected routes, and post-login behavior. Security-specific entry/control points are:

- `ECommerce/src/main/java/com/example/configuration/SecurityConfiguration.java`
- `ECommerce/src/main/java/com/example/configuration/CustomSuccessHandler.java`
- `ECommerce/src/main/webapp/WEB-INF/views/login.jsp`

The sole explicit external integration surface is mailing through `ECommerce/src/main/java/com/example/service/MailService.java` and `ECommerce/src/main/java/com/example/service/impl/MailServiceImpl.java`. No payment gateway, external catalog API, or separate frontend service is evidenced by this tree.

Main entry points: [`ECommerce/src/main/java/com/example/controller/ProductController.java`](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/controller/ProductController.java) (Storefront controllers), [`ECommerce/src/main/java/com/example/configuration/SecurityConfiguration.java`](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/SecurityConfiguration.java) (Spring Security), [`ECommerce/src/main/java/com/example/dao/impl/ProductDaoImpl.java`](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/dao/impl/ProductDaoImpl.java) (Hibernate DAOs), [`ECommerce/src/main/java/com/example/configuration/SpringMvcInitializer.java`](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/SpringMvcInitializer.java) (Spring bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_deployment["Deployment"]
  node_maven["Maven webapp<br/>build package<br/>[pom.xml]"]
  node_webxml["Tomcat descriptor<br/>deployment descriptor"]
end

subgraph group_web["Web and Security"]
  node_spring_bootstrap{{"Spring bootstrap<br/>MVC initializer"}}
  node_security{{"Spring Security<br/>security configuration"}}
  node_success_handler["Login success handler<br/>authentication handler"]
  node_controllers["Storefront controllers<br/>Spring MVC controllers"]
  node_admin_controllers["Admin controllers<br/>Spring MVC controllers"]
  node_jsp_views["Customer JSP views<br/>server-rendered views<br/>[productpage.jsp]"]
  node_admin_views["Admin JSP views<br/>server-rendered views"]
  node_login_view["Login JSP<br/>authentication view<br/>[login.jsp]"]
end

subgraph group_commerce["Commerce Application"]
  node_checkout_flow["Checkout web flow<br/>stateful checkout flow<br/>[checkout-flow.xml]"]
  node_services["Commerce services<br/>service layer"]
  node_mail_service{{"Mail service<br/>external integration<br/>[MailService.java]"}}
  node_domain["Commerce domain<br/>JPA entities<br/>[Product.java]"]
end

subgraph group_persistence["Persistence"]
  node_daos["Hibernate DAOs<br/>persistence layer"]
  node_hibernate{{"Hibernate and transactions<br/>ORM configuration"}}
  node_database[("HSQLDB database<br/>relational database")]
end

node_maven -->|"packages"| node_webxml
node_webxml -->|"deploys"| node_spring_bootstrap
node_spring_bootstrap -->|"dispatches requests to"| node_controllers
node_spring_bootstrap -->|"initializes"| node_security
node_security -->|"uses"| node_success_handler
node_security -->|"protects"| node_controllers
node_security -->|"authorizes roles for"| node_admin_controllers
node_security -->|"renders"| node_login_view
node_controllers -->|"renders"| node_jsp_views
node_admin_controllers -->|"renders"| node_admin_views
node_controllers -->|"uses"| node_services
node_controllers -->|"starts checkout"| node_checkout_flow
node_checkout_flow -->|"creates order and shipping state"| node_domain
node_services -->|"persists through"| node_daos
node_controllers -.->|"uses cart/order persistence"| node_daos
node_daos -->|"maps"| node_domain
node_daos -->|"uses"| node_hibernate
node_hibernate -->|"connects to"| node_database
node_services -->|"sends notifications via"| node_mail_service

click node_maven "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/pom.xml"
click node_spring_bootstrap "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/SpringMvcInitializer.java"
click node_security "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/SecurityConfiguration.java"
click node_success_handler "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/CustomSuccessHandler.java"
click node_controllers "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/controller/ProductController.java"
click node_admin_controllers "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/controller/admin/AdminProductController.java"
click node_jsp_views "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/webapp/WEB-INF/views/productpage.jsp"
click node_login_view "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/webapp/WEB-INF/views/login.jsp"
click node_checkout_flow "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/webapp/WEB-INF/views/flow/checkout/checkout-flow.xml"
click node_services "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/service/impl/ProductServiceImpl.java"
click node_mail_service "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/service/MailService.java"
click node_domain "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/model/Product.java"
click node_daos "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/dao/impl/ProductDaoImpl.java"
click node_hibernate "https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/HibernateConfiguration.java"

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_maven,node_webxml toneBlue
class node_spring_bootstrap,node_security,node_success_handler,node_controllers,node_admin_controllers,node_jsp_views,node_admin_views,node_login_view toneAmber
class node_checkout_flow,node_services,node_mail_service,node_domain toneMint
class node_daos,node_hibernate,node_database toneRose
```

## Components

### Deployment

- [Maven webapp](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/pom.xml): build package · Packages the application for Tomcat. · `ECommerce/pom.xml`
- **Tomcat descriptor**: deployment descriptor

### Web and Security

- [Spring bootstrap](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/SpringMvcInitializer.java): MVC initializer · Creates the servlet application contexts. · `ECommerce/src/main/java/com/example/configuration/SpringMvcInitializer.java`
- [Spring Security](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/SecurityConfiguration.java): security configuration · Protects routes and controls authentication. · `ECommerce/src/main/java/com/example/configuration/SecurityConfiguration.java`
- [Login success handler](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/CustomSuccessHandler.java): authentication handler · `ECommerce/src/main/java/com/example/configuration/CustomSuccessHandler.java`
- [Storefront controllers](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/controller/ProductController.java): Spring MVC controllers · Product, cart, order, account, and wishlist request handlers. · `ECommerce/src/main/java/com/example/controller/ProductController.java`
- [Admin controllers](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/controller/admin/AdminProductController.java): Spring MVC controllers · Management endpoints for products, categories, suppliers, and users. · `ECommerce/src/main/java/com/example/controller/admin/AdminProductController.java`
- [Customer JSP views](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/webapp/WEB-INF/views/productpage.jsp): server-rendered views · WEB-INF views are rendered through MVC rather than directly requested. · `ECommerce/src/main/webapp/WEB-INF/views/productpage.jsp`
- **Admin JSP views**: server-rendered views
- [Login JSP](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/webapp/WEB-INF/views/login.jsp): authentication view · `ECommerce/src/main/webapp/WEB-INF/views/login.jsp`

### Commerce Application

- [Checkout web flow](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/webapp/WEB-INF/views/flow/checkout/checkout-flow.xml): stateful checkout flow · Owns multi-step purchase state. · `ECommerce/src/main/webapp/WEB-INF/views/flow/checkout/checkout-flow.xml`
- [Commerce services](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/service/impl/ProductServiceImpl.java): service layer · Catalog and user business operations. · `ECommerce/src/main/java/com/example/service/impl/ProductServiceImpl.java`
- [Mail service](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/service/MailService.java): external integration · Sends application mail. · `ECommerce/src/main/java/com/example/service/MailService.java`
- [Commerce domain](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/model/Product.java): JPA entities · Products, users, carts, orders, shipping, and roles. · `ECommerce/src/main/java/com/example/model/Product.java`

### Persistence

- [Hibernate DAOs](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/dao/impl/ProductDaoImpl.java): persistence layer · Catalog, cart, and order persistence APIs. · `ECommerce/src/main/java/com/example/dao/impl/ProductDaoImpl.java`
- [Hibernate and transactions](https://github.com/bhavesh27/ecommerce/blob/master/ECommerce/src/main/java/com/example/configuration/HibernateConfiguration.java): ORM configuration · Provides sessions and transaction access. · `ECommerce/src/main/java/com/example/configuration/HibernateConfiguration.java`
- **HSQLDB database**: relational database

## Connections

- Maven webapp → Tomcat descriptor: packages
- Tomcat descriptor → Spring bootstrap: deploys
- Spring bootstrap → Storefront controllers: dispatches requests to
- Spring bootstrap → Spring Security: initializes
- Spring Security → Login success handler: uses
- Spring Security → Storefront controllers: protects
- Spring Security → Admin controllers: authorizes roles for
- Spring Security → Login JSP: renders
- Storefront controllers → Customer JSP views: renders
- Admin controllers → Admin JSP views: renders
- Storefront controllers → Commerce services: uses
- Storefront controllers → Checkout web flow: starts checkout
- Checkout web flow → Commerce domain: creates order and shipping state
- Commerce services → Hibernate DAOs: persists through
- Storefront controllers → Hibernate DAOs: uses cart/order persistence
- Hibernate DAOs → Commerce domain: maps
- Hibernate DAOs → Hibernate and transactions: uses
- Hibernate and transactions → HSQLDB database: connects to
- Commerce services → Mail service: sends notifications via
