StartXKit docs
CLI

add module

Generate a feature module and choose how many layers it should contain.

The add module command adds a new feature to an existing StartXKit project.

Use it for things like:

  • users
  • auth
  • products
  • orders
  • billing

Usage

Run the command from the root of a generated StartXKit project:

npx @startxkit/cli add module users

The CLI reads startxkit.config.json, then uses your framework and architecture to place the files correctly.

Layer Choices

When prompted, choose how deep the module should be:

Prompt labelGenerated filesUse when
Route + Controllerroute, controllerThe feature only needs HTTP handlers
Route + Controller + Serviceroute, controller, serviceThe feature has business logic
Route + Controller + Service + Repositoryroute, controller, service, repositoryThe feature needs a data access boundary
Fullroute, controller, service, repository, interface, validatorThe feature should have the full production structure

Modular Output

In a modular project, each feature owns its files:

src/
  modules/
    users/
      users.route.ts
      users.controller.ts
      users.service.ts
      users.repository.ts
      users.interface.ts
      users.validation.ts

This is a feature-first layout. Everything for users is in one folder.

Layered Output

In a layered project, files are grouped by responsibility:

src/
  routes/
    users.route.ts
  controllers/
    users.controller.ts
  services/
    users.service.ts
  repositories/
    users.repository.ts
  interfaces/
    users.interface.ts
  validators/
    users.validation.ts

This is a layer-first layout. All routes live together, all controllers live together, and so on.

Minimal Output

In a minimal project, the route file contains the handlers directly:

src/
  routes/
    users.route.ts

Minimal projects intentionally avoid controllers, services, repositories, interfaces, and validators.

Generated Endpoints

If you choose CRUD endpoints, the module includes:

MethodPathPurpose
GET/usersList records
GET/users/:idRead one record
POST/usersCreate a record
PATCH/users/:idUpdate a record
DELETE/users/:idDelete a record

The final URL also includes your API prefix. With /api/v1, the list endpoint becomes:

GET /api/v1/users

Dependency Injection

If dependency injection is enabled, the route file wires the selected layers together:

route
  |
  v
controller
  |
  v
service
  |
  v
repository

If a layer was not selected, the generated code does not try to inject it. For example, Route + Controller does not create or inject a service.

Common Choices

  • Choose Route + Controller for thin endpoints.
  • Choose Route + Controller + Service for most business features.
  • Choose Route + Controller + Service + Repository when the feature talks to persistence.
  • Choose Full when you want interfaces and validation files from the start.