- Domain-driven structure: Organize code by business domains (
cli/,registry/,components/,utils/) - Subfolder patterns: Use consistent patterns (
domain/,routes/,views/,middleware/) - File naming: Use kebab-case for all files and folders (
components-cache,package-json-validator) - Module exports: Use
index.tsfiles for clean public APIs and re-exports - Centralized types: Place shared TypeScript interfaces in
src/types.ts
- Strict compilation: All code must pass TypeScript strict mode checks
- Interface design: Use comprehensive interfaces with optional properties (
?syntax) - Type imports: Use
import typefor type-only dependencies - Union types: Use union types for constrained values (
'oc-registry' | 'oc-registry-local') - Generic interfaces: Extend base types like
PackageJsonfor specialized interfaces - Naming conventions:
- camelCase for variables/functions (
componentName,getComponent) - PascalCase for interfaces/types (
Component,RegistryOptions) - UPPER_CASE for constants (
DEFAULT_PORT)
- camelCase for variables/functions (
- Import organization: Group imports (Node.js with
node:prefix, external libraries, local modules) - Function style: Use arrow functions for simple operations, function declarations for main functions
- Async patterns: Prefer async/await over Promise chains
- Object destructuring: Use destructuring in function parameters
- Descriptive naming: Use clear, descriptive function names (
getComponentRetrievingInfovsgetComp)
src/
├── cli/
│ ├── commands.ts
│ ├── domain/ # Business logic
│ ├── facade/ # Public APIs
│ └── programmatic-api.ts
├── registry/
│ ├── routes/ # Express routes
│ ├── domain/ # Business logic
│ │ └── validators/ # Input validation
│ ├── views/ # JSX components
│ │ └── partials/ # Reusable components
│ └── middleware/ # Express middleware
├── components/ # Component implementations
├── utils/ # Shared utilities
├── types.ts # Centralized type definitions
└── resources/ # Static resources
.tsfor TypeScript modules and business logic.tsxfor React/JSX components and viewsindex.tsfor module exports and public APIs