# samteng22/ecommerce architecture

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

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

## Overview

This is a Spring Boot ecommerce REST API. Customers register or log in, browse products and categories, add products to a cart, and check out into orders; administrators manage catalog data and order status. Controllers expose the REST endpoints, services own business operations, repositories persist JPA entities, and JWT-based security supports authenticated and role-restricted access. Product images use an optional Cloudinary integration. Relationships below follow sampled service/controller references and README capabilities; several security, category, and integration internals were not sampled, so their links are documented or marked unverified.

Main entry points: [`src/main/java/com/samantha/ecommerce/service/CartService.java`](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/CartService.java) (Cart Operations), [`src/main/java/com/samantha/ecommerce/service/OrderService.java`](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/OrderService.java) (Order Processing), [`src/main/java/com/samantha/ecommerce/service/ProductService.java`](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/ProductService.java) (Product Management), [`src/main/java/com/samantha/ecommerce/repository/ProductRepository.java`](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/ProductRepository.java) (Product Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_auth_api["Authentication API"]
  node_product_api["Product API"]
  node_category_api["Category API"]
  node_cart_api["Cart API"]
  node_order_api["Order API"]
end

subgraph group_identity["Identity and Security"]
  node_auth_service["Authentication<br/>[AuthService.java]"]
  node_jwt_filter["JWT Filter<br/>[JwtAuthFilter.java]"]
  node_jwt_util["JWT Utility<br/>[JwtUtil.java]"]
  node_user_details["User Lookup"]
  node_auth_helper["Current User<br/>[AuthHelper.java]"]
  node_security["Access Control"]
end

subgraph group_commerce["Commerce Services"]
  node_cart_service["Cart Operations<br/>[CartService.java]"]
  node_order_service["Order Processing<br/>[OrderService.java]"]
  node_product_service["Product Management"]
  node_category_service["Category Management"]
  node_cloudinary["Image Hosting"]
end

subgraph group_data["Persistence and Catalog"]
  node_cart_repo["Cart Storage"]
  node_cart_item_repo["Cart Item Storage"]
  node_order_repo["Order Storage"]
  node_product_repo["Product Storage"]
  node_category_repo["Category Storage"]
  node_user_repo["User Storage"]
  node_user_entity[("User Records<br/>[User.java]")]
  node_cart_entity[("Cart Records<br/>[Cart.java]")]
  node_product_entity[("Product Records<br/>[Product.java]")]
  node_category_entity[("Category Records<br/>[Category.java]")]
  node_order_entity[("Order Records<br/>[Order.java]")]
end

node_customer(("Customer"))
node_admin(("Administrator"))
node_postgres[("PostgreSQL")]

node_customer -->|"registers or logs in"| node_auth_api
node_customer -->|"browses"| node_product_api
node_customer -->|"browses"| node_category_api
node_customer -->|"manages cart"| node_cart_api
node_customer -->|"checks out"| node_order_api
node_admin -->|"manages products"| node_product_api
node_admin -->|"manages categories"| node_category_api
node_admin -->|"updates status"| node_order_api
node_auth_api -->|"delegates"| node_auth_service
node_product_api -->|"delegates"| node_product_service
node_category_api -->|"delegates"| node_category_service
node_cart_api -->|"delegates"| node_cart_service
node_order_api -->|"delegates"| node_order_service
node_auth_service -->|"reads and saves"| node_user_repo
node_auth_service -->|"generates tokens"| node_jwt_util
node_jwt_filter -->|"validates tokens"| node_jwt_util
node_user_details -->|"looks up user"| node_user_repo
node_auth_helper -->|"resolves current user"| node_user_repo
node_security -.->|"configures filter"| node_jwt_filter
node_cart_service -->|"gets current user"| node_auth_helper
node_cart_service -->|"reads and saves"| node_cart_repo
node_cart_service -->|"manages items"| node_cart_item_repo
node_cart_service -->|"checks products"| node_product_repo
node_order_service -->|"gets current user"| node_auth_helper
node_order_service -->|"loads and clears cart"| node_cart_repo
node_order_service -->|"updates stock"| node_product_repo
node_order_service -->|"creates and reads"| node_order_repo
node_product_service -->|"manages products"| node_product_repo
node_product_service -->|"resolves category"| node_category_repo
node_product_service -->|"uploads images"| node_cloudinary
node_category_service -->|"manages categories"| node_category_repo
node_cart_repo -->|"persists"| node_cart_entity
node_user_repo -->|"persists"| node_user_entity
node_product_repo -->|"persists"| node_product_entity
node_category_repo -->|"persists"| node_category_entity
node_order_repo -->|"persists"| node_order_entity
node_cart_entity -->|"stored in"| node_postgres
node_user_entity -->|"stored in"| node_postgres
node_product_entity -->|"stored in"| node_postgres
node_category_entity -->|"stored in"| node_postgres
node_order_entity -->|"stored in"| node_postgres

click node_auth_api "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/AuthController.java"
click node_product_api "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/ProductController.java"
click node_category_api "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/CategoryController.java"
click node_cart_api "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/CartController.java"
click node_order_api "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/OrderController.java"
click node_auth_service "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/AuthService.java"
click node_jwt_filter "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/JwtAuthFilter.java"
click node_jwt_util "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/JwtUtil.java"
click node_user_details "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/CustomUserDetailsService.java"
click node_auth_helper "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/AuthHelper.java"
click node_security "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/SecurityConfig.java"
click node_cart_service "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/CartService.java"
click node_order_service "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/OrderService.java"
click node_product_service "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/ProductService.java"
click node_category_service "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/CategoryService.java"
click node_cloudinary "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/CloudinaryService.java"
click node_cart_repo "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/CartRepository.java"
click node_cart_item_repo "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/CartItemRepository.java"
click node_order_repo "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/OrderRepository.java"
click node_product_repo "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/ProductRepository.java"
click node_category_repo "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/CategoryRepository.java"
click node_user_repo "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/UserRepository.java"
click node_user_entity "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/User.java"
click node_cart_entity "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Cart.java"
click node_product_entity "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Product.java"
click node_category_entity "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Category.java"
click node_order_entity "https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Order.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_auth_api,node_product_api,node_category_api,node_cart_api,node_order_api toneBlue
class node_auth_service,node_jwt_filter,node_jwt_util,node_user_details,node_auth_helper,node_security,node_postgres toneAmber
class node_cart_service,node_order_service,node_product_service,node_category_service,node_cloudinary toneMint
class node_cart_repo,node_cart_item_repo,node_order_repo,node_product_repo,node_category_repo,node_user_repo,node_user_entity,node_cart_entity,node_product_entity,node_category_entity,node_order_entity toneRose
class node_customer,node_admin toneIndigo
```

## Components

### REST API

- [Authentication API](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/AuthController.java): `src/main/java/com/samantha/ecommerce/controller/AuthController.java`
- [Product API](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/ProductController.java): `src/main/java/com/samantha/ecommerce/controller/ProductController.java`
- [Category API](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/CategoryController.java): `src/main/java/com/samantha/ecommerce/controller/CategoryController.java`
- [Cart API](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/CartController.java): `src/main/java/com/samantha/ecommerce/controller/CartController.java`
- [Order API](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/controller/OrderController.java): `src/main/java/com/samantha/ecommerce/controller/OrderController.java`

### Identity and Security

- [Authentication](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/AuthService.java): `src/main/java/com/samantha/ecommerce/service/AuthService.java`
- [JWT Filter](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/JwtAuthFilter.java): `src/main/java/com/samantha/ecommerce/config/JwtAuthFilter.java`
- [JWT Utility](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/JwtUtil.java): `src/main/java/com/samantha/ecommerce/config/JwtUtil.java`
- [User Lookup](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/CustomUserDetailsService.java): `src/main/java/com/samantha/ecommerce/config/CustomUserDetailsService.java`
- [Current User](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/AuthHelper.java): `src/main/java/com/samantha/ecommerce/config/AuthHelper.java`
- [Access Control](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/config/SecurityConfig.java): `src/main/java/com/samantha/ecommerce/config/SecurityConfig.java`

### Commerce Services

- [Cart Operations](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/CartService.java): `src/main/java/com/samantha/ecommerce/service/CartService.java`
- [Order Processing](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/OrderService.java): `src/main/java/com/samantha/ecommerce/service/OrderService.java`
- [Product Management](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/ProductService.java): `src/main/java/com/samantha/ecommerce/service/ProductService.java`
- [Category Management](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/CategoryService.java): `src/main/java/com/samantha/ecommerce/service/CategoryService.java`
- [Image Hosting](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/service/CloudinaryService.java): `src/main/java/com/samantha/ecommerce/service/CloudinaryService.java`

### Persistence and Catalog

- [Cart Storage](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/CartRepository.java): `src/main/java/com/samantha/ecommerce/repository/CartRepository.java`
- [Cart Item Storage](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/CartItemRepository.java): `src/main/java/com/samantha/ecommerce/repository/CartItemRepository.java`
- [Order Storage](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/OrderRepository.java): `src/main/java/com/samantha/ecommerce/repository/OrderRepository.java`
- [Product Storage](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/ProductRepository.java): `src/main/java/com/samantha/ecommerce/repository/ProductRepository.java`
- [Category Storage](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/CategoryRepository.java): `src/main/java/com/samantha/ecommerce/repository/CategoryRepository.java`
- [User Storage](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/repository/UserRepository.java): `src/main/java/com/samantha/ecommerce/repository/UserRepository.java`
- [User Records](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/User.java): `src/main/java/com/samantha/ecommerce/model/User.java`
- [Cart Records](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Cart.java): `src/main/java/com/samantha/ecommerce/model/Cart.java`
- [Product Records](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Product.java): `src/main/java/com/samantha/ecommerce/model/Product.java`
- [Category Records](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Category.java): `src/main/java/com/samantha/ecommerce/model/Category.java`
- [Order Records](https://github.com/samteng22/ecommerce/blob/main/src/main/java/com/samantha/ecommerce/model/Order.java): `src/main/java/com/samantha/ecommerce/model/Order.java`

### Other components

- **Customer**
- **Administrator**
- **PostgreSQL**

## Connections

- Customer → Authentication API: registers or logs in
- Customer → Product API: browses
- Customer → Category API: browses
- Customer → Cart API: manages cart
- Customer → Order API: checks out
- Administrator → Product API: manages products
- Administrator → Category API: manages categories
- Administrator → Order API: updates status
- Authentication API → Authentication: delegates (evidence: `src/main/java/com/samantha/ecommerce/controller/AuthController.java`)
- Product API → Product Management: delegates (evidence: `src/main/java/com/samantha/ecommerce/controller/ProductController.java`)
- Category API → Category Management: delegates (evidence: `src/main/java/com/samantha/ecommerce/controller/CategoryController.java`)
- Cart API → Cart Operations: delegates (evidence: `src/main/java/com/samantha/ecommerce/controller/CartController.java`)
- Order API → Order Processing: delegates (evidence: `src/main/java/com/samantha/ecommerce/controller/OrderController.java`)
- Authentication → User Storage: reads and saves (evidence: `src/main/java/com/samantha/ecommerce/service/AuthService.java`)
- Authentication → JWT Utility: generates tokens (evidence: `src/main/java/com/samantha/ecommerce/service/AuthService.java`)
- JWT Filter → JWT Utility: validates tokens (evidence: `src/main/java/com/samantha/ecommerce/config/JwtAuthFilter.java`)
- User Lookup → User Storage: looks up user (evidence: `src/main/java/com/samantha/ecommerce/config/CustomUserDetailsService.java`)
- Current User → User Storage: resolves current user (evidence: `src/main/java/com/samantha/ecommerce/config/AuthHelper.java`)
- Access Control → JWT Filter: configures filter
- Cart Operations → Current User: gets current user (evidence: `src/main/java/com/samantha/ecommerce/service/CartService.java`)
- Cart Operations → Cart Storage: reads and saves (evidence: `src/main/java/com/samantha/ecommerce/service/CartService.java`)
- Cart Operations → Cart Item Storage: manages items (evidence: `src/main/java/com/samantha/ecommerce/service/CartService.java`)
- Cart Operations → Product Storage: checks products (evidence: `src/main/java/com/samantha/ecommerce/service/CartService.java`)
- Order Processing → Current User: gets current user (evidence: `src/main/java/com/samantha/ecommerce/service/OrderService.java`)
- Order Processing → Cart Storage: loads and clears cart (evidence: `src/main/java/com/samantha/ecommerce/service/OrderService.java`)
- Order Processing → Product Storage: updates stock (evidence: `src/main/java/com/samantha/ecommerce/service/OrderService.java`)
- Order Processing → Order Storage: creates and reads (evidence: `src/main/java/com/samantha/ecommerce/service/OrderService.java`)
- Product Management → Product Storage: manages products (evidence: `src/main/java/com/samantha/ecommerce/service/ProductService.java`)
- Product Management → Category Storage: resolves category (evidence: `src/main/java/com/samantha/ecommerce/service/ProductService.java`)
- Product Management → Image Hosting: uploads images (evidence: `src/main/java/com/samantha/ecommerce/service/ProductService.java`)
- Category Management → Category Storage: manages categories (evidence: `src/main/java/com/samantha/ecommerce/service/CategoryService.java`)
- Cart Storage → Cart Records: persists (evidence: `src/main/java/com/samantha/ecommerce/repository/CartRepository.java`)
- User Storage → User Records: persists (evidence: `src/main/java/com/samantha/ecommerce/repository/UserRepository.java`)
- Product Storage → Product Records: persists (evidence: `src/main/java/com/samantha/ecommerce/repository/ProductRepository.java`)
- Category Storage → Category Records: persists (evidence: `src/main/java/com/samantha/ecommerce/repository/CategoryRepository.java`)
- Order Storage → Order Records: persists (evidence: `src/main/java/com/samantha/ecommerce/repository/OrderRepository.java`)
- Cart Records → PostgreSQL: stored in
- User Records → PostgreSQL: stored in
- Product Records → PostgreSQL: stored in
- Category Records → PostgreSQL: stored in
- Order Records → PostgreSQL: stored in
