# NestCraftX CLI - User Guide ## Installation ```bash npm install -g nestcraftx ``` ## Available Commands ### Create a new project ```bash nestcraftx new [options] ``` ## Generation Modes ### FULL Mode (Complete Architecture - Clean Architecture + DDD) Complete structure with use-cases, mappers, adapters, and strict layer separation. Ideal for complex and scalable projects. ```bash nestcraftx new my-project --full nestcraftx new my-project --mode=full nestcraftx new my-project ``` **Generated Structure:** ``` src ├── [entity] │ ├── application │ │ ├── dtos │ │ ├── services │ │ ├── use-cases │ │ └── interfaces │ │ │ ├── domain │ │ ├── entities │ │ ├── enums │ │ └── interfaces │ │ │ ├── infrastructure │ │ ├── adapters │ │ ├── mappers │ │ ├── repositories │ │ └── services │ │ │ ├── presentation │ │ └── controllers │ │ │ └── [entity].module.ts ``` ### LIGHT Mode (Simplified MVP) Flat structure with fewer abstraction layers. Perfect for prototypes and small projects. ```bash nestcraftx new my-project --light nestcraftx new my-project --mode=light ``` **Generated Structure:** ``` src ├── [entity] │ ├── entities │ ├── dto │ ├── services │ ├── repositories │ ├── controllers │ └── [entity].module.ts ``` --- ## Available Options ### ORM Choose which ORM to use: ```bash --orm=prisma # Prisma (default) --orm=typeorm # TypeORM --orm=mongoose # Mongoose (MongoDB - beta phase) ``` **Examples:** ```bash nestcraftx new my-api --light --orm=prisma nestcraftx new my-api --full --orm=typeorm nestcraftx new my-api --orm=mongoose ``` ### Authentication Enable JWT authentication: ```bash --auth # Enables JWT auth ``` **Example:** ```bash nestcraftx new my-api --light --auth --orm=prisma ``` With `--auth`, a User entity is automatically generated with: - email (string) - password (string) - isActive (boolean) ### Swagger Enable Swagger/OpenAPI documentation: ```bash --swagger # Enables Swagger UI ``` **Example:** ```bash nestcraftx new my-api --light --swagger ``` Swagger will be accessible at: `http://localhost:3000/api/docs` ### Docker Disable Docker (enabled by default): ```bash --docker=false # Disables Docker ``` **Example:** ```bash nestcraftx new my-api --light --docker=false ``` --- ## Full Command Examples ### LIGHT Project with all options ```bash nestcraftx new my-api --light --orm=prisma --auth --swagger ``` ### FULL Project with TypeORM and Auth ```bash nestcraftx new my-api --full --orm=typeorm --auth ``` ### Minimal LIGHT Project (interactive mode) ```bash nestcraftx new my-api --light # The CLI will prompt for all necessary options ``` ### MongoDB Project with Mongoose ```bash nestcraftx new my-api --light --orm=mongoose --auth --swagger ``` --- ## Automatic Configuration ### Generated .env file The CLI automatically generates a `.env` file with: **For PostgreSQL (Prisma/TypeORM):** ```env NODE_ENV=development PORT=3000 JWT_SECRET= JWT_REFRESH_SECRET= JWT_EXPIRES_IN=15m JWT_REFRESH_EXPIRES_IN=7d POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=my-api POSTGRES_HOST=localhost POSTGRES_PORT=5432 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/my-api?schema=public ``` **For MongoDB (Mongoose):** ```env NODE_ENV=development PORT=3000 JWT_SECRET= JWT_REFRESH_SECRET= JWT_EXPIRES_IN=15m JWT_REFRESH_EXPIRES_IN=7d MONGO_URI=mongodb://localhost:27017 MONGO_DB=my-api ``` JWT secrets are automatically generated in a secure manner. --- ## Interactive Modes ### Interactive LIGHT Mode If you don't provide all necessary flags, the CLI will enter interactive mode to ask for missing options. **Example:** ```bash nestcraftx new my-api --light [LIGHT MODE] Simplified configuration for my-api [?] Choose an ORM (prisma, typeorm, mongoose) [prisma]: prisma [?] Enable JWT authentication? (Y/n): y [INFO] Auth enabled: automatically adding User entity [?] Enable Swagger for API documentation? (Y/n): y [?] Generate Docker files? (Y/n): y [INFO] PostgreSQL Configuration PostgreSQL User [postgres]: PostgreSQL Password [postgres]: Database Name [my-api]: PostgreSQL Host [localhost]: PostgreSQL Port [5432]: [?] Do you want to add additional entities? (Y/n): n [INFO] Starting project generation... ``` ### Interactive FULL Mode The FULL mode is always interactive to give you total control over the configuration. **Example:** ```bash nestcraftx new my-project [FULL MODE] Complete configuration with Clean Architecture [?] Project name: my-project [?] Database (postgresql, mongodb) [postgresql]: postgresql [INFO] PostgreSQL Configuration PostgreSQL User [postgres]: PostgreSQL Password [postgres]: ... [?] ORM for PostgreSQL (prisma, typeorm) [prisma]: prisma [?] Use Yarn? (Y/n): n [?] Generate Docker files? (Y/n): y [?] Add JWT authentication? (Y/n): y [?] Install Swagger? (Y/n): y [INFO] Swagger Configuration API Title [my-project API]: Description [API generated by NestCraftX]: Version [1.0.0]: Endpoint [api/docs]: [INFO] Entity Input (FULL Mode - Complete Architecture) [?] Add an entity? (Y/n): y Entity name: post Fields for "post": Field name (empty to finish): title Type for "title" (string, number, boolean, Date, enum): string Field name (empty to finish): content Type for "content" (string, number, boolean, Date, enum): string Field name (empty to finish): [✓] Entity "post" added with 2 field(s) [?] Add another entity? (Y/n): n [?] Add relationships between entities? (Y/n): n ``` --- ## After Creation ```bash cd my-project npm run start:dev ``` If Swagger is enabled: `http://localhost:3000/api/docs` ## Other Commands ### Check environment ```bash nestcraftx test ``` ### CLI Information ```bash nestcraftx info ``` ### Help ```bash nestcraftx --help ``` ## Important Notes - JWT secrets are securely auto-generated (64 characters). - `DATABASE_URL` is automatically built based on the chosen ORM. - Docker is enabled by default in LIGHT mode. - FULL mode requires interactive configuration if no options are provided.