Skip to content

Canonical File & Directory Structure Standard

This standard defines canonical file naming and placement across the Nexload SDK ecosystem. Autonomous agents and human engineers must follow the nexload-way roles and the generated role table below when creating, refactoring, or modernizing packages and applications.


  1. Predictable Discovery: A developer or agent inspecting src/ should grasp module boundaries within 10 seconds.
  2. Explicit Dependency Flow: Dependencies flow inward; internal helper utilities never leak through root barrel exports.
  3. Mandatory Kebab-Case: Every file and folder name uses kebab-case. Never use camelCase or PascalCase filenames. Only framework convention and generated files keep the name their tool requires, such as payload-types.ts or routeTree.gen.ts.
  4. Co-location of Tests: Every test sits next to the file it tests and repeats its full file name: pricing.service.test.ts and pricing.service.integration.test.ts beside pricing.service.ts. Never use a separate test/, tests/ or __tests__/ folder (ST-10).
  5. Private Boundary Markers: A leading _ marks a module-private file, such as _price-row.comp.tsx. Import it only from inside its own module and never export it from index.ts (ST-05). Do not create an internal/ folder; the _ prefix is the only private marker.

File layout, role suffixes and naming follow the nexload-way skill (skills/nexload/way/); do not hand-write layouts from this page. Run nexload-doctrine verify from @nexload-sdk/eslint-config to check a tree against the same manifest.

Load the nexload-way skill before creating, renaming or moving files. The table below is generated from its manifest.

roleextmeaningfoldersexamplesymbol
pagetsxRenders a full pagemodules/<feature>/checkout.page.tsxCheckoutPage
layouttsxShared frame for several pages of a modulemodules/<feature>/account.layout.tsxAccountLayout
skeletontsxLoading state of a page or sectionnext to its pagecheckout.skeleton.tsxCheckoutSkeleton
comptsxReact component (prefix _ when private to the module)modules/<feature>/ or shared/ui/modules/products/card.comp.tsxProductCard
hooktsReact hookmodules/<feature>/modules/carts/state.hook.tsuseCartState
providertsxReact context providermodules/<feature>/modules/carts/cart.provider.tsxCartProvider
utiltsPure helper functionnext to the module with _, or shared/lib/shared/lib/slug.util.tsformatSlug
schematsZod validation schemamodules/<feature>/modules/orders/checkout.schema.tscheckoutSchema
adaptertsConnects to an external service (gateway, SMS)modules/<domain>/modules/payments/zibal.adapter.tscreateZibalAdapter
servicetsRuns domain logic or a use casemodules/<domain>/modules/orders/pricing.service.tscalcOrderTotal
routertsRegisters RPC or HTTP routesmodules/<domain>/modules/payments/payment.router.tspaymentRouter
mappertsConverts data between layersmodules/<domain>/modules/products/product.mapper.tstoProductDto
dtotsDescribes the input or output of an endpointmodules/<domain>/modules/customers/create.dto.tsCreateCustomerDto
contracttsAPI contract between appspackages/contracts/src/catalog.contract.tscatalogContract
entitytsCanonical model of an entitypackages/schema/src/<domain>/payments/payment.entity.tspaymentEntity
collectiontsPayload collectionmodules/<domain>/modules/orders/order.collection.tsOrders
globaltsPayload globalmodules/<domain>/modules/settings/store.global.tsStoreSettings
before-validatetsPayload collection beforeValidate hook (module-private)next to the collection_<what>.before-validate.tsverb-named function
before-changetsPayload collection beforeChange hook (module-private)next to the collection_total.before-change.tscomputeOrderTotal
after-changetsPayload collection afterChange hook (module-private)next to the collection_<what>.after-change.tsverb-named function
after-readtsPayload collection afterRead hook (module-private)next to the collection_<what>.after-read.tsverb-named function
after-deletetsPayload collection afterDelete hook (module-private)next to the collection_<what>.after-delete.tsverb-named function
accesstsPayload access rulemodules/<domain>/modules/customers/customer.access.tscustomerAccess
operationstsTyped operations on the Payload Local APImodules/<domain>/modules/payments/payment.operations.tspaymentOperations
jobtsBackground job or taskmodules/<domain>/modules/orders/expiry.job.tsorderExpiryJob
endpointtsCustom endpointmodules/<domain>/modules/catalog/preview.endpoint.tscatalogPreviewEndpoint
typestsTypes onlynext to the ownermodules/products/card.types.tsProductCardProps
constantstsModule constantsmodules/<feature>/modules/shop/shop.constants.tsshopPageSize
errorstsModule error classes or codesmodules/<domain>/modules/payments/payment.errors.tsPaymentDeclinedError

  • ❌ Deep Relative Import Leaks: Importing another module’s files, such as ../orders/pricing.service or ../orders/_price-row.comp. Import another module only through its index.ts (ST-04, ST-05).
  • ❌ Mixed Case or Role-less Filenames: Files like UserProfile.tsx or dataFetcher.ts. Use a kebab-case <what> plus a role from the table (ST-06, ST-07): modules/users/profile.comp.tsx, and name a fetcher after what it does, such as modules/orders/order.operations.ts. Run nexload-doctrine suggest <path> --kind <role> for the exact name.
  • ❌ Barrel Bloat: Re-exporting every private function in src/index.ts. Only export public interfaces, contracts, and entry functions.
  • ❌ Circular Dependencies: Cycles between a <what>.types.ts file and implementation files. Types must remain leaf nodes.