Code Generation

You get a working connector adapter in hours instead of weeks. Prism uses Grace, a code generation tool that reads payment provider API specs and produces Rust connector integration code with proper request/response transformations.

The Problem with Manual Integration

Writing a connector adapter requires understanding:

  • The payment provider's authentication scheme

  • How their API maps to unified types (amounts, currencies, payment methods)

  • Error code mappings

  • Webhook payload structures

  • Testing patterns

For a typical connector like Stripe or Adyen, this is 2,000-5,000 lines of Rust code. Done manually, it takes weeks and introduces bugs. Grace automates the repetitive 80% so developers focus on the interesting 20%.

Grace Architecture

Grace has two interfaces: a CLI tool and a skill/prompt system for LLMs.

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│   API Spec      │────▶│  Grace Parser    │────▶│  Rust Adapter   │
│ (OpenAPI/JSON)  │     │  + Templates     │     │  Code           │
└─────────────────┘     └──────────────────┘     └─────────────────┘
         │                       │                        │
         ▼                       ▼                        ▼
   Provider docs           LLM Skill              Connector-specific
   and examples           augmentation             business logic

CLI Usage

Generate a connector scaffold from an OpenAPI spec:

The CLI produces:

  • connector.rs — The adapter struct and trait implementation

  • transformers.rs — Request/response mapping functions

  • types.rs — Connector-specific type definitions

  • test.rs — Generated test scaffolding

LLM Skill Integration

Grace includes a skill definition that any LLM can use. Connect your own model:

The skill prompt includes:

  • Prism's unified type system

  • Common transformation patterns

  • Error mapping conventions

  • Rust code templates

Your LLM generates code that follows Prism conventions without training on proprietary code.

What Gets Generated

Request Transformers

Response Transformers

Error Mapping

Customization Points

Generated code includes TODO markers for connector-specific logic:

You fill in the blanks. The boilerplate structure is done.

Validation

Grace validates generated code:

  • Type checks against Prism interfaces

  • Serialization roundtrips (unified → connector → unified)

  • Required field coverage

  • Error case handling

Adding a New Connector

A basic connector adapter takes 1-2 days instead of 2-3 weeks.

Benefits

  • Speed: Days instead of weeks for new connectors

  • Consistency: All adapters follow the same patterns

  • Correctness: Generated code passes type checks and validation

  • Maintainability: Update the spec, regenerate the code

  • Flexibility: Bring your own LLM, no vendor lock-in

Connector integration becomes configuration, not implementation.

Last updated

Was this helpful?