nameencore-servicedescriptionImplement Encore.ts services and lay out an application using `encore.service.ts`, service directories, systems, and `~encore/clients`. For service boundaries and architecture decisions, use `encore-architecture`.when_to_useUser wants to add or modify an Encore.ts service or microservice, implement an already-chosen service layout, organize service files and directories, group services into system folders, or call another service. Trigger phrases: "add a service", "create a service", "add a microservice", "encore.service.ts", "lay out these services", "service directory", "systems folder", "~encore/clients".
Encore Service Structure
Instructions
Creating a Service
Every Encore service needs an encore.service.ts file:
typescript
// encore.service.ts
import { Service } from "encore.dev/service";
export default new Service("my-service");
Minimal Service Structure
text
my-service/
├── encore.service.ts # Service definition (required)
├── api.ts # API endpoints
└── db.ts # Database (if needed)
Application Patterns
Single Service
A service can be defined at the application root:
text
my-app/
├── package.json
├── encore.app
├── encore.service.ts
├── api.ts
├── db.ts
└── migrations/
└── 001_initial.up.sql