# panapolll/commerce-api architecture

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

- Interactive diagram: https://gitdiagram.com/panapolll/commerce-api
- Repository: https://github.com/panapolll/commerce-api
- Video tour (about a minute): https://gitdiagram.com/panapolll/commerce-api/video

## Overview

This is a NestJS commerce API. Customers authenticate, browse products, manage a cart, create orders at checkout, and pay for pending orders; successful payment clears the cart and triggers a notification. Admins can manage products and access user records. The sampled code confirms authentication, cart, order, payment, and notification call paths; the README documents product and checkout capabilities, but their service implementations were not sampled, so uncertain internal links are omitted.

Main entry points: [`src/payments/payments.service.ts`](https://github.com/panapolll/commerce-api/blob/main/src/payments/payments.service.ts) (Payment service), [`src/auth/auth.service.ts`](https://github.com/panapolll/commerce-api/blob/main/src/auth/auth.service.ts) (Auth service), [`src/auth/auth.controller.ts`](https://github.com/panapolll/commerce-api/blob/main/src/auth/auth.controller.ts) (Auth endpoints), [`src/users/users.controller.ts`](https://github.com/panapolll/commerce-api/blob/main/src/users/users.controller.ts) (User endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_api["NestJS bootstrap<br/>[main.ts]"]
  node_app["Application modules<br/>[app.module.ts]"]
end

subgraph group_identity["Identity and users"]
  node_authctl["Auth endpoints<br/>[auth.controller.ts]"]
  node_authsvc["Auth service<br/>[auth.service.ts]"]
  node_usersctl["User endpoints"]
  node_usersvc["User service<br/>[users.service.ts]"]
  node_jwt["JWT service"]
end

subgraph group_commerce["Commerce workflow"]
  node_productsctl["Product endpoints"]
  node_productsvc["Product service"]
  node_cartctl["Cart endpoints<br/>[cart.controller.ts]"]
  node_cartsvc["Cart service<br/>[cart.service.ts]"]
  node_ordersctl["Order endpoints"]
  node_ordersvc["Order service<br/>[orders.service.ts]"]
end

subgraph group_payment["Payments and notifications"]
  node_paymentsctl["Payment endpoints"]
  node_paymentssvc["Payment service"]
  node_omise["Omise"]
  node_notificationsvc["Notification service client"]
end

node_customer(("Customer or admin"))
node_notificationapi["Notification service"]
node_mongo[("MongoDB")]

node_api -->|"starts"| node_app
node_customer -->|"authenticates"| node_authctl
node_customer -->|"requests profile"| node_usersctl
node_customer -->|"browses or manages"| node_productsctl
node_customer -->|"manages cart"| node_cartctl
node_customer -->|"checks out"| node_ordersctl
node_customer -->|"pays or submits webhook"| node_paymentsctl
node_authctl -->|"calls"| node_authsvc
node_authsvc -->|"finds or creates user"| node_usersvc
node_authsvc -->|"signs token"| node_jwt
node_usersctl -->|"queries users"| node_usersvc
node_productsctl -->|"calls"| node_productsvc
node_cartctl -->|"calls"| node_cartsvc
node_ordersctl -->|"calls"| node_ordersvc
node_paymentsctl -->|"calls"| node_paymentssvc
node_paymentssvc -->|"creates charge"| node_omise
node_paymentssvc -->|"reads and updates order"| node_mongo
node_paymentssvc -->|"clears cart"| node_cartsvc
node_paymentssvc -->|"sends payment notice"| node_notificationsvc
node_notificationsvc -->|"posts notification"| node_notificationapi

click node_api "https://github.com/panapolll/commerce-api/blob/main/src/main.ts"
click node_app "https://github.com/panapolll/commerce-api/blob/main/src/app.module.ts"
click node_authctl "https://github.com/panapolll/commerce-api/blob/main/src/auth/auth.controller.ts"
click node_authsvc "https://github.com/panapolll/commerce-api/blob/main/src/auth/auth.service.ts"
click node_usersctl "https://github.com/panapolll/commerce-api/blob/main/src/users/users.controller.ts"
click node_usersvc "https://github.com/panapolll/commerce-api/blob/main/src/users/users.service.ts"
click node_productsctl "https://github.com/panapolll/commerce-api/blob/main/src/products/products.controller.ts"
click node_productsvc "https://github.com/panapolll/commerce-api/blob/main/src/products/products.service.ts"
click node_cartctl "https://github.com/panapolll/commerce-api/blob/main/src/cart/cart.controller.ts"
click node_cartsvc "https://github.com/panapolll/commerce-api/blob/main/src/cart/cart.service.ts"
click node_ordersctl "https://github.com/panapolll/commerce-api/blob/main/src/orders/orders.controller.ts"
click node_ordersvc "https://github.com/panapolll/commerce-api/blob/main/src/orders/orders.service.ts"
click node_paymentsctl "https://github.com/panapolll/commerce-api/blob/main/src/payments/payments.controller.ts"
click node_paymentssvc "https://github.com/panapolll/commerce-api/blob/main/src/payments/payments.service.ts"
click node_notificationsvc "https://github.com/panapolll/commerce-api/blob/main/src/notfications/notfications.service.ts"

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_api,node_app toneBlue
class node_authctl,node_authsvc,node_usersctl,node_usersvc,node_jwt,node_mongo toneAmber
class node_productsctl,node_productsvc,node_cartctl,node_cartsvc,node_ordersctl,node_ordersvc toneMint
class node_paymentsctl,node_paymentssvc,node_omise,node_notificationsvc toneRose
class node_customer,node_notificationapi toneIndigo
```

## Components

### API entry

- [NestJS bootstrap](https://github.com/panapolll/commerce-api/blob/main/src/main.ts): `src/main.ts`
- [Application modules](https://github.com/panapolll/commerce-api/blob/main/src/app.module.ts): `src/app.module.ts`

### Identity and users

- [Auth endpoints](https://github.com/panapolll/commerce-api/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Auth service](https://github.com/panapolll/commerce-api/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [User endpoints](https://github.com/panapolll/commerce-api/blob/main/src/users/users.controller.ts): `src/users/users.controller.ts`
- [User service](https://github.com/panapolll/commerce-api/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- **JWT service**

### Commerce workflow

- [Product endpoints](https://github.com/panapolll/commerce-api/blob/main/src/products/products.controller.ts): `src/products/products.controller.ts`
- [Product service](https://github.com/panapolll/commerce-api/blob/main/src/products/products.service.ts): `src/products/products.service.ts`
- [Cart endpoints](https://github.com/panapolll/commerce-api/blob/main/src/cart/cart.controller.ts): `src/cart/cart.controller.ts`
- [Cart service](https://github.com/panapolll/commerce-api/blob/main/src/cart/cart.service.ts): `src/cart/cart.service.ts`
- [Order endpoints](https://github.com/panapolll/commerce-api/blob/main/src/orders/orders.controller.ts): `src/orders/orders.controller.ts`
- [Order service](https://github.com/panapolll/commerce-api/blob/main/src/orders/orders.service.ts): `src/orders/orders.service.ts`

### Payments and notifications

- [Payment endpoints](https://github.com/panapolll/commerce-api/blob/main/src/payments/payments.controller.ts): `src/payments/payments.controller.ts`
- [Payment service](https://github.com/panapolll/commerce-api/blob/main/src/payments/payments.service.ts): `src/payments/payments.service.ts`
- **Omise**
- [Notification service client](https://github.com/panapolll/commerce-api/blob/main/src/notfications/notfications.service.ts): `src/notfications/notfications.service.ts`

### Other components

- **Customer or admin**
- **Notification service**
- **MongoDB**

## Connections

- NestJS bootstrap → Application modules: starts
- Customer or admin → Auth endpoints: authenticates
- Customer or admin → User endpoints: requests profile
- Customer or admin → Product endpoints: browses or manages
- Customer or admin → Cart endpoints: manages cart
- Customer or admin → Order endpoints: checks out
- Customer or admin → Payment endpoints: pays or submits webhook
- Auth endpoints → Auth service: calls
- Auth service → User service: finds or creates user
- Auth service → JWT service: signs token
- User endpoints → User service: queries users
- Product endpoints → Product service: calls
- Cart endpoints → Cart service: calls
- Order endpoints → Order service: calls
- Payment endpoints → Payment service: calls
- Payment service → Omise: creates charge
- Payment service → MongoDB: reads and updates order
- Payment service → Cart service: clears cart
- Payment service → Notification service client: sends payment notice
- Notification service client → Notification service: posts notification
