| Crates.io | schema-registry-server |
| lib.rs | schema-registry-server |
| version | 0.1.0 |
| created_at | 2025-11-23 05:52:25.908542+00 |
| updated_at | 2025-11-23 05:52:25.908542+00 |
| description | Production-ready server for the LLM Schema Registry with gRPC and REST APIs |
| homepage | https://github.com/globalbusinessadvisors/llm-schema-registry |
| repository | https://github.com/globalbusinessadvisors/llm-schema-registry |
| max_upload_size | |
| id | 1946148 |
| size | 232,760 |
A high-performance REST API server for the LLM Schema Registry, built with Axum.
REST API Endpoints:
POST /api/v1/schemas - Register a new schemaGET /api/v1/schemas/:id - Retrieve schema by IDPOST /api/v1/validate/:id - Validate data against schemaPOST /api/v1/compatibility/check - Check schema compatibilityGET /health - Health check endpointPerformance Optimizations:
Observability:
GET /metrics)The server is configured via environment variables:
DATABASE_URL - PostgreSQL connection string (default: postgresql://postgres:postgres@localhost:5432/schema_registry)REDIS_URL - Redis connection string (default: redis://localhost:6379)SERVER_HOST - Server bind address (default: 0.0.0.0)SERVER_PORT - Server port (default: 8080)METRICS_PORT - Prometheus metrics port (default: 9091)# Set environment variables
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/schema_registry"
export REDIS_URL="redis://localhost:6379"
# Run the server
cargo run -p schema-registry-server
The server will:
curl -X POST http://localhost:8080/api/v1/schemas \
-H "Content-Type: application/json" \
-d '{
"subject": "test.schema.user",
"schema": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"}
},
"required": ["id"]
},
"schema_type": "json"
}'
Response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"version": "1.0.0",
"created_at": "2025-01-15T10:30:00Z"
}
curl http://localhost:8080/api/v1/schemas/550e8400-e29b-41d4-a716-446655440000
Response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"namespace": "test.schema",
"name": "user",
"version": "1.0.0",
"format": "JSON",
"schema": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"}
},
"required": ["id"]
},
"content": "{\"type\":\"object\",...}",
"state": "DRAFT",
"compatibility_mode": "BACKWARD",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z"
}
curl -X POST http://localhost:8080/api/v1/validate/550e8400-e29b-41d4-a716-446655440000 \
-H "Content-Type: application/json" \
-d '{
"id": "user123",
"name": "John Doe"
}'
Response:
{
"is_valid": true,
"errors": []
}
curl -X POST http://localhost:8080/api/v1/compatibility/check \
-H "Content-Type: application/json" \
-d '{
"schema_id": "550e8400-e29b-41d4-a716-446655440000",
"compared_schema_id": "660e8400-e29b-41d4-a716-446655440001",
"mode": "BACKWARD"
}'
Response:
{
"is_compatible": true,
"mode": "BACKWARD",
"violations": []
}
curl http://localhost:8080/health
Response:
{
"status": "healthy",
"components": {
"database": {
"status": "up",
"message": null
},
"redis": {
"status": "up",
"message": null
}
}
}
curl http://localhost:9091/metrics
The server is designed to handle the k6 load tests in tests/load/:
# Run basic load test
k6 run tests/load/basic_load.js
# Run stress test
k6 run tests/load/stress_test.js
# Run spike test
k6 run tests/load/spike_test.js
# Run soak test
k6 run tests/load/soak_test.js
┌─────────────┐
│ Client │
└──────┬──────┘
│
▼
┌─────────────────────────────────┐
│ Axum HTTP Server │
│ - Request routing │
│ - JSON serialization │
│ - Error handling │
│ - Tracing middleware │
└──────┬──────────────────────────┘
│
├──────────────┬────────────────┐
│ │ │
▼ ▼ ▼
┌────────────┐ ┌──────────┐ ┌──────────────┐
│ PostgreSQL │ │ Redis │ │ Prometheus │
│ (L2) │ │ (L1) │ │ (Metrics) │
│ │ │ │ │ │
│ - Schemas │ │ - Cache │ │ - /metrics │
│ - Metadata │ │ - 1h TTL │ │ :9091 │
└────────────┘ └──────────┘ └──────────────┘
L1 (Redis): Hot cache with 1-hour TTL
L2 (PostgreSQL): Persistent storage
Migrations are automatically applied on server startup using sqlx. Migration files are in /migrations/:
001_init.sql - Initial schema tables002_performance_indexes.sql - Performance optimizationscargo build -p schema-registry-server
cargo test -p schema-registry-server
RUST_LOG=debug cargo run -p schema-registry-server
For production deployment:
Apache 2.0