Reflect
A modern, web-based protobuf reflection server that provides beautiful documentation for your Protocol Buffer services.
Features
- π Instant Setup: Point to your
.proto files and get documentation immediately
- π¨ Modern UI: Beautiful, responsive interface with Tailwind CSS
- π Dark Mode: Built-in light/dark mode toggle with system preference detection
- π Rich Documentation: Displays service, method, and field descriptions from proto comments
- π HTTP Mappings: Shows
google.api.http annotations and generates example requests
- π Copy-Paste Ready: One-click copy for
curl and grpcurl commands
- π Type Navigation: Deep linking between services, methods, and types
- π± Mobile Friendly: Responsive design that works on all devices
Quick Start
Installation
git clone <repository-url>
cd reflect
go build ./cmd/reflect
Usage
# Basic usage - point to your proto files
./reflect --proto-root=./protos
# With include paths for dependencies
./reflect --proto-root=./protos --proto-include=./third_party
# Custom port
./reflect --proto-root=./protos --addr=:8080
Then open http://localhost:8080 in your browser.
Command Line Options
| Option |
Description |
Default |
--proto-root |
Root directory containing .proto files |
Required |
--proto-include |
Additional include directories (can be used multiple times) |
None |
--addr |
Address to listen on |
:8080 |
Example Proto Files
Here's what your proto files should look like to get the best documentation:
syntax = "proto3";
package echo.v1;
import "google/api/annotations.proto";
// EchoService provides simple echo functionality with HTTP annotations.
service EchoService {
// Echo echoes back the received message.
rpc Echo(EchoRequest) returns (EchoResponse) {
option (google.api.http) = {
post: "/v1/echo"
body: "*"
};
}
}
// EchoRequest contains the message to echo.
message EchoRequest {
// The message to echo back.
string message = 1;
}
// EchoResponse contains the echoed message.
message EchoResponse {
// The echoed message.
string message = 1;
}
Architecture
Reflect consists of several key components:
Core Components
- Descriptor Package (
internal/descriptor/): Loads and parses .proto files using protoparse
- Registry (
internal/descriptor/registry.go): Indexes services, methods, and types with full names
- Documentation Models (
internal/docs/): Builds view models for templates
- Web Server (
internal/server/): Serves HTML documentation with Tailwind CSS styling
Key Features
- Comment Extraction: Automatically extracts and displays proto comments as descriptions
- HTTP Annotation Support: Shows REST API mappings from
google.api.http options
- Example Generation: Creates ready-to-use
curl and grpcurl commands
- Type Linking: Deep navigation between related types and services
Development
Prerequisites
- Go 1.21+
- Node.js (for Tailwind CSS compilation)
Building CSS
The project uses Tailwind CSS for styling. To rebuild the CSS:
npm install
npm run build-css
# Or watch for changes during development
npm run watch-css
Running Tests
go test ./...
Project Structure
reflect/
βββ cmd/reflect/ # Main application entry point
βββ internal/
β βββ descriptor/ # Proto file loading and registry
β βββ docs/ # Documentation model builders
β βββ server/ # Web server and templates
βββ ARCHITECTURE.md # Detailed architecture documentation
βββ CHECKLIST.md # Development progress tracking
βββ README.md # This file
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
See LICENSE file for details.
Acknowledgments
- Built with Go and Tailwind CSS
- Uses protoparse for proto file parsing
- Inspired by the need for better protobuf documentation tools