DevOps Schema Registry Project
Tools commonly used in industry and student projects for contract-driven streaming pipelines.
Without a registry, each team embeds ad-hoc JSON and breaks downstream jobs silently. A Schema Registry stores versioned schemas by subject (usually topic-key / topic-value), assigns integer IDs, and answers compatibility questions before a new version is accepted.
- Single source of truth for event contracts across microservices
- Safe evolution — add fields with defaults; reject destructive renames when policy is BACKWARD/FULL
- Wire efficiency — Avro/Protobuf payloads carry schema ID, not the full schema every time
- DevOps fit — CI jobs call the registry API as a required merge check
- Producers serialize with a specific schema version; message magic byte + schema ID prefix the payload (Confluent wire format).
- Registry may store schemas in a Kafka topic (
_schemas) or an external database depending on deployment. - Consumers resolve ID → schema (with local cache) and apply reader schema for projection/defaults.
Avro
Most common with Kafka. Rich logical types (timestamps, decimals). Excellent default-based evolution. Typical for analytics pipelines.
Protobuf
Strong for polyglot microservices and gRPC-adjacent stacks. Field numbers provide stable wire IDs. Registry stores .proto or FileDescriptor sets.
JSON Schema
Human-readable; good for REST-ish events. Heavier payloads; still benefits from ID-based versioning and compatibility checks.
Subject naming
Convention: <topic>-value / <topic>-key, or TopicRecordName strategy for multiple event types per topic.
| Mode | Meaning | Typical use |
|---|---|---|
| BACKWARD | New schema can read data written with previous schema | Default for most consumer-first teams |
| FORWARD | Previous schema can read data written with new schema | Producer upgrades lag consumers |
| FULL | Both BACKWARD and FORWARD | Strict shared platforms |
| NONE | No checks | Local experiments only |
#!/usr/bin/env bash set -euo pipefail SUBJECT="orders-value" REGISTRY="${SCHEMA_REGISTRY_URL}" CANDIDATE="schemas/orders-v13.avsc" # 1) Syntax / parse (avro-tools or language lib) python -c "import json,sys; json.load(open('${CANDIDATE}'))" # 2) Compatibility check against latest curl -s -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data "{\"schema\":$(jq -c -R -s '.' ${CANDIDATE})}" \ "${REGISTRY}/compatibility/subjects/${SUBJECT}/versions/latest" \ | tee /tmp/compat.json grep -q '"is_compatible":true' /tmp/compat.json # 3) Optional dry-run register in CI-only context echo "Schema gate PASSED for ${SUBJECT}"
main. Store schemas as code next to producers. Prefer BACKWARD or FULL at the subject level; override only with documented migration plans.
- Module 1: Docker Compose — Kafka + Schema Registry + sample UI/API
- Module 2: Define Avro schemas for 2–3 topics; register subjects; produce/consume with schema ID
- Module 3: Demonstrate a breaking change that fails BACKWARD check; then a safe additive change that passes
- Module 4: GitHub Actions / GitLab CI job that runs compatibility against a staging registry
- Module 5: Metrics — register latency, cache hit rate, failed compatibility counts (Prometheus exporters where available)
- Deliverables: Architecture diagram, schema repo, CI YAML, demo script, report & viva notes
{
"type": "record",
"name": "Order",
"namespace": "com.example.orders",
"fields": [
{ "name": "orderId", "type": "string" },
{ "name": "amount", "type": "double" },
{ "name": "currency", "type": "string", "default": "INR" },
{ "name": "createdAt", "type": "long", "logicalType": "timestamp-millis" }
]
}