# ngolegiabao/ecommerce-backend-nodejs architecture

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

- Interactive diagram: https://gitdiagram.com/ngolegiabao/ecommerce-backend-nodejs
- Repository: https://github.com/ngolegiabao/ecommerce-backend-nodejs

## Overview

This is a shoe-shop e-commerce backend split into an API gateway and domain services. The main customer journey enters through the gateway, manages a cart, checks out into an order, applies a voucher, and completes payment; identity, catalog, inventory, media, reviews, and loyalty support that flow. The tree and README establish additional admin, analytics, and notification capabilities. Sampled controllers confirm several controller-to-service calls and review, media-event, and identity behavior; unsampled service wiring is shown only where the service boundaries and documented capabilities support it.

Main entry points: [`api-gateway/src/app.ts`](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/api-gateway/src/app.ts) (API gateway), [`product-service/src/services`](https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/product-service/src/services) (Products and categories), [`user-service/src/services/user.service.ts`](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/user-service/src/services/user.service.ts) (Users and addresses), [`order-service/src/services`](https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/order-service/src/services) (Orders and analytics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_gateway["API gateway<br/>[app.ts]"]
end

subgraph group_commerce["Shopping and orders"]
  node_cart["Cart management"]
  node_orders["Orders and analytics"]
  node_payments["Payment processing<br/>[payment.service.ts]"]
  node_vouchers["Discount vouchers<br/>[voucher.service.ts]"]
end

subgraph group_catalog["Catalog and media"]
  node_products["Products and categories"]
  node_inventory["Inventory"]
  node_reviews["Reviews and ratings<br/>[review.service.ts]"]
  node_media["Media uploads<br/>[file.service.ts]"]
end

subgraph group_identity["Accounts and loyalty"]
  node_users["Users and addresses<br/>[user.service.ts]"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_loyalty["Loyalty points<br/>[loyalty.service.ts]"]
end

subgraph group_communications["Events and notifications"]
  node_redis["Redis events<br/>[redis.core.ts]"]
  node_notifications["Email notifications"]
end

node_customer(("Customer or admin"))
node_mongo[("MongoDB")]
node_email["Email provider"]
node_cloudinary["Cloudinary"]
node_vnpay["VNPay"]
node_sentiment["Sentiment analysis"]

node_customer -->|"requests"| node_gateway
node_gateway -->|"proxies cart"| node_cart
node_gateway -->|"proxies orders"| node_orders
node_gateway -->|"proxies payments"| node_payments
node_gateway -->|"proxies vouchers"| node_vouchers
node_gateway -->|"proxies catalog"| node_products
node_gateway -->|"proxies inventory"| node_inventory
node_gateway -->|"proxies reviews"| node_reviews
node_gateway -->|"proxies media"| node_media
node_gateway -->|"proxies users"| node_users
node_gateway -->|"proxies auth"| node_auth
node_gateway -->|"proxies loyalty"| node_loyalty
node_cart -->|"fetches product data"| node_products
node_orders -->|"fetches product data"| node_products
node_orders -->|"uses guest account data"| node_users
node_orders -->|"creates payments"| node_payments
node_payments -.->|"uses gateway"| node_vnpay
node_reviews -.->|"analyzes comments"| node_sentiment
node_reviews -->|"fetches public info"| node_users
node_reviews -->|"updates rating totals"| node_products
node_media -.->|"uploads files"| node_cloudinary
node_media -->|"publishes upload events"| node_redis
node_redis -->|"dispatches image updates"| node_products
node_redis -->|"dispatches avatar updates"| node_users
node_redis -->|"dispatches events"| node_notifications
node_notifications -.->|"sends email"| node_email
node_auth -->|"creates guest account"| node_users
node_auth -->|"stores refresh tokens"| node_redis
node_cart -->|"reads and writes"| node_mongo
node_orders -->|"reads and writes"| node_mongo
node_payments -->|"reads and writes"| node_mongo
node_vouchers -->|"reads and writes"| node_mongo
node_products -->|"reads and writes"| node_mongo
node_inventory -->|"reads and writes"| node_mongo
node_reviews -->|"reads and writes"| node_mongo
node_users -->|"reads and writes"| node_mongo
node_auth -->|"reads and writes"| node_mongo
node_loyalty -->|"reads and writes"| node_mongo

click node_gateway "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/api-gateway/src/app.ts"
click node_cart "https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/cart-service/src/services"
click node_orders "https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/order-service/src/services"
click node_payments "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/order-service/src/services/payment.service.ts"
click node_vouchers "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/voucher-service/src/services/voucher.service.ts"
click node_products "https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/product-service/src/services"
click node_inventory "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/product-service/src/services/inventory.service.ts"
click node_reviews "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/product-service/src/services/review.service.ts"
click node_media "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/media-service/src/services/file.service.ts"
click node_users "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/user-service/src/services/user.service.ts"
click node_auth "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/user-service/src/services/auth.service.ts"
click node_loyalty "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/user-service/src/services/loyalty.service.ts"
click node_redis "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/product-service/src/core/redis.core.ts"
click node_notifications "https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/notification-service/src/subscribers/notification.subscriber.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_gateway toneBlue
class node_cart,node_orders,node_payments,node_vouchers,node_mongo toneAmber
class node_products,node_inventory,node_reviews,node_media toneMint
class node_users,node_auth,node_loyalty toneRose
class node_redis,node_notifications,node_customer,node_email,node_cloudinary,node_vnpay,node_sentiment toneIndigo
```

## Components

### API entry

- [API gateway](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/api-gateway/src/app.ts): `api-gateway/src/app.ts`

### Shopping and orders

- [Cart management](https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/cart-service/src/services): `cart-service/src/services`
- [Orders and analytics](https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/order-service/src/services): `order-service/src/services`
- [Payment processing](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/order-service/src/services/payment.service.ts): `order-service/src/services/payment.service.ts`
- [Discount vouchers](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/voucher-service/src/services/voucher.service.ts): `voucher-service/src/services/voucher.service.ts`

### Catalog and media

- [Products and categories](https://github.com/ngolegiabao/ecommerce-backend-nodejs/tree/main/product-service/src/services): `product-service/src/services`
- [Inventory](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/product-service/src/services/inventory.service.ts): `product-service/src/services/inventory.service.ts`
- [Reviews and ratings](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/product-service/src/services/review.service.ts): `product-service/src/services/review.service.ts`
- [Media uploads](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/media-service/src/services/file.service.ts): `media-service/src/services/file.service.ts`

### Accounts and loyalty

- [Users and addresses](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/user-service/src/services/user.service.ts): `user-service/src/services/user.service.ts`
- [Authentication](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/user-service/src/services/auth.service.ts): `user-service/src/services/auth.service.ts`
- [Loyalty points](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/user-service/src/services/loyalty.service.ts): `user-service/src/services/loyalty.service.ts`

### Events and notifications

- [Redis events](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/product-service/src/core/redis.core.ts): `product-service/src/core/redis.core.ts`
- [Email notifications](https://github.com/ngolegiabao/ecommerce-backend-nodejs/blob/main/notification-service/src/subscribers/notification.subscriber.ts): `notification-service/src/subscribers/notification.subscriber.ts`

### Other components

- **Customer or admin**
- **MongoDB**
- **Email provider**
- **Cloudinary**
- **VNPay**
- **Sentiment analysis**

## Connections

- Customer or admin → API gateway: requests
- API gateway → Cart management: proxies cart
- API gateway → Orders and analytics: proxies orders
- API gateway → Payment processing: proxies payments
- API gateway → Discount vouchers: proxies vouchers
- API gateway → Products and categories: proxies catalog
- API gateway → Inventory: proxies inventory
- API gateway → Reviews and ratings: proxies reviews
- API gateway → Media uploads: proxies media
- API gateway → Users and addresses: proxies users
- API gateway → Authentication: proxies auth
- API gateway → Loyalty points: proxies loyalty
- Cart management → Products and categories: fetches product data
- Orders and analytics → Products and categories: fetches product data
- Orders and analytics → Users and addresses: uses guest account data
- Orders and analytics → Payment processing: creates payments
- Payment processing → VNPay: uses gateway
- Reviews and ratings → Sentiment analysis: analyzes comments
- Reviews and ratings → Users and addresses: fetches public info
- Reviews and ratings → Products and categories: updates rating totals
- Media uploads → Cloudinary: uploads files
- Media uploads → Redis events: publishes upload events
- Redis events → Products and categories: dispatches image updates
- Redis events → Users and addresses: dispatches avatar updates
- Redis events → Email notifications: dispatches events
- Email notifications → Email provider: sends email
- Authentication → Users and addresses: creates guest account
- Authentication → Redis events: stores refresh tokens
- Cart management → MongoDB: reads and writes
- Orders and analytics → MongoDB: reads and writes
- Payment processing → MongoDB: reads and writes
- Discount vouchers → MongoDB: reads and writes
- Products and categories → MongoDB: reads and writes
- Inventory → MongoDB: reads and writes
- Reviews and ratings → MongoDB: reads and writes
- Users and addresses → MongoDB: reads and writes
- Authentication → MongoDB: reads and writes
- Loyalty points → MongoDB: reads and writes
