Skip to main content

Colors Module

Overview​

The colors module manages product colors within FlowPOS. Colors are used to classify products by their color attribute, supporting filtering, variant definition, and catalog organization.

Colors are business-scoped: every color belongs to a specific business and is isolated from other businesses.


Architecture​

The module follows Hexagonal Architecture with strict layer boundaries.

colors/
├── colors.module.ts # NestJS module wiring
├── domain/
│ └── colors-repository.domain.ts # IColorsRepository port + injection token
├── application/
│ └── colors.service.ts # Use cases (CRUD)
├── infrastructure/
│ └── colors.repository.ts # Kysely DB adapter (implements port)
└── interfaces/
├── colors.controller.ts # HTTP adapter
├── dtos/
│ ├── create-color.dto.ts
│ └── update-color.dto.ts
└── query/
└── paginate-colors.query.ts

Layer responsibilities​

LayerResponsibility
domain/Repository port (IColorsRepository) and COLORS_REPOSITORY injection token.
application/ColorsService — orchestrates CRUD operations and pagination.
infrastructure/ColorsRepository — Kysely queries against the color table. Implements IColorsRepository.
interfaces/ColorsController — maps HTTP requests to service calls. Thin layer with no business logic.

Dependency rule​

interfaces → application → domain ← infrastructure

Domain Concepts​

Color​

A named color with a hex value, used to classify products (especially for variant definitions like apparel).

FieldTypeDescription
idUUIDPrimary key (auto-generated)
namestringDisplay name (e.g. "Red", "Navy Blue")
hexValuestringHex color code (e.g. "#FF0000")
businessIdUUIDFK to business
isActivebooleanWhether the color is available for use
createdByUUIDFK to user
updatedByUUIDFK to user (nullable)
createdAttimestamptzAuto-set on creation
updatedAttimestamptzSet on update

API Endpoints​

All endpoints require Bearer token authentication and are scoped to PolicyResource.Color for RBAC.

POST /colors​

Create a new color.

Body:

{
"name": "Red",
"hexValue": "#FF0000",
"businessId": "<uuid>",
"isActive": true,
"createdBy": "<uuid>"
}

Responses: 201 Created | 400 Invalid body | 401 Unauthorized

GET /colors​

List colors with pagination, search, and sorting.

Query parameters:

ParamRequiredDescription
businessIdNoUUID of the business (filter)
pageNoPage number (default: 1)
sizeNoPage size (default: 10)
searchNoCase-insensitive search on name and hexValue
orderByNoSort field (name)
orderNoasc or desc

Responses: 200 Paginated list | 401 Unauthorized

GET /colors/:id​

Get a single color by UUID.

Responses: 200 Found | 404 Not found | 401 Unauthorized

PATCH /colors/:id​

Partially update a color.

Body:

{
"name": "Blue",
"hexValue": "#0000FF",
"updatedBy": "<uuid>"
}

Responses: 200 Updated | 400 Invalid body | 404 Not found | 401 Unauthorized

DELETE /colors/:id​

Delete a color by UUID.

Responses: 200 Deleted | 404 Not found | 401 Unauthorized


  • Products — products reference colorId for catalog classification
  • Product Variants — colors are used as option values in variant matrices (e.g. size × color)