reflect

module
v0.0.0-...-583a8e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2025 License: MIT

README ΒΆ

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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. 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

Directories ΒΆ

Path Synopsis
cmd
reflect command
internal
config
Package config provides configuration loading and management for Reflect.
Package config provides configuration loading and management for Reflect.
descriptor
Package descriptor provides protobuf descriptor loading, parsing, and registry functionality.
Package descriptor provides protobuf descriptor loading, parsing, and registry functionality.
docs
Package docs provides documentation rendering and search functionality.
Package docs provides documentation rendering and search functionality.
security
Package security provides authentication, CSRF protection, and rate limiting.
Package security provides authentication, CSRF protection, and rate limiting.
tryit
Package tryit provides "Try It" functionality for invoking Connect/gRPC services.
Package tryit provides "Try It" functionality for invoking Connect/gRPC services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL