# tfs-here/trusttradebd architecture

> Architecture diagram of the GitHub repository tfs-here/trusttradebd, 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/tfs-here/trusttradebd
- Repository: https://github.com/tfs-here/trusttradebd

## Overview

TrustTrade BD is a buyer–seller marketplace whose central workflow is listing and discovering products, placing and paying for an order, shipping it, then confirming delivery to release escrow funds. Disputes and admin decisions provide an alternate resolution path; the product also includes wallets, chat, reviews, Q&A, uploads, and platform controls. The graph follows documented capabilities and sampled route/controller/service wiring; several feature implementations were not sampled, so uncertain internal calls are omitted.

Main entry points: [`client/src/App.jsx`](https://github.com/tfs-here/trusttradebd/blob/main/client/src/App.jsx) (Web application), [`server/models`](https://github.com/tfs-here/trusttradebd/tree/main/server/models) (Domain models), [`server/server.js`](https://github.com/tfs-here/trusttradebd/blob/main/server/server.js) (API server), [`server/services/order.service.js`](https://github.com/tfs-here/trusttradebd/blob/main/server/services/order.service.js) (Order lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Marketplace client"]
  node_app["Web application<br/>[App.jsx]"]
  node_buyer_pages["Buyer pages"]
  node_seller_pages["Seller pages"]
  node_admin_pages["Admin pages"]
  node_auth_context["Auth context<br/>[AuthContext.jsx]"]
  node_cart_context["Cart context<br/>[CartContext.jsx]"]
  node_api_client["API client<br/>[apiClient.js]"]
  node_product_api["Product API<br/>[productApi.js]"]
  node_order_api["Order API<br/>[orderApi.js]"]
  node_auth_api["Auth API<br/>[apiClient.js]"]
end

subgraph group_commerce["Commerce and escrow"]
  node_server["API server<br/>[server.js]"]
  node_product_routes["Product routes<br/>[product.routes.js]"]
  node_product_controller["Product management"]
  node_order_routes["Order routes<br/>[order.routes.js]"]
  node_order_controller["Order handling"]
  node_order_service["Order lifecycle<br/>[order.service.js]"]
  node_payment["Payment handling"]
  node_wallet["Wallet handling"]
  node_escrow["Escrow accounting<br/>[escrow.js]"]
end

subgraph group_trust["Trust and operations"]
  node_trust_features["Trust features"]
  node_admin_routes["Admin routes<br/>[admin.routes.js]"]
  node_admin_controller["Admin controls"]
  node_auth_routes["Authentication routes<br/>[auth.routes.js]"]
  node_auth_controller["Authentication<br/>[auth.controller.js]"]
end

subgraph group_integrations["Integrations and data"]
  node_models["Domain models"]
  node_database[("MongoDB<br/>[db.js]")]
  node_sslcommerz["SSLCommerz"]
  node_pathao["Pathao courier"]
  node_cloudinary["Cloudinary storage<br/>[cloudinary.js]"]
  node_email["Email service<br/>[sendEmail.js]"]
end

node_buyer(("Buyer"))
node_seller(("Seller"))
node_admin(("Admin"))

node_buyer -->|"uses"| node_app
node_seller -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"routes to"| node_buyer_pages
node_app -->|"routes to"| node_seller_pages
node_app -->|"routes to"| node_admin_pages
node_app -->|"provides"| node_auth_context
node_app -->|"provides"| node_cart_context
node_buyer_pages -->|"requests"| node_product_api
node_buyer_pages -->|"requests"| node_order_api
node_seller_pages -->|"requests"| node_product_api
node_admin_pages -->|"requests"| node_api_client
node_product_api -->|"uses"| node_api_client
node_order_api -->|"uses"| node_api_client
node_auth_context -->|"uses"| node_auth_api
node_server -->|"mounts"| node_product_routes
node_server -->|"mounts"| node_order_routes
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_admin_routes
node_product_routes -->|"dispatches"| node_product_controller
node_order_routes -->|"dispatches"| node_order_controller
node_auth_routes -->|"dispatches"| node_auth_controller
node_admin_routes -->|"dispatches"| node_admin_controller
node_product_controller -->|"reads and writes"| node_models
node_order_controller -->|"invokes"| node_order_service
node_order_service -->|"reads and writes"| node_models
node_order_service -->|"accounts funds"| node_escrow
node_payment -->|"initiates payment"| node_sslcommerz
node_order_service -.->|"uses delivery"| node_pathao
node_wallet -->|"reads and writes"| node_models
node_escrow -->|"records transactions"| node_models
node_trust_features -->|"supports features"| node_models
node_admin_controller -->|"manages records"| node_models
node_auth_controller -->|"reads and writes"| node_models
node_auth_controller -->|"sends notices"| node_email
node_database -->|"connects"| node_models
node_cloudinary -->|"stores images"| node_cloudinary

click node_app "https://github.com/tfs-here/trusttradebd/blob/main/client/src/App.jsx"
click node_buyer_pages "https://github.com/tfs-here/trusttradebd/tree/main/client/src/pages/buyer"
click node_seller_pages "https://github.com/tfs-here/trusttradebd/tree/main/client/src/pages/seller"
click node_admin_pages "https://github.com/tfs-here/trusttradebd/tree/main/client/src/pages/admin"
click node_auth_context "https://github.com/tfs-here/trusttradebd/blob/main/client/src/context/AuthContext.jsx"
click node_cart_context "https://github.com/tfs-here/trusttradebd/blob/main/client/src/context/CartContext.jsx"
click node_api_client "https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/apiClient.js"
click node_product_api "https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/productApi.js"
click node_order_api "https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/orderApi.js"
click node_auth_api "https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/apiClient.js"
click node_server "https://github.com/tfs-here/trusttradebd/blob/main/server/server.js"
click node_product_routes "https://github.com/tfs-here/trusttradebd/blob/main/server/routes/product.routes.js"
click node_product_controller "https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/product.controller.js"
click node_order_routes "https://github.com/tfs-here/trusttradebd/blob/main/server/routes/order.routes.js"
click node_order_controller "https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/order.controller.js"
click node_order_service "https://github.com/tfs-here/trusttradebd/blob/main/server/services/order.service.js"
click node_payment "https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/payment.controller.js"
click node_wallet "https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/wallet.controller.js"
click node_escrow "https://github.com/tfs-here/trusttradebd/blob/main/server/utils/escrow.js"
click node_trust_features "https://github.com/tfs-here/trusttradebd/tree/main/server/routes"
click node_admin_routes "https://github.com/tfs-here/trusttradebd/blob/main/server/routes/admin.routes.js"
click node_admin_controller "https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/admin.controller.js"
click node_auth_routes "https://github.com/tfs-here/trusttradebd/blob/main/server/routes/auth.routes.js"
click node_auth_controller "https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/auth.controller.js"
click node_models "https://github.com/tfs-here/trusttradebd/tree/main/server/models"
click node_database "https://github.com/tfs-here/trusttradebd/blob/main/server/config/db.js"
click node_cloudinary "https://github.com/tfs-here/trusttradebd/blob/main/server/config/cloudinary.js"
click node_email "https://github.com/tfs-here/trusttradebd/blob/main/server/utils/sendEmail.js"

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_app,node_buyer_pages,node_seller_pages,node_admin_pages,node_auth_context,node_cart_context,node_api_client,node_product_api,node_order_api,node_auth_api toneBlue
class node_server,node_product_routes,node_product_controller,node_order_routes,node_order_controller,node_order_service,node_payment,node_wallet,node_escrow toneAmber
class node_trust_features,node_admin_routes,node_admin_controller,node_auth_routes,node_auth_controller toneMint
class node_models,node_database,node_sslcommerz,node_pathao,node_cloudinary,node_email toneRose
class node_buyer,node_seller,node_admin toneIndigo
```

## Components

### Marketplace client

- [Web application](https://github.com/tfs-here/trusttradebd/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Buyer pages](https://github.com/tfs-here/trusttradebd/tree/main/client/src/pages/buyer): `client/src/pages/buyer`
- [Seller pages](https://github.com/tfs-here/trusttradebd/tree/main/client/src/pages/seller): `client/src/pages/seller`
- [Admin pages](https://github.com/tfs-here/trusttradebd/tree/main/client/src/pages/admin): `client/src/pages/admin`
- [Auth context](https://github.com/tfs-here/trusttradebd/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Cart context](https://github.com/tfs-here/trusttradebd/blob/main/client/src/context/CartContext.jsx): `client/src/context/CartContext.jsx`
- [API client](https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/apiClient.js): `client/src/api/apiClient.js`
- [Product API](https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/productApi.js): `client/src/api/productApi.js`
- [Order API](https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/orderApi.js): `client/src/api/orderApi.js`
- [Auth API](https://github.com/tfs-here/trusttradebd/blob/main/client/src/api/apiClient.js): `client/src/api/apiClient.js`

### Commerce and escrow

- [API server](https://github.com/tfs-here/trusttradebd/blob/main/server/server.js): `server/server.js`
- [Product routes](https://github.com/tfs-here/trusttradebd/blob/main/server/routes/product.routes.js): `server/routes/product.routes.js`
- [Product management](https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/product.controller.js): `server/controllers/product.controller.js`
- [Order routes](https://github.com/tfs-here/trusttradebd/blob/main/server/routes/order.routes.js): `server/routes/order.routes.js`
- [Order handling](https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/order.controller.js): `server/controllers/order.controller.js`
- [Order lifecycle](https://github.com/tfs-here/trusttradebd/blob/main/server/services/order.service.js): `server/services/order.service.js`
- [Payment handling](https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/payment.controller.js): `server/controllers/payment.controller.js`
- [Wallet handling](https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/wallet.controller.js): `server/controllers/wallet.controller.js`
- [Escrow accounting](https://github.com/tfs-here/trusttradebd/blob/main/server/utils/escrow.js): `server/utils/escrow.js`

### Trust and operations

- [Trust features](https://github.com/tfs-here/trusttradebd/tree/main/server/routes): `server/routes`
- [Admin routes](https://github.com/tfs-here/trusttradebd/blob/main/server/routes/admin.routes.js): `server/routes/admin.routes.js`
- [Admin controls](https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/admin.controller.js): `server/controllers/admin.controller.js`
- [Authentication routes](https://github.com/tfs-here/trusttradebd/blob/main/server/routes/auth.routes.js): `server/routes/auth.routes.js`
- [Authentication](https://github.com/tfs-here/trusttradebd/blob/main/server/controllers/auth.controller.js): `server/controllers/auth.controller.js`

### Integrations and data

- [Domain models](https://github.com/tfs-here/trusttradebd/tree/main/server/models): `server/models`
- [MongoDB](https://github.com/tfs-here/trusttradebd/blob/main/server/config/db.js): `server/config/db.js`
- **SSLCommerz**
- **Pathao courier**
- [Cloudinary storage](https://github.com/tfs-here/trusttradebd/blob/main/server/config/cloudinary.js): `server/config/cloudinary.js`
- [Email service](https://github.com/tfs-here/trusttradebd/blob/main/server/utils/sendEmail.js): `server/utils/sendEmail.js`

### Other components

- **Buyer**
- **Seller**
- **Admin**

## Connections

- Buyer → Web application: uses
- Seller → Web application: uses
- Admin → Web application: uses
- Web application → Buyer pages: routes to
- Web application → Seller pages: routes to
- Web application → Admin pages: routes to
- Web application → Auth context: provides
- Web application → Cart context: provides
- Buyer pages → Product API: requests
- Buyer pages → Order API: requests
- Seller pages → Product API: requests
- Admin pages → API client: requests
- Product API → API client: uses
- Order API → API client: uses
- Auth context → Auth API: uses
- API server → Product routes: mounts
- API server → Order routes: mounts
- API server → Authentication routes: mounts
- API server → Admin routes: mounts
- Product routes → Product management: dispatches
- Order routes → Order handling: dispatches
- Authentication routes → Authentication: dispatches
- Admin routes → Admin controls: dispatches
- Product management → Domain models: reads and writes
- Order handling → Order lifecycle: invokes
- Order lifecycle → Domain models: reads and writes
- Order lifecycle → Escrow accounting: accounts funds
- Payment handling → SSLCommerz: initiates payment
- Order lifecycle → Pathao courier: uses delivery
- Wallet handling → Domain models: reads and writes
- Escrow accounting → Domain models: records transactions
- Trust features → Domain models: supports features
- Admin controls → Domain models: manages records
- Authentication → Domain models: reads and writes
- Authentication → Email service: sends notices
- MongoDB → Domain models: connects
- Cloudinary storage → Cloudinary storage: stores images
