Skip to content

apmitchell/fw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fw — Single‑source schema → full‑stack codegen for Go + React

A rails‑style DX for Go + React. Define your data once (Protobuf) and automatically get a Go API, DB models & migrations, a typed TS client with React Query hooks, and scaffolded CRUD UI components.

FW Logo

Elevator pitch

Stop wiring the same types, validators, handlers, queries, and hooks in three places. With fw, one schema produces everything you need—from database to browser—while keeping end‑to‑end types safe and codegen idempotent.

  • One source of truth: /schema/**/*.proto.
  • Generated automatically: ConnectRPC services, Ent models/migrations, TS SDK + React Query hooks, CRUD scaffolds.
  • Customize safely: write business logic in service handlers; style UI with your own components.
  • Drift control: fw gen ensures generated code stays in sync with schemas.

Why this exists

  • Schema drift and copy‑paste glue across DB ↔ server ↔ client.
  • Manual wiring of types, validation, and API handlers across multiple files.
  • Slow time‑to‑first‑CRUD for Go teams that want a modern React front end.

fw composes Buf + ConnectRPC + Ent + Atlas + Vite + TanStack Query into one cohesive experience.


What you get

  • Go server (ConnectRPC over HTTP/JSON) with request validation.
  • DB layer: Ent models + Atlas schema migrations.
  • Typed TS client + React Query hooks (useListUsers, useCreateUser, …).
  • CRUD UI scaffolds for List / Detail / Create / Edit pages.
  • Dev workflow: hot reload (Air, Vite), Docker Compose, structured logging.

Quick Start

# 1. Install core tools (one-time setup)
brew install go node pnpm bufbuild/buf/buf protobuf docker

# 2. Build the CLI
go build -o bin/fw .

# 3. Create a new project
./bin/fw init blog

# 4. Generate code (auto-installs dev tools on first run)
cd blog && ../bin/fw gen
# 📦 Installing atlas... ✅ Done
# 📦 Installing air... ✅ Done  
# 📦 Installing protoc-gen-*... ✅ Done
# ✅ Code generation complete!

# 5. Verify everything is ready
../bin/fw doctor
# ✅ All tools available!

Installation

# Clone and build
git clone https://github.com/apmitchell/fw
cd fw
go build -o bin/fw .

# Optional: Add to PATH for global access
sudo cp bin/fw /usr/local/bin/

# Or run directly
./bin/fw --help

Prerequisites

Before using fw, ensure you have the following installed:

# Core development tools
brew install go node pnpm

# Protobuf and code generation
brew install buf protobuf

# Database and dev tools (optional but recommended)
brew install atlas-go cosmtrek/tap/air docker

# Verify installation
./bin/fw doctor

CLI Commands

Command Description Example
fw init [name] Create new project fw init blog
fw setup Install fw toolchain fw setup
fw doctor Check dev environment fw doctor
fw gen Generate code from schemas fw gen
fw dev Start development servers fw dev
fw migrate-up Apply migrations fw migrate-up

Command Options

# Custom module path and npm scope
fw init myapp --module github.com/me/myapp --scope @me

Toolchain Management

fw uses a hybrid toolchain approach for the best developer experience:

Core Tools (Install Once via Homebrew)

brew install go node pnpm bufbuild/buf/buf protobuf docker

Auto-Installed Dev Tools

fw automatically installs these to ~/.fw/tools/ when needed:

  • Atlas: Database schema migrations (via Homebrew tap, fallback to go install)
  • Air: Hot reloading for Go development
  • protoc-gen-go: Protocol buffer Go code generator
  • protoc-gen-connect-go: ConnectRPC Go code generator

Verification

fw doctor  # Checks core tools + shows auto-install status

Template Synchronization

fw automatically keeps your project in sync with framework improvements:

Auto-Updating Templates

Whenever you run fw gen, the framework:

  1. Updates framework-managed files: package.json, tsconfig.json, Makefile, etc.
  2. Preserves your code: Business logic, components, and user-written files remain untouched
  3. Resolves dependencies: Automatically adds required packages (like @bufbuild/protobuf)
  4. Fixes conflicts: Resolves common issues like duplicate exports

What Gets Updated

Always synced (framework-managed):

  • packages/sdk-ts/package.json — SDK dependencies and configuration
  • packages/sdk-ts/src/index.ts — Generated exports and re-exports
  • Build configuration files (tsconfig.json, Makefile, etc.)
  • Docker and development configs

Never touched (user-owned):

  • Service handlers in server/internal/service/
  • React components in web/src/
  • Database schemas in server/internal/ent/schema/
  • Custom business logic

Benefits

  • Stay current with framework improvements automatically
  • No manual config updates when dependencies change
  • Safe upgrades without breaking existing functionality
  • Consistent tooling across all generated projects

Generated Project Structure

fw init [name] creates this complete project structure:

myapp/
├── 📁 schema/                    # 🎯 Protobuf schemas (single source of truth)
│   ├── buf.yaml                  # Buf configuration
│   ├── buf.gen.yaml             # Code generation config
│   ├── common/v1/paging.proto   # Shared types (pagination, filters)
│   ├── error/v1/problem.proto   # Error handling schemas
│   └── user/v1/user.proto       # User service definition
├── 📁 server/                    # 🔧 Go API server
│   ├── go.mod                    # Go dependencies
│   ├── cmd/
│   │   ├── api/main.go          # HTTP server entrypoint
│   │   └── seed/main.go         # Database seeder
│   └── internal/
│       ├── app/config.go        # Configuration helpers
│       ├── ent/schema/          # Database schemas (Ent ORM)
│       │   ├── user.go          # User entity schema
│       │   └── mixin/           # Reusable schema components
│       ├── service/             # Business logic handlers
│       │   └── user_service.go  # User service implementation
│       └── transport/           # HTTP transport layer
│           ├── errors.go        # Error handling
│           └── validate.go      # Request validation
├── 📁 web/                       # ⚛️ React frontend
│   ├── package.json             # Frontend dependencies
│   ├── vite.config.ts          # Vite configuration
│   ├── tsconfig.json           # TypeScript configuration
│   ├── index.html              # HTML entry point
│   └── src/
│       ├── main.tsx            # React app entry
│       ├── App.tsx             # Main app component
│       ├── features/users/     # User management components
│       │   └── List.tsx        # User list component
│       └── lib/api/
│           └── client.ts       # ConnectRPC client setup
├── 📁 packages/sdk-ts/           # 📦 TypeScript SDK package
│   ├── package.json             # SDK package configuration
│   ├── tsconfig.json           # SDK TypeScript config
│   └── src/
│       ├── index.ts            # SDK exports
│       └── error.ts            # Error handling utilities
├── 📁 db/                        # 🗺️ Database configuration
│   └── atlas.hcl               # Atlas migration config
├── 📄 Root configuration files
│   ├── package.json            # Workspace configuration
│   ├── pnpm-workspace.yaml    # pnpm workspace setup
│   ├── Makefile                # Development commands
│   ├── docker-compose.yml     # PostgreSQL for development
│   ├── .env.example           # Environment variables template
│   ├── .air.toml              # Hot reload configuration
│   ├── .nvmrc                  # Node.js version specification
│   ├── .gitignore             # Git ignore patterns
│   └── README.md               # Project-specific documentation

Key Features of Generated Structure:

  • Monorepo setup with pnpm workspaces
  • ConnectRPC integration between Go server and React client
  • Ent ORM with schema definitions and mixins
  • Complete development workflow with hot reload and code generation
  • Production-ready configuration for Docker, CI/CD, and deployment

Current Status

✅ Implemented (Works Today)

  • CLI framework with all commands (init, setup, gen, dev, migrate-up, doctor)
  • Complete project scaffolding — generates 30+ files across full-stack structure
  • Template synchronizationfw gen automatically updates framework-managed files (package.json, configs) while preserving user code
  • Hybrid toolchain management:
    • Core tools via Homebrew (Go, Node, pnpm, Buf, protoc, Docker)
    • Auto-install dev tools (Atlas, Air, protoc-gen-*) to ~/.fw/tools/
    • Homebrew-first fallbacks with proper error reporting
  • Protobuf schema templates with complete ConnectRPC service definitions
  • Go backend with:
    • ConnectRPC service handlers (full CRUD operations)
    • Ent ORM schemas with mixins (timestamps, soft-delete, versioning)
    • Request validation and structured error handling
    • Database configuration (Atlas)
  • React frontend with:
    • TypeScript + Vite configuration
    • TanStack React Query integration
    • CRUD UI components (UsersList with loading/error states)
    • ConnectRPC client setup
  • TypeScript SDK with full protobuf codegen and React Query integration
  • Development tooling (Air hot reload, pnpm workspaces, Docker Compose)
  • Token replacement system (app name, module path, npm scope)

🚧 Final Polish

  • ConnectRPC client-server communication testing
  • Database migration + seeding validation
  • Full fw dev workflow verification
  • Error handling and developer experience polish

✅ What You Get Today

  • One-command setup: fw init blog && fw gen creates and configures everything
  • Auto-installing toolchain: Dev tools install automatically on first use
  • Auto-syncing templates: Framework updates automatically apply to existing projects
  • Working ConnectRPC services with CRUD operations (Create, Get, List, Update, Delete)
  • Generated TypeScript SDK with full protobuf codegen and type safety
  • React Query hooks ready for API integration (useQuery, useMutation)
  • Ent ORM models with soft-delete, timestamps, and validation
  • Rails-like DX: Download one binary, everything just works

Tech Stack

CLI: Go, Cobra

Generated Project:

  • Backend: Go 1.22, ConnectRPC, Ent ORM, PostgreSQL, Atlas migrations
  • Frontend: React 18, TypeScript, Vite, TanStack Query
  • Code Gen: Protobuf + Buf CLI, protovalidate
  • Dev Tools: Air (hot reload), pnpm workspaces, Docker Compose

Contributing

Contributions are welcome! Here's how to get started:

# Clone the repository
git clone https://github.com/apmitchell/fw
cd fw

# Build the CLI
go build -o bin/fw .

# Run the CLI
./bin/fw --help

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published