Skip to content

URD: Commerce

ModuleCORE-03Versionv0.4
StatusBuiltDate2026-05-30

1. Purpose

Commerce lets a business owner stand up and run their business structure: a single Organization (the brand) and one or more Merchants (the legal point-of-sale units), each with its own sale channels and product categories. The module delivers a one-step onboarding that creates the whole structure atomically, plus full lifecycle management of every entity afterwards.

2. Scope

IncludedExcluded
Organization creation via onboardingEmployee lifecycle & login (→ User Management)
Organization profile, hierarchy, settings, attachmentsRole/permission definition (→ Permissions)
Merchant creation (single, batch, aggregate)Product catalog content (→ Products)
Business-type classificationStock levels (→ Inventory)
Sale-channel managementOrder / checkout processing (→ Orders)
Category management with add-on flagPayment processing (→ Payment)
Per-merchant deletion policyE-invoice issuance (→ Tax & Invoice)
Encrypted merchant configurationTechnical API specifications (→ developer docs)
Role-based data filtering

3. Definitions

TermDefinition
OrganizationTop-level virtual brand entity. Parent container for merchants, users, and devices. Carries branding, not legal identity.
MerchantA physical/legal point-of-sale unit under an organization where transactions occur. Holds tax info, invoice profile, and wallet.
Sale ChannelA selling channel within a merchant (e.g. dine-in, takeout, delivery). Supports hierarchy.
CategoryA product grouping within a merchant. Can be flagged as add-on.
Business TypeClassification that drives the POS UI: DEFAULT, TICKET, FNB, THEATER.
Aggregate OperationA single request that creates or updates a merchant together with its categories and sale channels, atomically.
Deletion PolicyPer-merchant configuration controlling cascade behavior on entity deletion.
ConfigurationEncrypted key-value settings for a merchant (payment providers, integrations).
SlugURL-friendly identifier. Globally unique for organizations; unique per organization for merchants; unique per merchant for sale channels.

4. Conceptual Model

Conceptual only — the full schema lives in the developer domain model.

5. Functional Requirements

One table per functional area. <AREA> codes match the test-case IDs. Priority = MoSCoW (Must / Should / Could / Won't).

5.1 Organization (ORG)

IDPRequirement
URD-ORG-001MUser can create one organization via onboarding
URD-ORG-002MOnboarding atomically creates organization + default merchant + sale channels + access
URD-ORG-003MThe creating user is automatically assigned as Owner
URD-ORG-004MName (multilingual) and slug are required; all other fields optional
URD-ORG-005MA unique system identifier is generated on creation and is not editable
URD-ORG-006MOrganization can be found by ID or by slug (cascading lookup)
URD-ORG-007MOwner can update organization profile
URD-ORG-008MAggregate create/update supports file attachments
URD-ORG-009SOrganization list/count is filtered by the user's role
URD-ORG-010SOrganization can be deactivated (data preserved, reversible)
URD-ORG-011SOrganization can designate a headquarter merchant
URD-ORG-012SOrganization can be archived (permanently read-only)
URD-ORG-013COrganization can have child organizations (hierarchy)

5.2 Merchant (MER)

IDPRequirement
URD-MER-001MDefault merchant created during onboarding
URD-MER-002MOwner can create additional merchants
URD-MER-003MOwner can batch-create multiple merchants
URD-MER-004MOwner can aggregate-create a merchant with categories + sale channels
URD-MER-005MMerchant slug is unique within the same organization
URD-MER-006MMerchant can be viewed with its channels and categories
URD-MER-007MOwner can update merchant information
URD-MER-008MAggregate update: ID-only = delete, ID+data = update, no ID = create
URD-MER-009MMerchant can be found by ID or by slug (cascading lookup)
URD-MER-010MMerchant list is filtered by the user's role
URD-MER-011MMerchant count respects the same filtering as the list
URD-MER-012SMerchant can be deactivated (reversible)
URD-MER-013SMerchant can be archived (permanently read-only)
URD-MER-014CMerchant hierarchy (parent-child)
URD-MER-015SExplicit delete flag distinguishes "delete" from "leave unchanged" in aggregate update

5.3 Sale Channels (SC)

IDPRequirement
URD-SC-001MDefault channel(s) created during onboarding
URD-SC-002MChannels managed as part of merchant aggregate operations
URD-SC-003MChannels can be batch-created for an existing merchant
URD-SC-004MChannel slug unique within the same merchant
URD-SC-005MA unique system identifier is generated on creation and is not editable
URD-SC-006CChannel hierarchy (parent-child)
URD-SC-007SChannels can be deactivated or archived

5.4 Categories (CAT)

IDPRequirement
URD-CAT-001MCategories managed as part of merchant aggregate operations
URD-CAT-002MCategories can be renamed via aggregate update without affecting their products
URD-CAT-003MCategories can be deleted via aggregate update (soft-delete)
URD-CAT-004SCategory can be marked as add-on (and un-marked)

5.5 Deletion Policy (DEL)

IDPRequirement
URD-DEL-001SEach merchant has a configurable deletion policy
URD-DEL-002SstrictCategoryDeletion: when true, blocked if category has linked products
URD-DEL-003ScascadeProductDeletion: when true, deleting a category cascades to its products
URD-DEL-004SOwner can view and update the deletion policy

5.6 Configuration (CFG)

IDPRequirement
URD-CFG-001SMerchants can store payment-provider credentials and integration settings
URD-CFG-002SSensitive credentials are encrypted at rest
URD-CFG-003SConfigurations are organized by group (system, table, integration)

5.7 Access (ACC)

IDPRequirement
URD-ACC-001MUser access is managed via role-based policies (org-level or merchant-level)
URD-ACC-002MEmployees can be assigned to specific merchants
URD-ACC-003MA user can be granted access to multiple organizations
URD-ACC-004MOwner sees only their own organization and merchants
URD-ACC-005MAll list/count operations are filtered by the user's role (Admin bypasses)
URD-ACC-006MOwner can create, view, and update their organization
URD-ACC-007MOwner can create, update, and deactivate merchants
URD-ACC-008MOwner can manage channels and categories via aggregate operations
URD-ACC-009MOwner can assign an employee to a specific merchant
URD-ACC-010MEmployee sees only assigned merchants
URD-ACC-011MEmployee cannot access unassigned merchants
URD-ACC-012MA user with an unrecognized role is denied (no silent empty result)

6. Acceptance Criteria

AC-ORG-01: Onboarding is atomic
GivenWhenThen
A new authenticated user with no organizationOnboarding completes with a valid name + slugOrganization (Activated) + default merchant + default channel(s) created; owner access granted; system & slug identifiers auto-generated
Any step failsDuring onboardingEntire operation rolls back — nothing persisted
AC-ORG-02: Slug uniqueness
GivenWhenThen
An organization already uses slug "my-business"Another user tries the same slugCreation rejected — slug already in use
AC-MER-01: Aggregate create
GivenWhenThen
An owner with an existing organizationCreates a merchant with categories + channelsMerchant, categories, channels all created atomically; identifiers generated
Any child is invalidDuring aggregate createEntire operation rolls back
AC-MER-02: Aggregate smart update
GivenWhenThen
Child item with ID onlyAggregate updateItem deleted
Child item with ID + dataAggregate updateItem updated
Child item without IDAggregate updateItem created
AC-DEL-01: Deletion policy
GivenWhenThen
strictCategoryDeletion = trueDeleting a category that has productsBlocked
cascadeProductDeletion = trueDeleting a categoryIts products are also deleted
AC-ACC-01: Role-based isolation
GivenWhenThen
Owner A (Org X) and Owner B (Org Y)Owner A requests organization/merchant dataOnly Org X data returned; Org Y not visible
Employee assigned to Merchant X onlyRequests merchant listOnly Merchant X returned

7. Constraints & Non-Goals

Constraints

IDConstraint
C-01Organization must exist before creating merchants
C-02Aggregate operations are atomic — all or nothing
C-03All entities use soft-delete; nothing is physically removed
C-04Slug uniqueness: global for organizations, per-org for merchants, per-merchant for channels
C-05All operations require authentication
C-06Payment credentials are encrypted at rest

Non-Goals

  • Cross-organization access or sharing merchants between organizations
  • Ownership transfer (Planned)
  • Hard-delete of any entity
  • Standalone sale-channel / category CRUD outside the merchant aggregate (Planned)

8. Version History

DateAuthorDescriptionVer
2026-05-30P. NguyenMigrated to module-docs convention; reconciled requirement IDs/areas with test casesv0.4
2026-04-17P. NguyenMerged Organization + Merchant into Commerce modulev0.3
2026-02-27QE AssessmentQE findingsv0.2
2026-02-26P. Do — Product OwnerInitialv0.1

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.