Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Common infrastructure contracts

A single source of truth for inter-service communication schemas.

Protobuf Buf gRPC

Overview

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.

Architecture

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/protovalidate for defining runtime validation constraints directly inside .proto schemas
  • Generated code: Outputs Go packages and C# projects for polyglot backend microservices

Project structure

  • contracts/go/: Generated Go packages (github.com/Aditya-0011/common/contracts/go)
  • contracts/csharp/: Generated C# contracts
  • protos/auth/: Auth service definitions
  • protos/manager/: Manager service definitions
  • protos/wallet/: Wallet service definitions
  • protos/buf.gen.yaml: Buf generation configuration for Go
  • protos/buf.gen.csharp.yaml: Buf generation configuration for C#

Features

This section outlines the capabilities of the schema registry.

  • Centralized schema: Prevents duplication across the microservices infrastructure.
  • Built-in validation: Defines payload constraints using protovalidate annotations.
  • Automated generation: Compiles contracts into usable code packages for multiple languages.
  • Safe evolution: Uses buf breaking to prevent breaking changes to internal APIs.

Getting started

This section explains how to compile the schemas locally.

Prerequisites

  • Buf CLI to work with the .proto files

Generating contracts

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.yaml

To consume the generated Go contracts in a Go service:

go get github.com/Aditya-0011/common/contracts/go

Linting and validation

To check for linting errors or breaking changes:

cd protos
buf lint
buf breaking --against '.git#branch=main'

About

The centralized Protocol Buffer contracts, generated Go/C# structs, and shared middleware.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages