Skip to content

Naming Conventions — FitZalo V2

Purpose: Chuẩn hóa naming cho Task IDs, API routes, Events, Permissions, Files. Scope: Áp dụng bắt buộc cho toàn bộ dự án.


1. Task ID

Format: WP-{Phase}.{ModuleKey}.{Seq}
Example: WP-1.IAM.001, WP-3.ORDER.005, WP-0.GOV.002
FieldRule
Phase0–8 (theo IMPLEMENTATION_ROADMAP)
ModuleKeyUPPERCASE, max 8 chars — xem bảng Module Keys bên dưới
Seq3 digits, zero-padded

Module Keys

KeyModuleDomain
GOVGovernance & BaselinePhase 0
IAMIdentity & Access MgmtCore Platform
TENANTMulti-TenancyCore Platform
AUDITAudit LogCore Platform
NOTIFYNotification HubCore Platform
PLUGINPlugin SystemCore Platform
BILLINGBilling & UsageCore Platform
CATALOGProduct CatalogCommerce
MDMMaster DataAdmin
ORDEROrder LifecycleCommerce
VOUCHERVoucher/PromotionCommerce
CARTCart & CheckoutCommerce
INVInventory WMSSupply Chain
PROCProcurementSupply Chain
VENDORVendor ManagementSupply Chain
PARTNERPartner/CustomerCRM
INBOXUnified InboxCRM
AFFILAffiliate & LoyaltyCRM
CMSContent ManagementContent
ESNInternal CommsContent
AIAI Studio / KBAI Platform
ZALOZalo IntegrationsIntegrations
SHIPShipping LayerLogistics
ADMINSystem AdminAdmin

2. API Routes

Format: /api/v2/{domain-plural}/{resource-plural}[/{id}][/{action}]
Example:
  GET    /api/v2/ecommerce/orders
  POST   /api/v2/ecommerce/orders/:id/split
  PATCH  /api/v2/iam/members/:id/role
  DELETE /api/v2/catalog/products/:id

Rules:

  • kebab-case for all segments
  • Plural nouns for resources
  • Verbs only for actions (sub-resources): /confirm, /validate, /split
  • No trailing slashes
  • Query params for filtering: ?status=ACTIVE&page=1&limit=20

3. Events

Format: {domain}.{entity}.{action}
Example: ecommerce.order.created, inventory.picking.validated, iam.member.invited

Rules:

  • All lowercase, dot-separated
  • Past tense for actions: created, updated, deleted, confirmed
  • Domain matches module key (lowercase)

4. Permissions

Format: {DOMAIN}_{ACTION}[_{SCOPE}]
Example: ORDER_VIEW, ORDER_MANAGE, ORDER_REFUND_PROCESS
         CAT_MANAGE, INV_ADJUST, CRM_INBOX_REPLY

Rules:

  • UPPERCASE, underscore-separated
  • Domain: 2–6 chars abbreviation (IAM, CAT, ORDER, INV, CRM, NOTIFY, etc.)
  • Action: VIEW, MANAGE, CREATE, DELETE, PROCESS, ADMIN, REPLY, PUBLISH
  • Scope (optional): further qualification

Standard Roles & Permissions Mapping

RoleScopePermission Baseline
SYSTEM_ADMINGlobalADMIN_FULL, TENANT_ADMIN, all SYS_*
TENANT_OWNERTenantAll permissions within the tenant
TENANT_ADMINTenantMost *_VIEW and *_MANAGE
TENANT_OPERATORTenantDaily ops (ORDER_MANAGE, INV_VIEW, CRM_REPLY)
TENANT_MEMBERTenantBasic *_VIEW only

Permission Registry Mapping

CurrentStandardModule
PROD_VIEW_ALLPROD_VIEWcatalog
CRM_VIEW_ORDERSORDER_VIEWecommerce
SHOP_PROFILETENANT_VIEWiam
TENANT_READTENANT_VIEWiam
TENANT_UPDATETENANT_MANAGEiam
CRM_INBOX_WRITEINBOX_REPLYinbox

5. File Naming

TypeConventionExample
Schema{entity}.schema.tsorder.schema.ts
Controller{entity}.controller.tsorder.controller.ts
Service{entity}.service.tsorder.service.ts
DTO{entity}.dto.tsorder.dto.ts
Consumer{domain}-{event}.consumer.tsbilling-usage.consumer.ts
Spec (test){entity}.{type}.spec.tsorder.integration.spec.ts
Frontend PagePascalCase.tsxOrderList.tsx

6. Branch & Commit

Branch: feat/{module-key}/{short-description}
Example: feat/order/state-machine, feat/iam/invite-flow

Commit: {type}({module}): {description}
Example: feat(order): implement state machine transitions
         fix(iam): tenant guard null check
         test(voucher): add stacking validation tests

7. Relation Fields & Population Naming

Full spec: RELATIONSHIP_POPULATION_RULES.md

Persisted Foreign Keys (DB Schema)

PatternExampleRule
<relation>IdcreatedById, categoryId, assigneeIdSingular FK → stores ObjectId
<relation>IdstagIds, roleIds, whitelistUserIdsArray FK → stores ObjectId[]

Response-Only Relations (API DTO)

PatternExampleRule
<relation>SummarycreatedBySummary, categorySummaryPreferred — projected relation in response
<relation>createdBy, categoryAllowed ONLY in response DTO; NEVER as DB field storing ID

Mandatory Audit Fields

All mutable entities MUST have:

  • createdById: ObjectId — user who created
  • updatedById: ObjectId — user who last updated
  • deletedById: ObjectId (if soft-delete) — user who deleted

❌ FORBIDDEN Patterns

ForbiddenWhyCorrect
createdBy: ObjectId in schemaAmbiguous — can be confused with populated objectcreatedById: ObjectId
owner: ObjectId in schemaAmbiguousownerId: ObjectId
Overwriting FK with populated objectMutates persisted dataSeparate <name>Summary in DTO

8. Audit Fields Naming

Full spec: AUDIT_STAMPING_STANDARD.md

FieldTypeMandatoryNotes
createdAtDateAuto — { timestamps: true }
updatedAtDateAuto — { timestamps: true }
createdByIdObjectIdService-stamped — NEVER from client
updatedByIdObjectIdService-stamped on every update
isDeletedboolean⚠️Only if soft-delete enabled
deletedAtDate⚠️Only if soft-delete enabled
deletedByIdObjectId⚠️Only if soft-delete enabled

❌ Forbidden Audit Naming

ForbiddenCorrect
createdBy: ObjectIdcreatedById: ObjectId
updatedBy: ObjectIdupdatedById: ObjectId
deletedBy: ObjectIddeletedById: ObjectId
createdBy: stringcreatedById: ObjectId (fix type too)

9. Time / Date Field Naming

Full spec: TIME_DATE_STANDARD.md

SuffixSemanticsDB TypeExample
*AtServer-controlled instant (lifecycle/audit)Date (UTC)createdAt, publishedAt, processedAt
*DateBusiness-controlled instant (user-provided range)Date (UTC)startDate, endDate, dueDate
*OnUser-provided date-only (calendar day)String YYYY-MM-DDbirthOn, invoiceDueOn
*MonthMonth granularityString YYYY-MMreportMonth, billingMonth
*YearYear granularityNumberfiscalYear

❌ Forbidden Time Naming

ForbiddenWhyCorrect
startAt / endAt on business fields*At implies server-controlledstartDate / endDate
createdDate / updatedDate*Date implies user-controlledcreatedAt / updatedAt
bare dateToo genericorderDate, birthOn, etc.

Changelog

DateChange
2026-02-23Initial creation — consolidated from RBAC_PERMISSION_MATRIX + conventions
2026-02-23Added §7: Relation Fields & Population Naming (D-008)
2026-02-23Added §8: Audit Fields Naming, §9: Time/Date Naming (GOV-AUDIT, GOV-TIME)

FitZalo Platform Documentation