Convert Figma logo to code with AI

livebud logobud

The Full-Stack Web Framework for Go

5,571
181
5,571
56

Top Related Projects

18,066

lightweight, idiomatic and composable router for building Go HTTP services

29,410

High performance, minimalist Go web framework

77,851

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

33,019

⚡️ Express inspired web framework written in Go

20,665

Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍

A high performance HTTP request router that scales well

Quick Overview

Bud is a full-stack web framework for Go developers, designed to provide a seamless development experience. It offers hot reloading, automatic code generation, and a unified approach to building both frontend and backend components, aiming to simplify the process of creating web applications in Go.

Pros

  • Hot reloading for rapid development and instant feedback
  • Automatic code generation to reduce boilerplate and improve productivity
  • Unified approach to frontend and backend development in Go
  • Built-in support for modern web technologies like React and SQLite

Cons

  • Relatively new project, which may lead to potential instability or lack of extensive community support
  • Limited ecosystem compared to more established web frameworks
  • Learning curve for developers accustomed to traditional Go web development patterns
  • May not be suitable for large-scale, complex applications that require more flexibility

Code Examples

  1. Defining a route and handler:
package main

import "github.com/livebud/bud/framework"

func main() {
    framework.New().Route("/", func(c *framework.Context) error {
        return c.String(200, "Hello, World!")
    }).Run()
}
  1. Creating a React component:
import React from 'react'

export default function Hello({ name }) {
  return <h1>Hello, {name}!</h1>
}
  1. Generating a database model:
package user

type User struct {
    ID    int    `json:"id"`
    Name  string `json:"name"`
    Email string `json:"email"`
}

Getting Started

To get started with Bud, follow these steps:

  1. Install Bud:

    go install github.com/livebud/bud/cmd/bud@latest
    
  2. Create a new project:

    bud create myapp
    cd myapp
    
  3. Run the development server:

    bud run
    

Your application will now be running at http://localhost:3000. Bud will automatically reload your application when you make changes to your code.

Competitor Comparisons

18,066

lightweight, idiomatic and composable router for building Go HTTP services

Pros of chi

  • Lightweight and minimalist HTTP router with no external dependencies
  • Highly performant and efficient for routing HTTP requests
  • Flexible middleware system for easy customization

Cons of chi

  • Less opinionated, requiring more manual setup for full-featured web apps
  • Lacks built-in code generation or hot reloading features
  • Steeper learning curve for beginners compared to more opinionated frameworks

Code Comparison

chi:

r := chi.NewRouter()
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("welcome"))
})
http.ListenAndServe(":3000", r)

bud:

func index(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("welcome"))
}

func main() {
    bud.Run(context.Background())
}

Summary

chi is a lightweight, high-performance HTTP router for Go, offering flexibility and efficiency. It's ideal for developers who want fine-grained control over their application structure. bud, on the other hand, is a full-featured web framework with built-in code generation and hot reloading, making it more suitable for rapid development and beginners. While chi provides a low-level routing solution, bud offers a more comprehensive toolkit for building web applications in Go.

29,410

High performance, minimalist Go web framework

Pros of Echo

  • More mature and widely adopted web framework with a larger community
  • Extensive middleware ecosystem and third-party integrations
  • High-performance and lightweight design optimized for production use

Cons of Echo

  • Requires more manual configuration and boilerplate code
  • Less opinionated, which may lead to inconsistent project structures
  • Steeper learning curve for beginners compared to Bud's all-in-one approach

Code Comparison

Echo:

e := echo.New()
e.GET("/", func(c echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!")
})
e.Logger.Fatal(e.Start(":1323"))

Bud:

func index(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello, World!")
}

func main() {
    bud.Run(context.Background())
}

Echo provides a more explicit routing setup, while Bud abstracts away much of the boilerplate code. Echo offers finer control over request handling, whereas Bud focuses on simplicity and convention over configuration.

Both frameworks aim to simplify Go web development, but they cater to different developer preferences and project requirements. Echo is better suited for larger, more complex applications that require fine-grained control, while Bud excels in rapid prototyping and smaller projects with its opinionated structure and built-in development tools.

77,851

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

Pros of Gin

  • Mature and widely adopted web framework with a large community
  • High performance and low memory usage
  • Extensive middleware ecosystem and third-party integrations

Cons of Gin

  • Lacks built-in hot reloading and live development features
  • Requires more boilerplate code for routing and handling requests
  • No integrated frontend development tools or asset pipeline

Code Comparison

Gin:

r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
    c.JSON(200, gin.H{"message": "pong"})
})
r.Run()

Bud:

func index(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello, World!")
}

Key Differences

  • Bud focuses on full-stack development with integrated frontend tooling
  • Gin is primarily a backend framework with emphasis on performance
  • Bud offers hot reloading and live development features out of the box
  • Gin provides more granular control over HTTP routing and middleware
  • Bud aims for a more opinionated, convention-over-configuration approach

Both frameworks have their strengths, with Gin excelling in backend performance and flexibility, while Bud offers a more integrated full-stack development experience with live reloading capabilities.

33,019

⚡️ Express inspired web framework written in Go

Pros of Fiber

  • Higher performance and lower latency due to its lightweight design
  • Extensive middleware ecosystem and third-party integrations
  • More mature and widely adopted in production environments

Cons of Fiber

  • Steeper learning curve for developers new to Go web frameworks
  • Less opinionated, requiring more manual configuration for complex applications
  • Limited built-in features compared to full-stack frameworks

Code Comparison

Fiber:

app := fiber.New()

app.Get("/", func(c *fiber.Ctx) error {
    return c.SendString("Hello, World!")
})

app.Listen(":3000")

Bud:

package main

import "github.com/livebud/bud/package/router"

func main() {
    router.Get("/", func(c *router.Context) error {
        return c.String("Hello, World!")
    })
}

Fiber focuses on high-performance routing and middleware, while Bud aims to provide a more comprehensive full-stack development experience. Fiber is better suited for developers who need fine-grained control over their application structure, while Bud offers a more opinionated approach with built-in conventions for rapid development.

Fiber excels in scenarios requiring maximum performance and flexibility, whereas Bud shines in projects that benefit from code generation and integrated tooling for both frontend and backend development.

20,665

Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍

Pros of Mux

  • Mature and widely adopted routing library for Go
  • Flexible and feature-rich, supporting URL parameters, subrouters, and middleware
  • Excellent documentation and community support

Cons of Mux

  • Focused solely on routing, requiring additional libraries for full-stack development
  • May be overkill for simple applications with basic routing needs
  • Lacks built-in hot reloading and code generation features

Code Comparison

Mux:

r := mux.NewRouter()
r.HandleFunc("/users/{id}", GetUserHandler).Methods("GET")
r.HandleFunc("/products", CreateProductHandler).Methods("POST")
http.ListenAndServe(":8080", r)

Bud:

app := bud.New()
app.Get("/users/:id", getUserHandler)
app.Post("/products", createProductHandler)
app.Run(":8080")

Summary

Mux is a robust routing library for Go, offering extensive features and flexibility. It's ideal for developers who need fine-grained control over routing in larger applications. Bud, on the other hand, is a full-stack framework that simplifies development with features like hot reloading and code generation. While Mux excels in routing capabilities, Bud provides a more comprehensive solution for rapid application development, especially for smaller to medium-sized projects.

A high performance HTTP request router that scales well

Pros of httprouter

  • Lightweight and fast HTTP request router
  • Excellent performance for high-load applications
  • Simple API with easy integration into existing Go projects

Cons of httprouter

  • Limited built-in functionality compared to full-featured web frameworks
  • Lacks built-in middleware support, requiring manual implementation
  • May require additional libraries for more complex web applications

Code Comparison

httprouter:

router := httprouter.New()
router.GET("/", Index)
router.GET("/hello/:name", Hello)

log.Fatal(http.ListenAndServe(":8080", router))

bud:

app := bud.New()
app.Get("/", func(ctx *bud.Context) {
    ctx.HTML("Hello, World!")
})
app.Run()

Key Differences

  • httprouter focuses on efficient routing, while bud aims to be a full-stack web framework
  • bud provides built-in hot reloading and code generation features
  • httprouter requires manual handling of middleware, whereas bud includes middleware support
  • bud offers a more opinionated structure for building web applications
  • httprouter is better suited for performance-critical applications, while bud prioritizes developer experience and rapid development

Both projects have their strengths, with httprouter excelling in performance and simplicity, and bud offering a more comprehensive set of features for full-stack web development.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Bud

The Full-Stack Web Framework for Go. Bud writes the boring code for you, helping you launch your website faster.

Video Demo

Watch a video demonstrating how to build a minimal HN clone in 15 minutes with Bud.

Documentation

Read the documentation to learn how to get started with Bud.

Installing Bud

Bud ships as a single binary that runs on Linux and Mac. You can follow along for Windows support in this issue.

The easiest way to get started is by copying and pasting the command below in your terminal:

curl -sf https://raw.githubusercontent.com/livebud/bud/main/install.sh | sh

This script will download the right binary for your operating system and move the binary to the right location in your $PATH.

Confirm that you've installed Bud by typing bud in your terminal.

bud -h

You should see the following:

Usage:
    bud [flags] [command]

Flags:
  -C, --chdir  Change the working directory

Commands:
  build    build the production server
  create   create a new project
  run      run the development server
  tool     extra tools
  version  Show package versions

Requirements

The following software is required to use Bud.

  • Node v14+

    This is a temporary requirement that we plan to remove in v0.3

  • Go v1.17+

    Bud relies heavily on io/fs and will take advantage of generics in the future, so while Go v1.16 will work, we suggest running Go v1.18+ if you can.

Your First Project

With bud installed, you can now scaffold a new project:

$ bud create hello
$ cd hello

The create command will scaffold everything you need to get started with bud.

$ ls
go.mod  node_modules/  package-lock.json  package.json

... which is not very much by the way! Unlike most other fullstack frameworks, Bud starts out very minimal. As you add dependencies, Bud will generate all the boring code to glue your app together. Let's see this in action.

Start the development server with bud run:

$ bud run
| Listening on http://127.0.0.1:3000

Click on the link to open the browser. You'll be greeted with bud's welcome page.

Congrats! You're running your first web server with Bud. The welcome server is your jumping off point to learn more about the framework.

CleanShot 2022-05-12 at 22.00.19@2x.png

Next Steps

Check out the Hacker News demo, read the documentation, schedule a quick call or go on your own adventure. The only limit is your imagination.

Recent discussions: Reddit, Hacker News, Twitter

Real-World Projects

History of Bud

I started working on Bud in April 2019 after seeing how productive developers could be in Laravel. I wanted the same for Go, so I decided to try creating Laravel for the Go ecosystem. However, my first version after 6 months needed to scaffold many files just to get started. If you are coming from Rails or Laravel, you may shrug and consider this as pretty normal.

Unfortunately, I have been spoiled by the renaissance in frontend frameworks like Next.js that start barebones but every file you add incrementally enhances your web application. This keeps the initial complexity under control.

With this additional inspiration, I worked on the next iteration for the ensuing 18 months.

The goals are now:

  • Generate files only as you need them. Keep these generated files away from your application code and give developers the choice to keep them out of source control. You shouldn't need to care about the generated code. You may be surprised to learn that Go also generates code to turn your Go code into an executable, but it works so well you don't need to think about it. Bud should feel like this.

  • Feel like using a modern JS framework. This means it should work with multiple modern frontend frameworks like Svelte and React, support live reload, and have server-side rendering for better performance and SEO.

  • The framework should be extensible from Day 1. Bud is too ambitious for one person. We're going to need an ambitious community behind this framework. Extensibility should be primarily driven by adding code, rather than by adding configuration.

  • Bud should provide high-level, type-safe APIs for developers while generating performant, low-level Go code under the covers.

  • Bud should compile to a single binary that contains your entire web app and can be copied to a server that doesn't even have Go installed.

Contributing

Please refer to the Contributing Guide to learn how to develop Bud locally.