Skip to content

CONTRIBUTING

Folder structure

bash
erp/
├── apps/
├── libs/
├── tools/
├── nx.json
├── package.json
└── tsconfig.base.json

/apps/ contains the application projects
/libs/ contains the library projects
/tools/ contains scripts that act on the code base: database scripts, local executors, local generators
nx.json configures the Nx CLI
tsconfig.base.json setups global Typescript settings

Library types:

  • Feature library
    • Contain a business use case, bounded context
    • Most of the its component are smart components that interact with data-sources
    • Contains most of the UI logic, form validation code, etc.
    • Most likely app specific, and lazy loaded
    • naming convention: libs/bookkeeping
  • UI library
    • Contain presentational (dumb) components
    • Generally there is no services injected, all of the data comes from inputs
    • UI library can depend on ui and util library
  • Data-access
    • naming convention: libs/bookkeeping/+state
    • Can depend on other data-access and util libraries
  • Utility
    • Collection of pure functions, used by many apps and libraries
    • The utilities do not have framework-specific code
    • naming convention: libs/util
    • dependency constraint: can depend only on other utility libraries

Generate application, library, components

bash
# Create erp application
nx g app foo

# Create bookkeping library
nx g library bookkeeping

# Create component foo inside the bookkeeping library
nx g component foo --project bookkeeping

FAQ

Q: When to create a new library? A: When there is a new bounded context. Each library is a bounded context.

Q: How to enforce dependency constraint? A: Use tags in NX, use CODEOWNERS to assign ownership of a library to a user/team