# samio11/craftify_server architecture

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

- Interactive diagram: https://gitdiagram.com/samio11/craftify_server
- Repository: https://github.com/samio11/craftify_server

## Overview

Cartify is an Express/TypeScript e-commerce API. Customers authenticate, browse products and categories, manage carts, and initiate checkout; sellers and administrators manage catalog data, while users can manage reviews. Payment callbacks update the payment flow through SSLCommerz. The graph follows documented capabilities and relationships visible in the excerpts or SOURCE INDEX; unsampled implementation details are represented only where the README supports them.

Main entry points: [`src/app/modules/payment/payment.services.ts`](https://github.com/samio11/craftify_server/blob/main/src/app/modules/payment/payment.services.ts) (Payment operations), [`src/app.ts`](https://github.com/samio11/craftify_server/blob/main/src/app.ts) (Express API), [`src/app/modules/product/product.service.ts`](https://github.com/samio11/craftify_server/blob/main/src/app/modules/product/product.service.ts) (Product management), [`src/app/modules/user/user.service.ts`](https://github.com/samio11/craftify_server/blob/main/src/app/modules/user/user.service.ts) (User management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; Access"]
  node_auth["Authentication<br/>[auth.controller.ts]"]
  node_authroutes["Auth routes<br/>[auth.routes.ts]"]
  node_authz["Role authorization<br/>[checkAuth.ts]"]
  node_users["User management<br/>[user.service.ts]"]
  node_userstore[("User records<br/>[user.model.ts]")]
end

subgraph group_catalog["Catalog &amp; Engagement"]
  node_products["Product management<br/>[product.service.ts]"]
  node_productstore[("Product records<br/>[products.model.ts]")]
  node_categories["Category management"]
  node_categorystore[("Category records<br/>[category.model.ts]")]
  node_reviews["Product reviews<br/>[review.services.ts]"]
  node_reviewstore[("Review records<br/>[review.model.ts]")]
end

subgraph group_commerce["Cart &amp; Payments"]
  node_cart["Cart operations<br/>[cart.services.ts]"]
  node_cartstore[("Cart records<br/>[cart.model.ts]")]
  node_payments["Payment operations"]
  node_paymentstore[("Payment records<br/>[payment.model.ts]")]
  node_ssl["SSLCommerz integration"]
end

subgraph group_platform["API Platform"]
  node_app["Express API<br/>[app.ts]"]
  node_query["Query builder<br/>[QueryBuilder.ts]"]
  node_uploads["Image upload config<br/>[multer.config.ts]"]
  node_errors["Error handling"]
end

node_customer(("Customer"))
node_seller(("Seller"))
node_admin(("Administrator"))
node_gateway{{"SSLCommerz gateway"}}

node_customer -->|"uses API"| node_app
node_seller -->|"uses API"| node_app
node_admin -->|"uses API"| node_app
node_app -->|"mounts API"| node_authroutes
node_authroutes -->|"routes to"| node_auth
node_auth -->|"authenticates user"| node_users
node_authz -->|"checks user"| node_userstore
node_app -->|"handles errors"| node_errors
node_products -->|"reads and writes"| node_productstore
node_products -->|"uses category"| node_categorystore
node_categories -->|"reads and writes"| node_categorystore
node_reviews -->|"reads and writes"| node_reviewstore
node_reviews -->|"uses products"| node_productstore
node_cart -->|"reads and writes"| node_cartstore
node_cart -->|"uses products"| node_productstore
node_cart -->|"initiates payment"| node_payments
node_payments -->|"reads and writes"| node_paymentstore
node_payments -->|"uses cart"| node_cartstore
node_payments -->|"uses products"| node_productstore
node_payments -->|"requests gateway"| node_ssl
node_ssl -->|"starts checkout"| node_gateway
node_users -->|"reads and writes"| node_userstore
node_products -->|"builds queries"| node_query
node_categories -->|"builds queries"| node_query
node_reviews -->|"builds queries"| node_query
node_users -->|"builds queries"| node_query
node_products -->|"uploads images"| node_uploads
node_categories -->|"uploads images"| node_uploads
node_users -->|"uploads profile image"| node_uploads

click node_app "https://github.com/samio11/craftify_server/blob/main/src/app.ts"
click node_auth "https://github.com/samio11/craftify_server/blob/main/src/app/modules/auth/auth.controller.ts"
click node_authroutes "https://github.com/samio11/craftify_server/blob/main/src/app/modules/auth/auth.routes.ts"
click node_authz "https://github.com/samio11/craftify_server/blob/main/src/app/middlewares/checkAuth.ts"
click node_users "https://github.com/samio11/craftify_server/blob/main/src/app/modules/user/user.service.ts"
click node_userstore "https://github.com/samio11/craftify_server/blob/main/src/app/modules/user/user.model.ts"
click node_products "https://github.com/samio11/craftify_server/blob/main/src/app/modules/product/product.service.ts"
click node_productstore "https://github.com/samio11/craftify_server/blob/main/src/app/modules/product/products.model.ts"
click node_categories "https://github.com/samio11/craftify_server/blob/main/src/app/modules/category/category.services.ts"
click node_categorystore "https://github.com/samio11/craftify_server/blob/main/src/app/modules/category/category.model.ts"
click node_reviews "https://github.com/samio11/craftify_server/blob/main/src/app/modules/review/review.services.ts"
click node_reviewstore "https://github.com/samio11/craftify_server/blob/main/src/app/modules/review/review.model.ts"
click node_cart "https://github.com/samio11/craftify_server/blob/main/src/app/modules/cart/cart.services.ts"
click node_cartstore "https://github.com/samio11/craftify_server/blob/main/src/app/modules/cart/cart.model.ts"
click node_payments "https://github.com/samio11/craftify_server/blob/main/src/app/modules/payment/payment.services.ts"
click node_paymentstore "https://github.com/samio11/craftify_server/blob/main/src/app/modules/payment/payment.model.ts"
click node_ssl "https://github.com/samio11/craftify_server/blob/main/src/app/modules/sslCommerz/sslCommer.service.ts"
click node_query "https://github.com/samio11/craftify_server/blob/main/src/app/utils/QueryBuilder.ts"
click node_uploads "https://github.com/samio11/craftify_server/blob/main/src/app/config/multer.config.ts"
click node_errors "https://github.com/samio11/craftify_server/blob/main/src/app/middlewares/globalErrorHandler.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_auth,node_authroutes,node_authz,node_users,node_userstore toneBlue
class node_products,node_productstore,node_categories,node_categorystore,node_reviews,node_reviewstore toneAmber
class node_cart,node_cartstore,node_payments,node_paymentstore,node_ssl toneMint
class node_app,node_query,node_uploads,node_errors toneRose
class node_customer,node_seller,node_admin,node_gateway toneIndigo
```

## Components

### Identity & Access

- [Authentication](https://github.com/samio11/craftify_server/blob/main/src/app/modules/auth/auth.controller.ts): `src/app/modules/auth/auth.controller.ts`
- [Auth routes](https://github.com/samio11/craftify_server/blob/main/src/app/modules/auth/auth.routes.ts): `src/app/modules/auth/auth.routes.ts`
- [Role authorization](https://github.com/samio11/craftify_server/blob/main/src/app/middlewares/checkAuth.ts): `src/app/middlewares/checkAuth.ts`
- [User management](https://github.com/samio11/craftify_server/blob/main/src/app/modules/user/user.service.ts): `src/app/modules/user/user.service.ts`
- [User records](https://github.com/samio11/craftify_server/blob/main/src/app/modules/user/user.model.ts): `src/app/modules/user/user.model.ts`

### Catalog & Engagement

- [Product management](https://github.com/samio11/craftify_server/blob/main/src/app/modules/product/product.service.ts): `src/app/modules/product/product.service.ts`
- [Product records](https://github.com/samio11/craftify_server/blob/main/src/app/modules/product/products.model.ts): `src/app/modules/product/products.model.ts`
- [Category management](https://github.com/samio11/craftify_server/blob/main/src/app/modules/category/category.services.ts): `src/app/modules/category/category.services.ts`
- [Category records](https://github.com/samio11/craftify_server/blob/main/src/app/modules/category/category.model.ts): `src/app/modules/category/category.model.ts`
- [Product reviews](https://github.com/samio11/craftify_server/blob/main/src/app/modules/review/review.services.ts): `src/app/modules/review/review.services.ts`
- [Review records](https://github.com/samio11/craftify_server/blob/main/src/app/modules/review/review.model.ts): `src/app/modules/review/review.model.ts`

### Cart & Payments

- [Cart operations](https://github.com/samio11/craftify_server/blob/main/src/app/modules/cart/cart.services.ts): `src/app/modules/cart/cart.services.ts`
- [Cart records](https://github.com/samio11/craftify_server/blob/main/src/app/modules/cart/cart.model.ts): `src/app/modules/cart/cart.model.ts`
- [Payment operations](https://github.com/samio11/craftify_server/blob/main/src/app/modules/payment/payment.services.ts): `src/app/modules/payment/payment.services.ts`
- [Payment records](https://github.com/samio11/craftify_server/blob/main/src/app/modules/payment/payment.model.ts): `src/app/modules/payment/payment.model.ts`
- [SSLCommerz integration](https://github.com/samio11/craftify_server/blob/main/src/app/modules/sslCommerz/sslCommer.service.ts): `src/app/modules/sslCommerz/sslCommer.service.ts`

### API Platform

- [Express API](https://github.com/samio11/craftify_server/blob/main/src/app.ts): `src/app.ts`
- [Query builder](https://github.com/samio11/craftify_server/blob/main/src/app/utils/QueryBuilder.ts): `src/app/utils/QueryBuilder.ts`
- [Image upload config](https://github.com/samio11/craftify_server/blob/main/src/app/config/multer.config.ts): `src/app/config/multer.config.ts`
- [Error handling](https://github.com/samio11/craftify_server/blob/main/src/app/middlewares/globalErrorHandler.ts): `src/app/middlewares/globalErrorHandler.ts`

### Other components

- **Customer**
- **Seller**
- **Administrator**
- **SSLCommerz gateway**

## Connections

- Customer → Express API: uses API
- Seller → Express API: uses API
- Administrator → Express API: uses API
- Express API → Auth routes: mounts API (evidence: `src/app.ts`)
- Auth routes → Authentication: routes to (evidence: `src/app/modules/auth/auth.routes.ts`)
- Authentication → User management: authenticates user
- Role authorization → User records: checks user (evidence: `src/app/middlewares/checkAuth.ts`)
- Express API → Error handling: handles errors (evidence: `src/app.ts`)
- Product management → Product records: reads and writes (evidence: `src/app/modules/product/product.service.ts`)
- Product management → Category records: uses category (evidence: `src/app/modules/product/product.service.ts`)
- Category management → Category records: reads and writes (evidence: `src/app/modules/category/category.services.ts`)
- Product reviews → Review records: reads and writes (evidence: `src/app/modules/review/review.services.ts`)
- Product reviews → Product records: uses products (evidence: `src/app/modules/review/review.services.ts`)
- Cart operations → Cart records: reads and writes (evidence: `src/app/modules/cart/cart.services.ts`)
- Cart operations → Product records: uses products (evidence: `src/app/modules/cart/cart.services.ts`)
- Cart operations → Payment operations: initiates payment (evidence: `src/app/modules/cart/cart.services.ts`)
- Payment operations → Payment records: reads and writes (evidence: `src/app/modules/payment/payment.services.ts`)
- Payment operations → Cart records: uses cart (evidence: `src/app/modules/payment/payment.services.ts`)
- Payment operations → Product records: uses products (evidence: `src/app/modules/payment/payment.services.ts`)
- Payment operations → SSLCommerz integration: requests gateway (evidence: `src/app/modules/payment/payment.services.ts`)
- SSLCommerz integration → SSLCommerz gateway: starts checkout
- User management → User records: reads and writes (evidence: `src/app/modules/user/user.service.ts`)
- Product management → Query builder: builds queries (evidence: `src/app/modules/product/product.service.ts`)
- Category management → Query builder: builds queries (evidence: `src/app/modules/category/category.services.ts`)
- Product reviews → Query builder: builds queries (evidence: `src/app/modules/review/review.services.ts`)
- User management → Query builder: builds queries (evidence: `src/app/modules/user/user.service.ts`)
- Product management → Image upload config: uploads images
- Category management → Image upload config: uploads images
- User management → Image upload config: uploads profile image
