# mosh-hamedani/spring-api-finished architecture

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

- Interactive diagram: https://gitdiagram.com/mosh-hamedani/spring-api-finished
- Repository: https://github.com/mosh-hamedani/spring-api-finished

## Overview

This is a Spring Boot e-commerce REST API. The documented customer journey is browsing products, creating and filling a cart, registering and logging in, checking out through Stripe, then receiving an order-status update through a webhook and viewing order history. The graph also shows the user, product, cart, and order service/repository layers. Relationships are limited to those shown in excerpts, the source index, or README; some controller and security implementation details were not sampled.

Main entry points: [`src/main/java/com/codewithmosh/store/payments/CheckoutService.java`](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/CheckoutService.java) (Checkout service), [`src/main/java/com/codewithmosh/store/auth/AuthService.java`](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/auth/AuthService.java) (Auth service), [`src/main/java/com/codewithmosh/store/payments/CheckoutController.java`](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/CheckoutController.java) (Checkout API), [`src/main/java/com/codewithmosh/store/products/ProductController.java`](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/products/ProductController.java) (Product API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Product catalog"]
  node_product_api["Product API"]
  node_product_repo[("Product repository")]
  node_category_repo[("Category repository")]
end

subgraph group_identity["Users and auth"]
  node_user_api["User API"]
  node_user_service["User service<br/>[UserService.java]"]
  node_user_repo[("User repository")]
  node_auth_api["Auth API"]
  node_auth_service["Auth service<br/>[AuthService.java]"]
  node_jwt_service["JWT service<br/>[JwtService.java]"]
end

subgraph group_shopping["Cart and orders"]
  node_cart_api["Cart API"]
  node_cart_service["Cart service<br/>[CartService.java]"]
  node_cart_repo[("Cart repository")]
  node_order_api["Order API"]
  node_order_service["Order service<br/>[OrderService.java]"]
  node_order_repo[("Order repository")]
end

subgraph group_payments["Checkout and payment"]
  node_checkout_api["Checkout API"]
  node_checkout_service["Checkout service"]
  node_payment_gateway["Payment gateway"]
end

node_customer(("Customer"))
node_stripe["Stripe"]

node_customer -->|"browse products"| node_product_api
node_product_api -->|"queries"| node_product_repo
node_product_api -->|"queries"| node_category_repo
node_customer -->|"manage cart"| node_cart_api
node_cart_api -->|"delegates"| node_cart_service
node_cart_service -->|"loads and saves"| node_cart_repo
node_cart_service -->|"looks up products"| node_product_repo
node_customer -->|"registers"| node_user_api
node_user_api -->|"delegates"| node_user_service
node_user_service -->|"reads and writes"| node_user_repo
node_customer -->|"logs in"| node_auth_api
node_auth_api -->|"delegates"| node_auth_service
node_auth_service -->|"loads account"| node_user_repo
node_auth_service -->|"creates tokens"| node_jwt_service
node_customer -->|"checks out"| node_checkout_api
node_checkout_api -->|"delegates"| node_checkout_service
node_checkout_service -->|"loads cart"| node_cart_repo
node_checkout_service -->|"saves order"| node_order_repo
node_checkout_service -->|"gets current user"| node_auth_service
node_checkout_service -->|"creates session"| node_payment_gateway
node_payment_gateway -->|"starts payment"| node_stripe
node_stripe -->|"sends webhook"| node_checkout_api
node_checkout_api -->|"forwards webhook"| node_checkout_service
node_checkout_service -->|"parses event"| node_payment_gateway
node_checkout_service -->|"updates status"| node_order_repo
node_customer -->|"views history"| node_order_api
node_order_api -->|"delegates"| node_order_service
node_order_service -->|"gets current user"| node_auth_service
node_order_service -->|"loads orders"| node_order_repo

click node_product_api "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/products/ProductController.java"
click node_product_repo "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/products/ProductRepository.java"
click node_category_repo "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/products/CategoryRepository.java"
click node_user_api "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/users/UserController.java"
click node_user_service "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/users/UserService.java"
click node_user_repo "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/users/UserRepository.java"
click node_auth_api "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/auth/AuthController.java"
click node_auth_service "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/auth/AuthService.java"
click node_jwt_service "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/auth/JwtService.java"
click node_cart_api "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/carts/CartController.java"
click node_cart_service "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/carts/CartService.java"
click node_cart_repo "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/carts/CartRepository.java"
click node_checkout_api "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/CheckoutController.java"
click node_checkout_service "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/CheckoutService.java"
click node_payment_gateway "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/StripePaymentGateway.java"
click node_order_api "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/orders/OrderController.java"
click node_order_service "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/orders/OrderService.java"
click node_order_repo "https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/orders/OrderRepository.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_product_api,node_product_repo,node_category_repo toneBlue
class node_user_api,node_user_service,node_user_repo,node_auth_api,node_auth_service,node_jwt_service toneAmber
class node_cart_api,node_cart_service,node_cart_repo,node_order_api,node_order_service,node_order_repo toneMint
class node_checkout_api,node_checkout_service,node_payment_gateway toneRose
class node_customer,node_stripe toneIndigo
```

## Components

### Product catalog

- [Product API](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/products/ProductController.java): `src/main/java/com/codewithmosh/store/products/ProductController.java`
- [Product repository](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/products/ProductRepository.java): `src/main/java/com/codewithmosh/store/products/ProductRepository.java`
- [Category repository](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/products/CategoryRepository.java): `src/main/java/com/codewithmosh/store/products/CategoryRepository.java`

### Users and auth

- [User API](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/users/UserController.java): `src/main/java/com/codewithmosh/store/users/UserController.java`
- [User service](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/users/UserService.java): `src/main/java/com/codewithmosh/store/users/UserService.java`
- [User repository](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/users/UserRepository.java): `src/main/java/com/codewithmosh/store/users/UserRepository.java`
- [Auth API](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/auth/AuthController.java): `src/main/java/com/codewithmosh/store/auth/AuthController.java`
- [Auth service](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/auth/AuthService.java): `src/main/java/com/codewithmosh/store/auth/AuthService.java`
- [JWT service](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/auth/JwtService.java): `src/main/java/com/codewithmosh/store/auth/JwtService.java`

### Cart and orders

- [Cart API](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/carts/CartController.java): `src/main/java/com/codewithmosh/store/carts/CartController.java`
- [Cart service](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/carts/CartService.java): `src/main/java/com/codewithmosh/store/carts/CartService.java`
- [Cart repository](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/carts/CartRepository.java): `src/main/java/com/codewithmosh/store/carts/CartRepository.java`
- [Order API](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/orders/OrderController.java): `src/main/java/com/codewithmosh/store/orders/OrderController.java`
- [Order service](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/orders/OrderService.java): `src/main/java/com/codewithmosh/store/orders/OrderService.java`
- [Order repository](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/orders/OrderRepository.java): `src/main/java/com/codewithmosh/store/orders/OrderRepository.java`

### Checkout and payment

- [Checkout API](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/CheckoutController.java): `src/main/java/com/codewithmosh/store/payments/CheckoutController.java`
- [Checkout service](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/CheckoutService.java): `src/main/java/com/codewithmosh/store/payments/CheckoutService.java`
- [Payment gateway](https://github.com/mosh-hamedani/spring-api-finished/blob/main/src/main/java/com/codewithmosh/store/payments/StripePaymentGateway.java): `src/main/java/com/codewithmosh/store/payments/StripePaymentGateway.java`

### Other components

- **Customer**
- **Stripe**

## Connections

- Customer → Product API: browse products
- Product API → Product repository: queries (evidence: `src/main/java/com/codewithmosh/store/products/ProductController.java`)
- Product API → Category repository: queries (evidence: `src/main/java/com/codewithmosh/store/products/ProductController.java`)
- Customer → Cart API: manage cart
- Cart API → Cart service: delegates (evidence: `src/main/java/com/codewithmosh/store/carts/CartController.java`)
- Cart service → Cart repository: loads and saves (evidence: `src/main/java/com/codewithmosh/store/carts/CartService.java`)
- Cart service → Product repository: looks up products (evidence: `src/main/java/com/codewithmosh/store/carts/CartService.java`)
- Customer → User API: registers
- User API → User service: delegates (evidence: `src/main/java/com/codewithmosh/store/users/UserController.java`)
- User service → User repository: reads and writes (evidence: `src/main/java/com/codewithmosh/store/users/UserService.java`)
- Customer → Auth API: logs in
- Auth API → Auth service: delegates (evidence: `src/main/java/com/codewithmosh/store/auth/AuthController.java`)
- Auth service → User repository: loads account (evidence: `src/main/java/com/codewithmosh/store/auth/AuthService.java`)
- Auth service → JWT service: creates tokens (evidence: `src/main/java/com/codewithmosh/store/auth/AuthService.java`)
- Customer → Checkout API: checks out
- Checkout API → Checkout service: delegates (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutController.java`)
- Checkout service → Cart repository: loads cart (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutService.java`)
- Checkout service → Order repository: saves order (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutService.java`)
- Checkout service → Auth service: gets current user (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutService.java`)
- Checkout service → Payment gateway: creates session (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutService.java`)
- Payment gateway → Stripe: starts payment
- Stripe → Checkout API: sends webhook
- Checkout API → Checkout service: forwards webhook (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutController.java`)
- Checkout service → Payment gateway: parses event (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutService.java`)
- Checkout service → Order repository: updates status (evidence: `src/main/java/com/codewithmosh/store/payments/CheckoutService.java`)
- Customer → Order API: views history
- Order API → Order service: delegates (evidence: `src/main/java/com/codewithmosh/store/orders/OrderController.java`)
- Order service → Auth service: gets current user (evidence: `src/main/java/com/codewithmosh/store/orders/OrderService.java`)
- Order service → Order repository: loads orders (evidence: `src/main/java/com/codewithmosh/store/orders/OrderService.java`)
