Skip to content

Example Projects

Bufrnix includes several example projects that demonstrate how to use Protocol Buffers with different languages and frameworks. These examples are complete, working projects that you can use as starting points for your own applications.

A basic example demonstrating Go gRPC server and client communication.

  • Simple gRPC server and client implementation
  • User service with create and get operations
  • In-memory storage for demonstration purposes
  • Error handling and validation

Check out the simple-flake example on GitHub.

Terminal window
# Navigate to the example directory
cd examples/simple-flake
# Generate the proto code
nix run .#packages.x86_64-linux.bufrnix generate
# Run the example
go run main.go

Demonstrates using Protocol Buffers with Node.js and TypeScript.

  • TypeScript support with type definitions
  • Modern ES modules
  • Simple client implementation
  • Integration with npm packages

Check out the js-example on GitHub.

Terminal window
# Navigate to the example directory
cd examples/js-example
# Generate the proto code
nix develop -c bufrnix generate
# Install dependencies
npm install
# Run the example
npm start

Shows how to use Protocol Buffers with Dart and gRPC for Flutter or server applications.

  • Dart class generation for Protocol Buffers
  • gRPC client implementation
  • Compatible with Flutter applications
  • Demo of async/await usage with gRPC

Check out the dart-example on GitHub.

Terminal window
# Navigate to the example directory
cd examples/dart-example
# Generate the proto code
nix develop -c bufrnix generate
# Run the example
dart lib/main.dart

Demonstrates using Protocol Buffers with PHP and the Twirp RPC framework.

  • PHP class generation for Protocol Buffers
  • Twirp HTTP server and client
  • Composer integration
  • Simple API implementation

Check out the php-twirp example on GitHub.

Terminal window
# Navigate to the example directory
cd examples/php-twirp
# Generate the proto code
nix develop -c bufrnix generate
# Install dependencies
composer install
# Run the example (implementation may vary)
php -S localhost:8080 -t public

To create your own example:

  1. Set up a new directory with a flake.nix file
  2. Add Bufrnix as an input
  3. Configure Bufrnix for your target languages
  4. Create your .proto files in the appropriate directory
  5. Run nix develop -c bufrnix generate to generate code
  6. Implement your application using the generated code

You can use any of the existing examples as a starting point for your own project.

Demonstrates basic Protocol Buffers usage with C# and .NET.

  • C# class generation for Protocol Buffers
  • Binary and JSON serialization
  • Nested messages and enums
  • Generated .csproj file for easy integration

Check out the csharp-basic on GitHub.

Terminal window
# Navigate to the example directory
cd examples/csharp-basic
# Generate the proto code
nix build .#proto
./result/bin/bufrnix
# Build and run the example
nix run

Shows how to build gRPC services with C# and ASP.NET Core.

  • gRPC service implementation with ASP.NET Core
  • Client console application
  • Unary and streaming RPC examples
  • Modern .NET 8.0 integration

Check out the csharp-grpc on GitHub.

Terminal window
# Navigate to the example directory
cd examples/csharp-grpc
# Generate the proto code
nix build .#proto
./result/bin/bufrnix
# Run the server (in one terminal)
nix run .#server
# Run the client (in another terminal)
nix run .#client

Demonstrates using flake-parts with Bufrnix for C# projects.

  • Uses flake-parts for modular flake configuration
  • Generates a .NET project with Protocol Buffers

Check out the csharp-flake-parts on GitHub.

Terminal window
# Navigate to the example directory
cd examples/csharp-flake-parts
# Generate the proto code
nix build .#proto
# Build and run the example
nix run .#app

Demonstrates basic Protocol Buffers usage with Kotlin.

  • Kotlin DSL builders for message creation
  • Immutable message updates with copy
  • Type-safe builders and null safety
  • Generated Gradle build file

Check out the kotlin-basic on GitHub.

Terminal window
# Navigate to the example directory
cd examples/kotlin-basic
# Generate the proto code
nix build .#proto
./result/bin/bufrnix
# Build and run with Gradle
cd gen/kotlin
gradle run

Shows how to build gRPC services with Kotlin coroutines.

  • Coroutine-based gRPC services
  • Flow-based streaming APIs
  • Unary and streaming RPC examples
  • Modern Kotlin idioms

Check out the kotlin-grpc on GitHub.

Terminal window
# Navigate to the example directory
cd examples/kotlin-grpc
# Generate the proto code
nix build .#proto
./result/bin/bufrnix
# Run the server (in one terminal)
cd gen/kotlin && gradle runServer
# Run the client (in another terminal)
cd gen/kotlin && gradle runClient

Demonstrates using Protocol Buffers with Swift for iOS, macOS, and server applications.

  • Swift struct generation with Codable support
  • Type-safe Protocol Buffer messages
  • SwiftProtobuf integration
  • Compatible with SwiftPM and Xcode projects

Check out the swift-example on GitHub.

Terminal window
# Navigate to the example directory
cd examples/swift-example
# Generate the proto code
nix develop -c bufrnix_init && bufrnix
# Build and run the example
swift build
swift run