Skip to content

feat: migrate to buf connect #1028

@whoAbhishekSah

Description

@whoAbhishekSah

Overview

Migrate Frontier's API implementation from gRPC + gRPC Gateway to buf connect.

Why

Buf connect offers several key advantages:

Proof of Concept

We have validated the buf connect approach in this example repository, which demonstrates:

  • Web clients directly calling the Connect RPC server without an intermediate proxy
  • Working streaming calls from web clients
  • TypeScript client generation using buf connect stubs instead of Swagger-generated JS clients
  • Existing gRPC clients working with the Connect server without code changes

These findings confirm that Buf Connect can significantly simplify our architecture while maintaining compatibility.

  1. Flexible Protocol Support

    • Works over HTTP/1.1, HTTP/2, and HTTP/3
    • Supports both JSON and binary Protobuf encoding
    • Direct communication using the standard fetch API
    • No need for gRPC-Web or special proxies
    • Better browser developer tools support with JSON
  2. Streamlined Development

    • Single unified API surface instead of separate gRPC and REST endpoints
    • Reduced boilerplate code
    • Simpler contract between the server and the clients
    • TypeScript-first design for better frontend integration
  3. Performance Benefits

    • Lighter-weight protocol than gRPC
    • Reduced latency without protocol buffers overhead
    • Native JSON handling

Implementation Steps

The migration will be done in two phases, targeting different service groups:

Phase 1: Admin Service Migration

  1. Set up the buf connect plugin and dependencies
  2. Generate connect stubs for Admin service proto definitions
  3. Create connection service handlers for Admin endpoints
  4. Update server initialisation for Admin connect handlers
  5. Update Admin-related React components in sdks/js/core
  6. Test and validate Admin service migration

Phase 2: Frontier Service Migration

  1. Generate connect stubs for Frontier service proto definitions
  2. Create connection service handlers for Frontier endpoints
  3. Update server initialisation for Frontier connect handlers
  4. Update Frontier-related React components in sdks/js/core
  5. Remove gRPC gateway dependencies and configuration
  6. Update documentation for new API patterns
  7. Test and validate Frontier service migration

SDK Simplification

The migration eliminates the need to generate complex SDK code, such as sdks/js/packages/core/api-client/v1beta1.ts. Instead, we can use the lightweight connect client stubs generated using:

  • @bufbuild/connect-web@v0.8.6
  • @bufbuild/protobuf@v1.3.0

This provides a more straightforward, more maintainable approach with:

  • Direct HTTP/JSON RPC calls using the generated stubs
  • Type-safe request/response structures
  • Reduced code complexity and maintenance burden

Additional Considerations

  • Configure separate ports for gRPC and Connect servers during migration (Connect supports HTTP/1.1, HTTP/2, and HTTP/3 with both JSON and binary Protobuf encoding)
  • Run both servers in parallel during the transition period for backwards compatibility
  • Update CI/CD pipeline for connect builds
  • Update deployment configurations to expose both ports until migration is complete

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions