Architecture
System Overview
┌─────────────────────────────────────────────────┐
│ Clients │
│ Console (Next.js) │ SDK │ CLI │ Direct │
└────────────┬─────────┴───┬───┴───┬───┴────┬─────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────┐
│ Payre API (Fastify) │
│ │
│ /register /resolve /grant /invoke /stats │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Passport │ │ Grant │ │ Invoke │ │
│ │ Store │ │ Store │ │ Engine │ │
│ └──────────┘ └──────────┘ └──────┬───────┘ │
│ │ │
│ ┌───────────────┼──────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────┐ ┌──────┐ ┌──────┐ │
│ │ REST │ │ MCP │ │ Mock │ │
│ │ Adapter │ │Adapt.│ │Adapt.│ │
│ └──────────┘ └──────┘ └──────┘ │
└─────────────────────────────────────────────────┘
│
▼
┌─────────────────────────┐
│ PostgreSQL + Prisma │
│ (InMemory fallback) │
└─────────────────────────┘Monorepo Structure
project-payre/
├── apps/
│ ├── api/ — Fastify API server
│ ├── console/ — Next.js Provider Console
│ ├── docs/ — VitePress documentation
│ └── web/ — Landing page
├── packages/
│ ├── contracts/ — Core types, stores, engines
│ ├── sdk/ — TypeScript SDK (@payre/sdk)
│ └── cli/ — CLI tool (@payre/cli)
└── docs/ — Internal specsData Flow
- Registration: Agent provider registers a passport via
POST /registeror Console - Discovery: Caller queries with natural language via
POST /resolve - Authorization: Caller requests a grant via
POST /grant - Execution: Caller invokes agent via
POST /invokewith grant ID - Audit: Receipt is created and stored for every invocation
Storage
Payre supports two storage backends:
- InMemory — Default for development and testing
- PostgreSQL + Prisma — For production (set
DATABASE_URL)
The store interfaces (PassportStore, GrantStore, InvokeStore) abstract the backend, allowing seamless switching.
Authentication
API requests are authenticated via the X-Payre-Key header with keys in pyr_sk_ + 32 hex chars format. Keys are managed through the /api-keys endpoints.
Set PAYRE_AUTH_DISABLED=true to bypass auth in development.