# codefactory-co/fastcampus-nestjs-part2 architecture

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

- Interactive diagram: https://gitdiagram.com/codefactory-co/fastcampus-nestjs-part2
- Repository: https://github.com/codefactory-co/fastcampus-nestjs-part2

## Overview

This repository implements a NestJS microservices order and commerce system: a gateway exposes authentication, product, and order APIs, while user, product, order, payment, and notification services handle domain work over gRPC. The principal order flow retrieves user and product data, checks the requested total, persists an order, then requests payment and updates order status. Source excerpts show the order orchestration and several service boundaries; some gateway routing and notification behavior is only indicated by configured clients, so those links are marked unverified.

Main entry points: [`apps/order/src/order/order.service.ts`](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/order/src/order/order.service.ts) (Order Workflow), [`apps/user/src/auth/auth.service.ts`](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/auth/auth.service.ts) (User Authentication), [`apps/payment/src/payment/payment.service.ts`](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/payment/src/payment/payment.service.ts) (Payment Processing), [`apps/user/src/user/user.service.ts`](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/user/user.service.ts) (User Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["API Gateway"]
  node_gateway["Gateway App<br/>[app.module.ts]"]
  node_gateway_auth["Auth API<br/>[auth.controller.ts]"]
  node_gateway_auth_service["Auth Proxy<br/>[auth.service.ts]"]
  node_gateway_order["Order API"]
  node_gateway_product["Product API"]
end

subgraph group_identity["Identity"]
  node_user_auth["User Authentication<br/>[auth.service.ts]"]
  node_user_data["User Service<br/>[user.service.ts]"]
  node_user_db[("User Database<br/>[user.entity.ts]")]
end

subgraph group_commerce["Commerce Services"]
  node_order_api["Order RPC"]
  node_order_flow["Order Workflow<br/>[order.service.ts]"]
  node_order_db[("Order Store<br/>[order.entity.ts]")]
  node_product_api["Product RPC"]
  node_product_flow["Product Catalog<br/>[product.service.ts]"]
  node_product_db[("Product Store<br/>[product.entity.ts]")]
  node_payment_api["Payment RPC"]
  node_payment_flow["Payment Processing<br/>[payment.service.ts]"]
  node_payment_db[("Payment Store<br/>[payment.entity.ts]")]
end

subgraph group_messaging["Notifications"]
  node_notification_api["Notification RPC"]
  node_notification_flow["Notification Service"]
  node_notification_db[("Notification Store")]
end

subgraph group_shared["Shared RPC"]
  node_rpc_contracts["gRPC Contracts<br/>[index.ts]"]
end

node_client(("API Client"))

node_client -->|"requests auth"| node_gateway_auth
node_client -->|"submits order"| node_gateway_order
node_gateway_auth -->|"calls"| node_gateway_auth_service
node_gateway_auth_service -->|"gRPC auth"| node_user_auth
node_client -->|"requests products"| node_gateway_product
node_gateway_order -.->|"routes order"| node_order_api
node_gateway_product -.->|"routes catalog"| node_product_api
node_order_api -->|"delegates"| node_order_flow
node_order_flow -->|"fetches user"| node_user_data
node_order_flow -->|"fetches products"| node_product_flow
node_order_flow -->|"requests payment"| node_payment_api
node_order_flow -->|"writes order"| node_order_db
node_product_api -->|"delegates"| node_product_flow
node_product_flow -->|"reads products"| node_product_db
node_payment_api -->|"delegates"| node_payment_flow
node_payment_flow -->|"stores payment"| node_payment_db
node_payment_flow -.->|"notifies payment"| node_notification_api
node_notification_api -->|"delegates"| node_notification_flow
node_notification_flow -->|"stores notice"| node_notification_db
node_user_auth -->|"creates user"| node_user_data
node_user_auth -->|"checks credentials"| node_user_db
node_user_data -->|"persists user"| node_user_db

click node_gateway "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/app.module.ts"
click node_gateway_auth "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/auth/auth.controller.ts"
click node_gateway_auth_service "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/auth/auth.service.ts"
click node_gateway_order "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/order/order.controller.ts"
click node_gateway_product "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/product/product.controller.ts"
click node_user_auth "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/auth/auth.service.ts"
click node_user_data "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/user/user.service.ts"
click node_user_db "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/user/entity/user.entity.ts"
click node_order_api "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/order/src/order/order.controller.ts"
click node_order_flow "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/order/src/order/order.service.ts"
click node_order_db "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/order/src/order/entity/order.entity.ts"
click node_product_api "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/product/src/product/product.controller.ts"
click node_product_flow "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/product/src/product/product.service.ts"
click node_product_db "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/product/src/product/entity/product.entity.ts"
click node_payment_api "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/payment/src/payment/payment.controller.ts"
click node_payment_flow "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/payment/src/payment/payment.service.ts"
click node_payment_db "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/payment/src/payment/entity/payment.entity.ts"
click node_notification_api "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/notification/src/notification/notification.controller.ts"
click node_notification_flow "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/notification/src/notification/notification.service.ts"
click node_notification_db "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/notification/src/notification/entity/notification.entity.ts"
click node_rpc_contracts "https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/libs/common/src/grpc/proto/index.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,node_gateway_auth,node_gateway_auth_service,node_gateway_order,node_gateway_product,node_client toneBlue
class node_user_auth,node_user_data,node_user_db toneAmber
class node_order_api,node_order_flow,node_order_db,node_product_api,node_product_flow,node_product_db,node_payment_api,node_payment_flow,node_payment_db toneMint
class node_notification_api,node_notification_flow,node_notification_db toneRose
class node_rpc_contracts toneIndigo
```

## Components

### API Gateway

- [Gateway App](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/app.module.ts): `apps/gateway/src/app.module.ts`
- [Auth API](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/auth/auth.controller.ts): `apps/gateway/src/auth/auth.controller.ts`
- [Auth Proxy](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/auth/auth.service.ts): `apps/gateway/src/auth/auth.service.ts`
- [Order API](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/order/order.controller.ts): `apps/gateway/src/order/order.controller.ts`
- [Product API](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/gateway/src/product/product.controller.ts): `apps/gateway/src/product/product.controller.ts`

### Identity

- [User Authentication](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/auth/auth.service.ts): `apps/user/src/auth/auth.service.ts`
- [User Service](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/user/user.service.ts): `apps/user/src/user/user.service.ts`
- [User Database](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/user/src/user/entity/user.entity.ts): `apps/user/src/user/entity/user.entity.ts`

### Commerce Services

- [Order RPC](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/order/src/order/order.controller.ts): `apps/order/src/order/order.controller.ts`
- [Order Workflow](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/order/src/order/order.service.ts): `apps/order/src/order/order.service.ts`
- [Order Store](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/order/src/order/entity/order.entity.ts): `apps/order/src/order/entity/order.entity.ts`
- [Product RPC](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/product/src/product/product.controller.ts): `apps/product/src/product/product.controller.ts`
- [Product Catalog](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/product/src/product/product.service.ts): `apps/product/src/product/product.service.ts`
- [Product Store](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/product/src/product/entity/product.entity.ts): `apps/product/src/product/entity/product.entity.ts`
- [Payment RPC](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/payment/src/payment/payment.controller.ts): `apps/payment/src/payment/payment.controller.ts`
- [Payment Processing](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/payment/src/payment/payment.service.ts): `apps/payment/src/payment/payment.service.ts`
- [Payment Store](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/payment/src/payment/entity/payment.entity.ts): `apps/payment/src/payment/entity/payment.entity.ts`

### Notifications

- [Notification RPC](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/notification/src/notification/notification.controller.ts): `apps/notification/src/notification/notification.controller.ts`
- [Notification Service](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/notification/src/notification/notification.service.ts): `apps/notification/src/notification/notification.service.ts`
- [Notification Store](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/apps/notification/src/notification/entity/notification.entity.ts): `apps/notification/src/notification/entity/notification.entity.ts`

### Shared RPC

- [gRPC Contracts](https://github.com/codefactory-co/fastcampus-nestjs-part2/blob/main/libs/common/src/grpc/proto/index.ts): `libs/common/src/grpc/proto/index.ts`

### Other components

- **API Client**

## Connections

- API Client → Auth API: requests auth (evidence: `apps/gateway/src/auth/auth.controller.ts`)
- API Client → Order API: submits order (evidence: `apps/gateway/src/order/order.controller.ts`)
- Auth API → Auth Proxy: calls (evidence: `apps/gateway/src/auth/auth.controller.ts`)
- Auth Proxy → User Authentication: gRPC auth (evidence: `apps/gateway/src/auth/auth.service.ts`)
- API Client → Product API: requests products (evidence: `apps/gateway/src/product/product.controller.ts`)
- Order API → Order RPC: routes order
- Product API → Product RPC: routes catalog
- Order RPC → Order Workflow: delegates (evidence: `apps/order/src/order/order.controller.ts`)
- Order Workflow → User Service: fetches user (evidence: `apps/order/src/order/order.service.ts`)
- Order Workflow → Product Catalog: fetches products (evidence: `apps/order/src/order/order.service.ts`)
- Order Workflow → Payment RPC: requests payment (evidence: `apps/order/src/order/order.service.ts`)
- Order Workflow → Order Store: writes order (evidence: `apps/order/src/order/order.service.ts`)
- Product RPC → Product Catalog: delegates (evidence: `apps/product/src/product/product.controller.ts`)
- Product Catalog → Product Store: reads products (evidence: `apps/product/src/product/product.service.ts`)
- Payment RPC → Payment Processing: delegates (evidence: `apps/payment/src/payment/payment.controller.ts`)
- Payment Processing → Payment Store: stores payment (evidence: `apps/payment/src/payment/payment.service.ts`)
- Payment Processing → Notification RPC: notifies payment
- Notification RPC → Notification Service: delegates (evidence: `apps/notification/src/notification/notification.controller.ts`)
- Notification Service → Notification Store: stores notice (evidence: `apps/notification/src/notification/notification.service.ts`)
- User Authentication → User Service: creates user (evidence: `apps/user/src/auth/auth.service.ts`)
- User Authentication → User Database: checks credentials (evidence: `apps/user/src/auth/auth.service.ts`)
- User Service → User Database: persists user (evidence: `apps/user/src/user/user.service.ts`)
