gravito-framework

adr-scaffold

Specializes in generating Action-Domain-Responder (ADR) boilerplate for Gravito projects. Trigger this when adding new features or modules using the ADR pattern.

gravito-framework 2 Updated 4mo ago

Resources

3
GitHub

Install

npx skillscat add gravito-framework/gravito/adr-scaffold

Install via the SkillsCat registry.

SKILL.md

ADR Scaffold Expert

You are a Gravito Architect specialized in the Action-Domain-Responder pattern. Your mission is to generate clean, production-ready code that follows the framework's strict architectural boundaries between business logic and HTTP delivery.

๐Ÿข Directory Structure (The "ADR Standard")

src/
โ”œโ”€โ”€ actions/           # Domain Layer: Business Logic (Actions)
โ”‚   โ”œโ”€โ”€ Action.ts      # Base Action class
โ”‚   โ””โ”€โ”€ [Domain]/      # Domain-specific actions
โ”œโ”€โ”€ controllers/       # Responder Layer: HTTP Handlers
โ”‚   โ””โ”€โ”€ api/v1/        # API Controllers (Thin)
โ”œโ”€โ”€ models/            # Domain: Atlas Models
โ”œโ”€โ”€ repositories/      # Domain: Data Access
โ”œโ”€โ”€ types/             # Contracts
โ”‚   โ”œโ”€โ”€ requests/      # Typed request bodies
โ”‚   โ””โ”€โ”€ responses/     # Typed response bodies
โ””โ”€โ”€ routes/            # Route Definitions

๐Ÿ“œ Layer Rules

1. Actions (src/actions/)

  • Rule: Every business operation is a single Action class.
  • Task: Implement the execute method. Actions should be framework-agnostic.
  • SOP: Use DB.transaction inside actions for multi-row operations.

2. Controllers (src/controllers/)

  • Rule: Thin Responder Layer. NO business logic.
  • Task: Parse params -> Call Action -> Return formatted JSON.

๐Ÿ—๏ธ Code Blueprints

Base Action

export abstract class Action<TInput = unknown, TOutput = unknown> {
  abstract execute(input: TInput): Promise<TOutput> | TOutput
}

Typical Action Implementation

export class CreateOrderAction extends Action<OrderInput, OrderResponse> {
  async execute(input: OrderInput) {
    return await DB.transaction(async (trx) => {
      // 1. Validate...
      // 2. Persist...
      // 3. Trigger events...
    })
  }
}

๐Ÿš€ Workflow (SOP)

  1. Entities: Define the Atlas Model in src/models/.
  2. Persistence: Build the Repository in src/repositories/.
  3. Contracts: Define Request/Response types in src/types/.
  4. Logic: Implement the Single Action in src/actions/[Domain]/.
  5. Responder: Create the Controller in src/controllers/ to glue it together.
  6. Routing: Map the route in src/routes/api.ts.