API
Overview
Build APIs in a feature-first way with oRPC.
AI Skill for features
Prompt: Type
/features in your Copilot / Cursor or other chat to use skill with the provided context./features Create a new feature "[featureName]" in `src/features/{scope}/[featureName]` where scope is one of: web, admin, dashboard, common.
Requirements:
- Use the standard feature structure from ai/skills/feature.md.
- Add model, service, and api folders.
- Optionally add actions for server actions.
- Define oRPC router and wire it in src/lib/orpc/router.ts.API workflow in this project
We use oRPC and a feature-based structure.
A typical API feature lives here:
src/features/web/todo/Inside a feature, your API usually has:
model/for schemas and typesservice/for business logicapi/for oRPC routeractions/for optional server actions
Recommended order
- Define schemas in
model/. - Define business logic in
service/. - Define oRPC routes in
api/{feature}.router.ts.
Optional steps
- Add server actions in
actions/{feature}.tsfor SSR-oriented flows. - Expose router from
src/lib/orpc/router.ts. - Verify OpenAPI output at
/openapi.json.