# usmonabdullaev/smarttj-backend architecture

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

- Interactive diagram: https://gitdiagram.com/usmonabdullaev/smarttj-backend
- Repository: https://github.com/usmonabdullaev/smarttj-backend

## Overview

SmartTJ is a marketplace REST API serving shoppers, partners, and administrators. The shopper journey centers on browsing and searching the catalog, managing a cart, placing an order, and paying through the Alif integration; accounts, delivery regions, and reviews support that journey. Separate partner and admin surfaces manage listings, fulfillment, moderation, and reporting. The README documents these capabilities and the principal integrations; many implementation files were not sampled, so subsystem-level links are limited to documented relationships.

Main entry points: [`src/bullmq`](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/bullmq) (Background jobs), [`src/modules/orders`](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/orders) (Order checkout), [`src/modules/reviews/reviews.service.ts`](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/modules/reviews/reviews.service.ts) (Customer reviews), [`src/modules/admin`](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/admin) (Admin operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Shopper marketplace"]
  node_catalog["Product catalog"]
  node_search["Catalog search"]
  node_cart["Shopping cart"]
  node_orders["Order checkout"]
  node_payments["Payment gateway"]
  node_reviews["Customer reviews<br/>[reviews.service.ts]"]
end

subgraph group_operations["Partner and admin"]
  node_partner_ops["Partner operations"]
  node_admin_ops["Admin operations"]
  node_support["Customer support"]
end

subgraph group_platform["Identity and data"]
  node_auth["Authentication"]
  node_authorization["Access guards<br/>[roles.guard.ts]"]
  node_prisma["Database access<br/>[prisma.service.ts]"]
end

subgraph group_integrations["External services"]
  node_alif["Alif acquiring"]
  node_sms["SMS gateway"]
  node_cloudinary["Media storage"]
  node_ai["AI services<br/>[ai.service.ts]"]
end

subgraph group_background["Async capabilities"]
  node_queues["Background jobs"]
  node_notifications["Notifications"]
  node_pdf["PDF generation<br/>[pdf.service.ts]"]
end

node_shopper(("Shopper"))
node_partner(("Partner"))
node_admin(("Administrator"))

node_shopper -->|"browses"| node_catalog
node_shopper -->|"searches"| node_search
node_shopper -->|"manages cart"| node_cart
node_shopper -->|"checks out"| node_orders
node_shopper -->|"initiates payment"| node_payments
node_payments -->|"uses gateway"| node_alif
node_shopper -->|"reviews products"| node_reviews
node_partner -->|"manages store"| node_partner_ops
node_admin -->|"administers platform"| node_admin_ops
node_admin_ops -->|"uploads media"| node_cloudinary
node_admin_ops -->|"queues moderation"| node_queues
node_partner_ops -.->|"queues notifications"| node_queues
node_shopper -->|"requests support"| node_support
node_support -->|"uses AI support"| node_ai
node_auth -.->|"sends OTP"| node_sms
node_shopper -->|"authenticates"| node_auth
node_authorization -.->|"guards routes"| node_auth
node_orders -->|"exports receipts"| node_pdf
node_catalog -.->|"reads catalog data"| node_prisma
node_orders -.->|"persists orders"| node_prisma
node_reviews -->|"queues moderation"| node_queues
node_reviews -->|"reads and writes"| node_prisma
node_queues -.->|"dispatches jobs"| node_notifications

click node_catalog "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/modules/products/products.service.ts"
click node_search "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/search"
click node_cart "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/carts"
click node_orders "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/orders"
click node_payments "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/payments"
click node_reviews "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/modules/reviews/reviews.service.ts"
click node_partner_ops "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/partner"
click node_admin_ops "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/admin"
click node_support "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/support"
click node_auth "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/auth"
click node_authorization "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/auth/guards/roles.guard.ts"
click node_prisma "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/database/prisma/prisma.service.ts"
click node_sms "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/sms/providers/smsgate.provider.ts"
click node_cloudinary "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/cloudinary/cloudinary.service.ts"
click node_ai "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/ai/ai.service.ts"
click node_queues "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/bullmq"
click node_notifications "https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/bullmq/notification"
click node_pdf "https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/pdf/pdf.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_catalog,node_search,node_cart,node_orders,node_payments,node_reviews toneBlue
class node_partner_ops,node_admin_ops,node_support toneAmber
class node_auth,node_authorization,node_prisma toneMint
class node_alif,node_sms,node_cloudinary,node_ai toneRose
class node_queues,node_notifications,node_pdf,node_shopper,node_partner,node_admin toneIndigo
```

## Components

### Shopper marketplace

- [Product catalog](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/modules/products/products.service.ts): `src/modules/products/products.service.ts`
- [Catalog search](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/search): `src/modules/search`
- [Shopping cart](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/carts): `src/modules/carts`
- [Order checkout](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/orders): `src/modules/orders`
- [Payment gateway](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/payments): `src/modules/payments`
- [Customer reviews](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/modules/reviews/reviews.service.ts): `src/modules/reviews/reviews.service.ts`

### Partner and admin

- [Partner operations](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/partner): `src/modules/partner`
- [Admin operations](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/admin): `src/modules/admin`
- [Customer support](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/support): `src/modules/support`

### Identity and data

- [Authentication](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/modules/auth): `src/modules/auth`
- [Access guards](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/auth/guards/roles.guard.ts): `src/auth/guards/roles.guard.ts`
- [Database access](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/database/prisma/prisma.service.ts): `src/database/prisma/prisma.service.ts`

### External services

- **Alif acquiring**
- [SMS gateway](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/sms/providers/smsgate.provider.ts): `src/sms/providers/smsgate.provider.ts`
- [Media storage](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/cloudinary/cloudinary.service.ts): `src/cloudinary/cloudinary.service.ts`
- [AI services](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/ai/ai.service.ts): `src/ai/ai.service.ts`

### Async capabilities

- [Background jobs](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/bullmq): `src/bullmq`
- [Notifications](https://github.com/usmonabdullaev/smarttj-backend/tree/main/src/bullmq/notification): `src/bullmq/notification`
- [PDF generation](https://github.com/usmonabdullaev/smarttj-backend/blob/main/src/pdf/pdf.service.ts): `src/pdf/pdf.service.ts`

### Other components

- **Shopper**
- **Partner**
- **Administrator**

## Connections

- Shopper → Product catalog: browses
- Shopper → Catalog search: searches
- Shopper → Shopping cart: manages cart
- Shopper → Order checkout: checks out
- Shopper → Payment gateway: initiates payment
- Payment gateway → Alif acquiring: uses gateway
- Shopper → Customer reviews: reviews products
- Partner → Partner operations: manages store
- Administrator → Admin operations: administers platform
- Admin operations → Media storage: uploads media
- Admin operations → Background jobs: queues moderation
- Partner operations → Background jobs: queues notifications
- Shopper → Customer support: requests support
- Customer support → AI services: uses AI support
- Authentication → SMS gateway: sends OTP
- Shopper → Authentication: authenticates
- Access guards → Authentication: guards routes
- Order checkout → PDF generation: exports receipts
- Product catalog → Database access: reads catalog data
- Order checkout → Database access: persists orders
- Customer reviews → Background jobs: queues moderation (evidence: `src/modules/reviews/reviews.service.ts`)
- Customer reviews → Database access: reads and writes (evidence: `src/modules/reviews/reviews.service.ts`)
- Background jobs → Notifications: dispatches jobs
