A single source of truth for inter-service communication schemas.
The common repository acts as the central Protocol Buffers (.proto) schema registry for the platform. It provides type-safe and validated communication between the REST API gateway and the internal gRPC microservices (auth, manager, and wallet). Centralizing the contracts ensures that the headless portfolio CMS, the identity provider, and the wallet ecosystem stay strictly synchronized across languages.
This section explains the technologies and physical layout of the contracts repository.
- Schema definition: Standard Protocol Buffers v3
- Build tooling: Uses Buf for linting, formatting, breaking change detection, and generating client and server stubs
- Validation: Integrates
buf.build/go/protovalidatefor defining runtime validation constraints directly inside.protoschemas - Generated code: Outputs Go packages and C# projects for polyglot backend microservices
contracts/go/: Generated Go packages (github.com/Aditya-0011/common/contracts/go)contracts/csharp/: Generated C# contractsprotos/auth/: Auth service definitionsprotos/manager/: Manager service definitionsprotos/wallet/: Wallet service definitionsprotos/buf.gen.yaml: Buf generation configuration for Goprotos/buf.gen.csharp.yaml: Buf generation configuration for C#
This section outlines the capabilities of the schema registry.
- Centralized schema: Prevents duplication across the microservices infrastructure.
- Built-in validation: Defines payload constraints using
protovalidateannotations. - Automated generation: Compiles contracts into usable code packages for multiple languages.
- Safe evolution: Uses
buf breakingto prevent breaking changes to internal APIs.
This section explains how to compile the schemas locally.
- Buf CLI to work with the
.protofiles
To compile the schemas locally for Go and C#, navigate to the protos directory:
cd protos
buf generate --template buf.gen.yaml
buf generate --template buf.gen.csharp.yamlTo consume the generated Go contracts in a Go service:
go get github.com/Aditya-0011/common/contracts/goTo check for linting errors or breaking changes:
cd protos
buf lint
buf breaking --against '.git#branch=main'