Draft

A powerful CLI tool for bootstrapping Go API projects with best practices built-in. Draft helps you quickly scaffold production-ready Go APIs with support for both HTTP (REST) and gRPC architectures.

Features

  • 🚀 Quick Project Scaffolding - Generate complete API projects with a single command
  • 🔄 Multiple API Types - Support for both HTTP (REST) and gRPC architectures
  • 📦 Service Generation - Easily create new services with proper structure
  • 🎯 Handler Generation - Generate HTTP or gRPC handlers on-demand
  • 🔐 Cryptographic Key Generator - Built-in secure key generation
  • 🛠️ Pre-configured Tooling - Automatic installation of essential Go tools
  • 📝 Template-based - Consistent code generation using embedded templates

Installation

From Source

git clone [email protected]:FernandoJVideira/draft.git
cd draft
make build

Build for Different Platforms

# macOS (ARM64)
make mac

# Linux (AMD64)
make linux

# Windows (AMD64)
make windows

# Windows (ARM64)
make win-arm

The compiled binary will be named draft_<os>_<arch> (e.g. draft_darwin_arm64, or draft_windows_amd64.exe on Windows).

Usage

Create a New API Project

draft new api

This interactive command will:

  1. Prompt you for a project name (module name)
  2. Ask you to select an API type (HTTP REST or gRPC)
  3. Scaffold the complete project structure
  4. Install required development tools
  5. Run go mod tidy to organize dependencies

Tools Automatically Installed:

  • air - Live reload for Go apps
  • golangci-lint - Go linters aggregator
  • mockgen - Mock generation for testing
  • sqlc - SQL compiler for type-safe database code
  • migrate - Database migration tool
  • swag - Swagger documentation (HTTP only)
  • protoc-gen-* - Protocol Buffer generators (gRPC only)

Generate a New Service

draft new service

Creates a new service file in internal/service/ with:

  • Service interface definition
  • Service struct implementation
  • Compile-time interface checks

Generate a New Handler

draft new handler

Creates a new handler in the appropriate directory:

  • HTTP handlers → internal/handlers/http/
  • gRPC handlers → internal/handlers/grpc/

Generate a Cryptographic Key

draft new key

Generates a secure random key for use in your application (default: 32 characters).

Check Version

draft version

Project Structure

When you create a new project, Draft generates a structured Go API with:

your-project/
├── cmd/
│   └── api/
│       └── main.go
├── internal/
│   ├── handlers/
│   │   ├── http/    (if HTTP selected)
│   │   └── grpc/    (if gRPC selected)
│   └── service/
├── proto/           (if gRPC selected)
├── pb/              (if gRPC selected)
└── go.mod

Requirements

  • Go 1.25.5 or higher
  • Make (for building from source)

Dependencies

Development

Build

make build

Run with Version Flag

make version

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Built by LKResuts for internal usage to bootstrap Go APIs.

S
Description
No description provided
Readme
153 KiB
0 Stars 0 Watchers 0 Forks
Draft v0.2.3
Latest
2026-10-20 17:20:23 +00:00
Languages
Go 71.2%
Go Template 23.1%
Shell 2.9%
Makefile 2.8%