# sopet-co-ltd/new-sopet-backend architecture

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

- Interactive diagram: https://gitdiagram.com/sopet-co-ltd/new-sopet-backend
- Repository: https://github.com/sopet-co-ltd/new-sopet-backend

## Overview

SOPET Backend is a NestJS GraphQL API for a multi-vendor commerce platform, with limited REST endpoints for webhooks and vendor integrations. The principal customer flow is authenticate, discover products, manage a cart, place an order, pay, and track fulfillment; vendors manage stores, catalog and fulfillment, while admins oversee platform operations. The graph also preserves documented search, reviews, promotions, payouts, uploads, and transactional email. README documents the resolver-to-service-to-PostgreSQL pattern; sampled code confirms selected module responsibilities, but not every module-to-module connection.

Main entry points: [`src/graphql/graphql.module.ts`](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/graphql/graphql.module.ts) (GraphQL API), [`src/database/database.module.ts`](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/database/database.module.ts) (PostgreSQL), [`src/modules/public-api/public-api.controller.ts`](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/public-api/public-api.controller.ts) (Vendor public API), [`src/modules/orders/orders.service.ts`](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/orders/orders.service.ts) (Order management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_graphql["GraphQL API<br/>[graphql.module.ts]"]
  node_public_api["Vendor public API"]
  node_auth["Authentication<br/>[auth.service.ts]"]
end

subgraph group_commerce["Commerce workflow"]
  node_products["Product catalog"]
  node_search["Smart search<br/>[search.service.ts]"]
  node_cart["Shopping cart<br/>[cart.service.ts]"]
  node_orders["Order management<br/>[orders.service.ts]"]
  node_fulfillment["Order fulfillment"]
  node_payments["Payments"]
  node_stores["Multi-vendor stores<br/>[stores.service.ts]"]
end

subgraph group_platform["Platform capabilities"]
  node_promotions["Promotions and sales"]
  node_reviews["Reviews<br/>[reviews.service.ts]"]
  node_payouts["Vendor payouts<br/>[payouts.service.ts]"]
  node_analytics["Analytics"]
  node_uploads["Image uploads"]
  node_email["Transactional email<br/>[email.service.ts]"]
end

subgraph group_runtime["Persistence and runtime"]
  node_database[("PostgreSQL<br/>[database.module.ts]")]
  node_redis_queue["Redis and BullMQ<br/>[queue.module.ts]"]
end

node_customer(("Customer or vendor"))
node_omise["Omise gateway"]
node_object_storage["S3-compatible storage"]
node_resend["Resend"]

node_customer -->|"sends requests"| node_graphql
node_graphql -->|"dispatches auth"| node_auth
node_graphql -->|"dispatches catalog"| node_products
node_graphql -->|"dispatches search"| node_search
node_graphql -->|"dispatches cart"| node_cart
node_graphql -->|"dispatches orders"| node_orders
node_graphql -->|"dispatches payments"| node_payments
node_graphql -->|"dispatches store ops"| node_stores
node_graphql -->|"dispatches promotions"| node_promotions
node_graphql -->|"dispatches reviews"| node_reviews
node_graphql -->|"dispatches payouts"| node_payouts
node_graphql -->|"dispatches analytics"| node_analytics
node_graphql -->|"dispatches uploads"| node_uploads
node_public_api -->|"calls catalog"| node_products
node_public_api -->|"calls orders"| node_orders
node_public_api -->|"calls fulfillment"| node_fulfillment
node_public_api -->|"calls reviews"| node_reviews
node_public_api -->|"calls analytics"| node_analytics
node_public_api -->|"imports store data"| node_stores
node_orders -->|"delegates fulfillment"| node_fulfillment
node_payments -->|"integrates payments"| node_omise
node_uploads -->|"uploads images"| node_object_storage
node_email -->|"sends email"| node_resend
node_search -.->|"queues embeddings"| node_redis_queue
node_auth -->|"reads and writes"| node_database
node_products -->|"reads and writes"| node_database
node_search -->|"queries catalog"| node_database
node_cart -->|"reads and writes"| node_database
node_orders -->|"reads and writes"| node_database
node_fulfillment -->|"updates orders"| node_database
node_payments -->|"records payments"| node_database
node_stores -->|"reads and writes"| node_database
node_promotions -->|"reads and writes"| node_database
node_reviews -->|"reads and writes"| node_database
node_payouts -->|"reads and writes"| node_database
node_analytics -->|"queries metrics"| node_database

click node_graphql "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/graphql/graphql.module.ts"
click node_public_api "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/public-api/public-api.controller.ts"
click node_auth "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/auth/auth.service.ts"
click node_products "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/products/products.service.ts"
click node_search "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/search/search.service.ts"
click node_cart "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/cart/cart.service.ts"
click node_orders "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/orders/orders.service.ts"
click node_fulfillment "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/orders/order-fulfillment.service.ts"
click node_payments "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/payments/payments.service.ts"
click node_stores "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/stores/stores.service.ts"
click node_promotions "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/promotions/promotions.service.ts"
click node_reviews "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/reviews/reviews.service.ts"
click node_payouts "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/payouts/payouts.service.ts"
click node_analytics "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/analytics/analytics.service.ts"
click node_uploads "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/storage/storage.resolver.ts"
click node_email "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/email/email.service.ts"
click node_database "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/database/database.module.ts"
click node_redis_queue "https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/queue/queue.module.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_graphql,node_public_api,node_auth toneBlue
class node_products,node_search,node_cart,node_orders,node_fulfillment,node_payments,node_stores,node_object_storage toneAmber
class node_promotions,node_reviews,node_payouts,node_analytics,node_uploads,node_email toneMint
class node_database,node_redis_queue toneRose
class node_customer,node_omise,node_resend toneIndigo
```

## Components

### API and identity

- [GraphQL API](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/graphql/graphql.module.ts): `src/graphql/graphql.module.ts`
- [Vendor public API](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/public-api/public-api.controller.ts): `src/modules/public-api/public-api.controller.ts`
- [Authentication](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/auth/auth.service.ts): `src/modules/auth/auth.service.ts`

### Commerce workflow

- [Product catalog](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/products/products.service.ts): `src/modules/products/products.service.ts`
- [Smart search](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/search/search.service.ts): `src/modules/search/search.service.ts`
- [Shopping cart](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/cart/cart.service.ts): `src/modules/cart/cart.service.ts`
- [Order management](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/orders/orders.service.ts): `src/modules/orders/orders.service.ts`
- [Order fulfillment](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/orders/order-fulfillment.service.ts): `src/modules/orders/order-fulfillment.service.ts`
- [Payments](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/payments/payments.service.ts): `src/modules/payments/payments.service.ts`
- [Multi-vendor stores](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/stores/stores.service.ts): `src/modules/stores/stores.service.ts`

### Platform capabilities

- [Promotions and sales](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/promotions/promotions.service.ts): `src/modules/promotions/promotions.service.ts`
- [Reviews](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/reviews/reviews.service.ts): `src/modules/reviews/reviews.service.ts`
- [Vendor payouts](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/payouts/payouts.service.ts): `src/modules/payouts/payouts.service.ts`
- [Analytics](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/analytics/analytics.service.ts): `src/modules/analytics/analytics.service.ts`
- [Image uploads](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/storage/storage.resolver.ts): `src/modules/storage/storage.resolver.ts`
- [Transactional email](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/email/email.service.ts): `src/modules/email/email.service.ts`

### Persistence and runtime

- [PostgreSQL](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/database/database.module.ts): `src/database/database.module.ts`
- [Redis and BullMQ](https://github.com/sopet-co-ltd/new-sopet-backend/blob/main/src/modules/queue/queue.module.ts): `src/modules/queue/queue.module.ts`

### Other components

- **Customer or vendor**
- **Omise gateway**
- **S3-compatible storage**
- **Resend**

## Connections

- Customer or vendor → GraphQL API: sends requests
- GraphQL API → Authentication: dispatches auth
- GraphQL API → Product catalog: dispatches catalog
- GraphQL API → Smart search: dispatches search
- GraphQL API → Shopping cart: dispatches cart
- GraphQL API → Order management: dispatches orders
- GraphQL API → Payments: dispatches payments
- GraphQL API → Multi-vendor stores: dispatches store ops
- GraphQL API → Promotions and sales: dispatches promotions
- GraphQL API → Reviews: dispatches reviews
- GraphQL API → Vendor payouts: dispatches payouts
- GraphQL API → Analytics: dispatches analytics
- GraphQL API → Image uploads: dispatches uploads
- Vendor public API → Product catalog: calls catalog
- Vendor public API → Order management: calls orders
- Vendor public API → Order fulfillment: calls fulfillment
- Vendor public API → Reviews: calls reviews
- Vendor public API → Analytics: calls analytics
- Vendor public API → Multi-vendor stores: imports store data
- Order management → Order fulfillment: delegates fulfillment
- Payments → Omise gateway: integrates payments
- Image uploads → S3-compatible storage: uploads images
- Transactional email → Resend: sends email
- Smart search → Redis and BullMQ: queues embeddings
- Authentication → PostgreSQL: reads and writes
- Product catalog → PostgreSQL: reads and writes
- Smart search → PostgreSQL: queries catalog
- Shopping cart → PostgreSQL: reads and writes
- Order management → PostgreSQL: reads and writes
- Order fulfillment → PostgreSQL: updates orders
- Payments → PostgreSQL: records payments
- Multi-vendor stores → PostgreSQL: reads and writes
- Promotions and sales → PostgreSQL: reads and writes
- Reviews → PostgreSQL: reads and writes
- Vendor payouts → PostgreSQL: reads and writes
- Analytics → PostgreSQL: queries metrics
