Create Your First Service
This guide walks you through creating services in Devux.
Domain Service
Use for shared business logic within a domain.
Steps
- Run
pnpm devux - Select "Domain Services"
- Select "Create"
- Choose the target domain
- Enter service name (kebab-case, e.g.,
calculate-pricing)
Result
apps/backend/src/domains/orders/services/calculate-pricing/
├── calculate-pricing.ts ← Your service logic
└── tests/
└── calculate-pricing.test.ts
packages/shared/src/shared-app/domains/orders/zod-schemas/calculate-pricing/
└── calculate-pricing.zod.schema.ts ← Input/output schemasApp Service
Use for cross-cutting concerns (email, logging, etc.) that span multiple domains.
Steps
- Run
pnpm devux - Select "App Services"
- Select "Create"
- Enter service name (kebab-case, e.g.,
email-service) - Choose scope: Request scoped or Global
Result
apps/backend/src/app-services/email-service/
├── email-service.ts
├── email-service.interface.ts
└── tests/
└── email-service.test.tsSee App Services for when to use each scope.