-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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.
-
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
-
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
-
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
- Set up the buf connect plugin and dependencies
- Generate connect stubs for Admin service proto definitions
- Create connection service handlers for Admin endpoints
- Update server initialisation for Admin connect handlers
- Update Admin-related React components in
sdks/js/core
- Test and validate Admin service migration
Phase 2: Frontier Service Migration
- Generate connect stubs for Frontier service proto definitions
- Create connection service handlers for Frontier endpoints
- Update server initialisation for Frontier connect handlers
- Update Frontier-related React components in
sdks/js/core
- Remove gRPC gateway dependencies and configuration
- Update documentation for new API patterns
- 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
Labels
enhancementNew feature or requestNew feature or request