application-service

Orchestrate validate, persist, and enqueue workflows for zoppy-api Application Services.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/Zoppy-crm/.github --skill application-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: application-service
Source: https://github.com/Zoppy-crm/.github/tree/main/skills/backend/application-service
Command: npx skills add https://github.com/Zoppy-crm/.github --skill application-service

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a clear, consistent pattern for implementing Application Services in zoppy-api so developers can orchestrate business workflows without leaking infrastructure concerns and avoid common mistakes like reading companyId from requests or bypassing domain responsibilities.

Core Features & Use Cases

  • Orchestration pattern: Standardizes the validate → persist → enqueue flow for write use cases and ensures Response DTOs are returned.
  • Dependency injection & registration: Describes required constructor injections (domains, queue services, session, logService) and how to register providers and exports in ApplicationModule.
  • Error handling and DTO conventions: Recommends NestJS exceptions for business errors, using response DTOs instead of entities, and when to call repositories directly.
  • Use Case Example: Implement a CampaignApplication that validates feature flags, saves via CampaignDomain, enqueues a processing job, and returns a CampaignResponse DTO.

Quick Start

Create a new Application Service in src/application that validates business rules, persists via the appropriate Domain, enqueues any required jobs, returns a Response DTO, and registers the service in ApplicationModule.

Frequently Asked Questions about application-service

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I orchestrate application service workflows in NestJS without leaking infrastructure concerns?

Orchestrate application service workflows by validating input, persisting through domain services, and enqueuing background jobs. This pattern returns response DTOs and uses NestJS exceptions for business errors to keep infrastructure concerns out of the application layer.

What is the best way to structure dependency injection for a NestJS application service?

Structure dependency injection by adding constructor injections for domains, queue services, session, and logService. Register the application service as a provider and export it in the ApplicationModule to ensure all required domain and queue dependencies are available.

How do I handle business errors and return data from a NestJS application service?

Handle business errors by throwing NestJS exceptions for business rule violations. Return data by mapping domain entities to response DTOs instead of returning raw entities directly from the application service to the controller layer.

When should I call repositories directly from an application service instead of going through the domain?

Call repositories directly from an application service only when the operation does not involve business rules or domain logic. For use cases requiring validation or business behavior, always persist data through the appropriate domain service instead.

Can I use an application service to enqueue background jobs after persisting data in NestJS?

Yes, you can enqueue background jobs after persisting data by injecting queue services into your application service. The standard flow validates input, saves data via the domain service, and then enqueues any required processing jobs before returning a response DTO.