Feature-based architecture generator
npm install @craftycodesmith/node-structureA zero-dependency CLI tool to scaffold Node.js projects with a Feature-Based (Modular) Architecture using TypeScript.
---
You can run this tool directly using npx without installation:
``bashInitialize a new project
npx @craftycodesmith/node-structure init [folder-name]
---
š¦ Commands
$3
Creates a new project with the feature-based architecture structure.
Usage:
`bash
npx @craftycodesmith/node-structure init my-project
`If no folder name is provided, it initializes in the current directory.
What it does:
- Creates the directory structure
- Runs
npm init -y
- Installs TypeScript and @types/node
- Generates a tsconfig.json
- Sets up base folders (features, common, config, middleware)---
$3
Generates a new feature module with Controller, Service, and Model files.
Usage:
`bash
npx @craftycodesmith/node-structure res User
`This creates:
`
src/features/user/
āāā user.controller.ts
āāā user.service.ts
āāā user.model.ts
`Each file includes boilerplate code to get you started quickly.
---
š Generated Architecture
The tool enforces a modular structure where each functional area of your application lives in its own "feature" folder.
`
project-root/
āāā src/
ā āāā features/
ā ā āāā [feature-name]/
ā ā āāā [name].controller.ts
ā ā āāā [name].service.ts
ā ā āāā [name].model.ts
ā āāā common/ # Shared utilities and helpers
ā āāā config/ # Environment and DB configurations
ā āāā middleware/ # Global Express/Koa middlewares
āāā tsconfig.json
āāā package.json
`---
š Features
- Zero Dependencies: Lightweight and fast
- TypeScript Ready: Automatically generates
tsconfig.json and installs @types/node and typescript
- Automated Setup: Runs npm init -y and dependency installation automatically
- Clean Code: Generates boilerplate classes and interfaces for rapid development
- Modular Architecture: Each feature is self-contained for better maintainability---
š Example Workflow
`bash
1. Create a new project
npx @craftycodesmith/node-structure init my-app2. Navigate to the project
cd my-app3. Generate features
npx @craftycodesmith/node-structure res User
npx @craftycodesmith/node-structure res Product
npx @craftycodesmith/node-structure res Order4. Start building!
``