Shop It Docs
Developer ResourcescatalogBrand

Brand Module Backend Documentation

Backend architecture and invariants for catalog brand flows.

Summary

The brand module is a standalone catalog entity for IT Mart storefront filtering and merchandising.

Data Model

brand

ColumnTypeNullableNotes
idserialnoPrimary key
namevarchar(120)noUnique
slugvarchar(120)noUnique
image_urlvarchar(500)noBrand logo
is_visiblebooleannoStorefront display toggle
orderintegernoDisplay sort order
product_kindbrand_product_kind enumyesphysical, digital, both, or null
timestampscreated_at, updated_at

Indexes

IndexTypeColumns
brand_name_idxuniquename
brand_name_trgm_idxginname
brand_visible_idxbtreeis_visible
brand_order_idxbtreeorder
brand_product_kind_idxbtreeproduct_kind

brand_slug_history

  • old slug continuity on rename

productKind enum values

PostgreSQL enum brand_product_kind: 'physical', 'digital', 'both'.

Null means unconstrained (applies to all product kinds).

Invariants

  • brand name must be unique
  • slug is generated from name and suffix-resolved on conflict
  • old slugs remain resolvable through slug history
  • public reads return visible brands only
  • productKind filter in admin list is exact match (eq)
  • productKind filter in customer list is OR(eq(value), eq("both")) (includes "both" brands)

Brand-to-Product Linkage

Brand-to-product linkage is now implemented. The key relationships are:

  • Product level: product.brand_id — nullable FK to brand.id, assigned during product admin CRUD.
  • Warranty level: warranty_info.brand_id — nullable FK to brand.id, associating warranty info entries with a brand.
  • Warranty claim level: warranty_claim resolves brand through warranty_claim.warranty_info_id -> warranty_info.brand_id -> brand.id.

All FKs are nullable — brands remain standalone entities with optional downstream associations.

Caching

Customer brand list is cached via RedisCacheService.getOrSet with a cache key that includes all query parameters including productKind. Different productKind filters produce different cache entries.

Admin mutations call invalidatePattern on catalog:brands:list:* and catalog:brand:slug:* to nuke the cache.