# aws-samples/aws-serverless-shopping-cart architecture

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

- Interactive diagram: https://gitdiagram.com/aws-samples/aws-serverless-shopping-cart
- Repository: https://github.com/aws-samples/aws-serverless-shopping-cart

## Overview

This is a serverless shopping-cart sample with a Vue storefront, authenticated and anonymous carts, a mock product catalog, and AWS-backed REST services. The primary flow is browsing products, adding or editing cart items, and checking out; signing in can migrate and merge an anonymous cart. Separate documented capabilities include cart expiry, asynchronous deletion during migration, and an aggregated per-product cart count. Source excerpts show key frontend dispatches and backend operations; several service connections are included only where the README documents them.

Main entry points: [`frontend/src/store/actions.js`](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/actions.js) (Cart actions), [`frontend/src/router.js`](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/router.js) (Page routing), [`backend/shopping-cart-service/add_to_cart.py`](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/add_to_cart.py) (Add cart item), [`backend/shopping-cart-service/migrate_cart.py`](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/migrate_cart.py) (Migrate cart)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app["Storefront shell<br/>[App.vue]"]
  node_routes["Page routing<br/>[router.js]"]
  node_home["Product browsing<br/>[Home.vue]"]
  node_auth["Authentication view<br/>[Auth.vue]"]
  node_checkout["Checkout view<br/>[Payment.vue]"]
  node_cartui["Cart controls<br/>[CartDrawer.vue]"]
  node_store["Client state<br/>[store.js]"]
  node_actions["Cart actions<br/>[actions.js]"]
  node_mutations["State mutations<br/>[mutations.js]"]
  node_getters["State getters<br/>[getters.js]"]
  node_api["API client<br/>[api.js]"]
  node_config["Amplify config<br/>[aws-exports.js]"]
end

subgraph group_cart["Cart services"]
  node_add["Add cart item<br/>[add_to_cart.py]"]
  node_list["List cart<br/>[list_cart.py]"]
  node_update["Update cart item<br/>[update_cart.py]"]
  node_remove["Delete cart item"]
  node_migrate["Migrate cart<br/>[migrate_cart.py]"]
  node_empty["Empty cart<br/>[checkout_cart.py]"]
  node_total["Product cart total<br/>[get_cart_total.py]"]
  node_shared["Cart identity helpers<br/>[shared.py]"]
  node_productlookup["Product lookup<br/>[utils.py]"]
  node_deleteworker["Queued deletion"]
  node_stream["Cart total aggregation"]
end

subgraph group_catalog["Product catalog"]
  node_productservice["Mock product API<br/>[get_product.py]"]
  node_products["Product listing<br/>[get_products.py]"]
end

subgraph group_aws["AWS services"]
  node_gateway{{"REST API"}}
  node_ddb[("DynamoDB")]
  node_queue["SQS deletion queue"]
  node_cognito{{"Cognito"}}
end

node_shopper(("Shopper"))

node_shopper -->|"uses"| node_app
node_app -->|"fetches cart"| node_actions
node_routes -->|"routes to"| node_auth
node_routes -->|"routes to"| node_home
node_routes -->|"routes to"| node_checkout
node_routes -->|"dispatches migration"| node_actions
node_home -.->|"uses"| node_actions
node_cartui -.->|"updates cart"| node_actions
node_checkout -.->|"checks out"| node_actions
node_store -->|"registers"| node_actions
node_store -->|"registers"| node_mutations
node_store -->|"registers"| node_getters
node_actions -->|"calls API"| node_api
node_actions -->|"commits state"| node_mutations
node_auth -.->|"authenticates"| node_cognito
node_app -->|"configures Amplify"| node_config
node_api -->|"requests REST"| node_gateway
node_gateway -->|"GET cart"| node_list
node_gateway -->|"POST cart"| node_add
node_gateway -->|"PUT item"| node_update
node_gateway -->|"migrate route"| node_migrate
node_gateway -->|"checkout route"| node_empty
node_gateway -->|"total route"| node_total
node_gateway -->|"GET products"| node_products
node_gateway -->|"GET product"| node_productservice
node_add -->|"looks up product"| node_productlookup
node_update -->|"looks up product"| node_productlookup
node_productlookup -->|"requests details"| node_productservice
node_add -->|"writes item"| node_ddb
node_update -->|"writes item"| node_ddb
node_list -->|"reads cart"| node_ddb
node_migrate -->|"reads and merges"| node_ddb
node_migrate -->|"queues deletion"| node_queue
node_queue -->|"triggers worker"| node_deleteworker
node_deleteworker -.->|"deletes items"| node_ddb
node_empty -->|"clears cart"| node_ddb
node_total -->|"reads totals"| node_ddb
node_ddb -->|"emits changes"| node_stream
node_stream -->|"updates aggregates"| node_ddb
node_add -->|"uses helpers"| node_shared
node_migrate -->|"uses helpers"| node_shared
node_cognito -->|"authorizes requests"| node_gateway

click node_app "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/App.vue"
click node_routes "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/router.js"
click node_home "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/views/Home.vue"
click node_auth "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/views/Auth.vue"
click node_checkout "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/views/Payment.vue"
click node_cartui "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/components/CartDrawer.vue"
click node_store "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/store.js"
click node_actions "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/actions.js"
click node_mutations "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/mutations.js"
click node_getters "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/getters.js"
click node_api "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/backend/api.js"
click node_config "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/aws-exports.js"
click node_add "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/add_to_cart.py"
click node_list "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/list_cart.py"
click node_update "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/update_cart.py"
click node_remove "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/delete_from_cart.py"
click node_migrate "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/migrate_cart.py"
click node_empty "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/checkout_cart.py"
click node_total "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/get_cart_total.py"
click node_shared "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/layers/shared.py"
click node_productlookup "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/utils.py"
click node_productservice "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/product-mock-service/get_product.py"
click node_products "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/product-mock-service/get_products.py"
click node_deleteworker "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/db_stream_handler.py"
click node_stream "https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/db_stream_handler.py"

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_app,node_routes,node_home,node_auth,node_checkout,node_cartui,node_store,node_actions,node_mutations,node_getters,node_api,node_config toneBlue
class node_add,node_list,node_update,node_remove,node_migrate,node_empty,node_total,node_shared,node_productlookup,node_deleteworker,node_stream toneAmber
class node_productservice,node_products toneMint
class node_gateway,node_ddb,node_queue,node_cognito toneRose
class node_shopper toneIndigo
```

## Components

### Storefront

- [Storefront shell](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/App.vue): `frontend/src/App.vue`
- [Page routing](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/router.js): `frontend/src/router.js`
- [Product browsing](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/views/Home.vue): `frontend/src/views/Home.vue`
- [Authentication view](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/views/Auth.vue): `frontend/src/views/Auth.vue`
- [Checkout view](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/views/Payment.vue): `frontend/src/views/Payment.vue`
- [Cart controls](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/components/CartDrawer.vue): `frontend/src/components/CartDrawer.vue`
- [Client state](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/store.js): `frontend/src/store/store.js`
- [Cart actions](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/actions.js): `frontend/src/store/actions.js`
- [State mutations](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/mutations.js): `frontend/src/store/mutations.js`
- [State getters](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/store/getters.js): `frontend/src/store/getters.js`
- [API client](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/backend/api.js): `frontend/src/backend/api.js`
- [Amplify config](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/frontend/src/aws-exports.js): `frontend/src/aws-exports.js`

### Cart services

- [Add cart item](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/add_to_cart.py): `backend/shopping-cart-service/add_to_cart.py`
- [List cart](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/list_cart.py): `backend/shopping-cart-service/list_cart.py`
- [Update cart item](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/update_cart.py): `backend/shopping-cart-service/update_cart.py`
- [Delete cart item](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/delete_from_cart.py): `backend/shopping-cart-service/delete_from_cart.py`
- [Migrate cart](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/migrate_cart.py): `backend/shopping-cart-service/migrate_cart.py`
- [Empty cart](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/checkout_cart.py): `backend/shopping-cart-service/checkout_cart.py`
- [Product cart total](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/get_cart_total.py): `backend/shopping-cart-service/get_cart_total.py`
- [Cart identity helpers](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/layers/shared.py): `backend/layers/shared.py`
- [Product lookup](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/utils.py): `backend/shopping-cart-service/utils.py`
- [Queued deletion](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/db_stream_handler.py): `backend/shopping-cart-service/db_stream_handler.py`
- [Cart total aggregation](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/shopping-cart-service/db_stream_handler.py): `backend/shopping-cart-service/db_stream_handler.py`

### Product catalog

- [Mock product API](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/product-mock-service/get_product.py): `backend/product-mock-service/get_product.py`
- [Product listing](https://github.com/aws-samples/aws-serverless-shopping-cart/blob/master/backend/product-mock-service/get_products.py): `backend/product-mock-service/get_products.py`

### AWS services

- **REST API**
- **DynamoDB**
- **SQS deletion queue**
- **Cognito**

### Other components

- **Shopper**

## Connections

- Shopper → Storefront shell: uses (evidence: `README.md`)
- Storefront shell → Cart actions: fetches cart (evidence: `frontend/src/App.vue`)
- Page routing → Authentication view: routes to (evidence: `frontend/src/router.js`)
- Page routing → Product browsing: routes to (evidence: `frontend/src/router.js`)
- Page routing → Checkout view: routes to (evidence: `frontend/src/router.js`)
- Page routing → Cart actions: dispatches migration (evidence: `frontend/src/router.js`)
- Product browsing → Cart actions: uses
- Cart controls → Cart actions: updates cart
- Checkout view → Cart actions: checks out
- Client state → Cart actions: registers (evidence: `frontend/src/store/store.js`)
- Client state → State mutations: registers (evidence: `frontend/src/store/store.js`)
- Client state → State getters: registers (evidence: `frontend/src/store/store.js`)
- Cart actions → API client: calls API (evidence: `frontend/src/store/actions.js`)
- Cart actions → State mutations: commits state (evidence: `frontend/src/store/actions.js`)
- Authentication view → Cognito: authenticates
- Storefront shell → Amplify config: configures Amplify (evidence: `frontend/src/main.js`)
- API client → REST API: requests REST (evidence: `README.md`)
- REST API → List cart: GET cart (evidence: `README.md`)
- REST API → Add cart item: POST cart (evidence: `README.md`)
- REST API → Update cart item: PUT item (evidence: `README.md`)
- REST API → Migrate cart: migrate route (evidence: `README.md`)
- REST API → Empty cart: checkout route (evidence: `README.md`)
- REST API → Product cart total: total route (evidence: `README.md`)
- REST API → Product listing: GET products (evidence: `README.md`)
- REST API → Mock product API: GET product (evidence: `README.md`)
- Add cart item → Product lookup: looks up product (evidence: `backend/shopping-cart-service/add_to_cart.py`)
- Update cart item → Product lookup: looks up product (evidence: `backend/shopping-cart-service/update_cart.py`)
- Product lookup → Mock product API: requests details (evidence: `backend/shopping-cart-service/utils.py`)
- Add cart item → DynamoDB: writes item (evidence: `README.md`)
- Update cart item → DynamoDB: writes item (evidence: `README.md`)
- List cart → DynamoDB: reads cart (evidence: `README.md`)
- Migrate cart → DynamoDB: reads and merges (evidence: `backend/shopping-cart-service/migrate_cart.py`)
- Migrate cart → SQS deletion queue: queues deletion (evidence: `backend/shopping-cart-service/migrate_cart.py`)
- SQS deletion queue → Queued deletion: triggers worker (evidence: `README.md`)
- Queued deletion → DynamoDB: deletes items
- Empty cart → DynamoDB: clears cart (evidence: `README.md`)
- Product cart total → DynamoDB: reads totals (evidence: `README.md`)
- DynamoDB → Cart total aggregation: emits changes (evidence: `README.md`)
- Cart total aggregation → DynamoDB: updates aggregates (evidence: `README.md`)
- Add cart item → Cart identity helpers: uses helpers (evidence: `backend/shopping-cart-service/add_to_cart.py`)
- Migrate cart → Cart identity helpers: uses helpers (evidence: `backend/shopping-cart-service/migrate_cart.py`)
- Cognito → REST API: authorizes requests (evidence: `README.md`)
