Example Contracts
This section provides ready-to-use Pacto contracts for common infrastructure services. Use these as references when writing your own contracts or as dependencies in your service contracts.
For a complete working demo repository, see pacto-demo.
Table of contents
These contracts represent the operational interface of each service — not a deployment recipe. They describe what the service exposes, how it behaves, and what the platform needs to know.
Available examples
| Service | Type | State | Description |
|---|---|---|---|
| PostgreSQL | service | stateful/persistent | Relational database |
| Redis | service | stateful/persistent | In-memory data store |
| RabbitMQ | service | stateful/persistent | Message broker |
| NGINX | service | stateless/ephemeral | Reverse proxy / web server |
| Cron Worker | scheduled | stateless/ephemeral | Scheduled batch job |
| Event Processor | service | stateless/ephemeral | Event-driven message consumer |
| gRPC Service | service | stateless/ephemeral | gRPC microservice with Proto contract |
| Hybrid Cache API | service | hybrid/persistent | API with local cache and upstream rebuild |
Using examples as dependencies
You can reference these contracts (once published to a registry) as dependencies in your own pacto.yaml:
dependencies:
- ref: oci://ghcr.io/acme/postgres-pacto@sha256:abc123
required: true
compatibility: "^16.0.0"
- ref: oci://ghcr.io/acme/redis-pacto@sha256:def456
required: false
compatibility: "^7.0.0"
Then use pacto graph to visualize the full dependency tree:
pacto graph .