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:
usersauthproductsordersbilling
Usage
Run the command from the root of a generated StartXKit project:
npx @startxkit/cli add module usersThe 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 label | Generated files | Use when |
|---|---|---|
| Route + Controller | route, controller | The feature only needs HTTP handlers |
| Route + Controller + Service | route, controller, service | The feature has business logic |
| Route + Controller + Service + Repository | route, controller, service, repository | The feature needs a data access boundary |
| Full | route, controller, service, repository, interface, validator | The 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.tsThis 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.tsThis 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.tsMinimal projects intentionally avoid controllers, services, repositories, interfaces, and validators.
Generated Endpoints
If you choose CRUD endpoints, the module includes:
| Method | Path | Purpose |
|---|---|---|
GET | /users | List records |
GET | /users/:id | Read one record |
POST | /users | Create a record |
PATCH | /users/:id | Update a record |
DELETE | /users/:id | Delete a record |
The final URL also includes your API prefix. With /api/v1, the list endpoint becomes:
GET /api/v1/usersDependency Injection
If dependency injection is enabled, the route file wires the selected layers together:
route
|
v
controller
|
v
service
|
v
repositoryIf 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 + Controllerfor thin endpoints. - Choose
Route + Controller + Servicefor most business features. - Choose
Route + Controller + Service + Repositorywhen the feature talks to persistence. - Choose
Fullwhen you want interfaces and validation files from the start.