ice-user/vodka

Modern Go web framework focused on developer experience, hot-reload, and full-stack workflow

โ˜… 0Forks 0GitHub โ†—Compare

README

Vodka

__/\\\________/\\\_______/\\\\\_______/\\\\\\\\\\\\_____/\\\________/\\\_____/\\\\\\\\\____        
 _\/\\\_______\/\\\_____/\\\///\\\____\/\\\////////\\\__\/\\\_____/\\\//____/\\\\\\\\\\\\\__       
  _\//\\\______/\\\____/\\\/__\///\\\__\/\\\______\//\\\_\/\\\__/\\\//______/\\\/////////\\\_      
   __\//\\\____/\\\____/\\\______\//\\\_\/\\\_______\/\\\_\/\\\\\\//\\\_____\/\\\_______\/\\\_     
    ___\//\\\__/\\\____\/\\\_______\/\\\_\/\\\_______\/\\\_\/\\\//_\//\\\____\/\\\\\\\\\\\\\\\_    
     ____\//\\\/\\\_____\//\\\______/\\\__\/\\\_______\/\\\_\/\\\____\//\\\___\/\\\/////////\\\_   
      _____\//\\\\\_______\///\\\__/\\\____\/\\\_______/\\\__\/\\\_____\//\\\__\/\\\_______\/\\\_  
       ______\//\\\__________\///\\\\\/_____\/\\\\\\\\\\\\/___\/\\\______\//\\\_\/\\\_______\/\\\_ 
        _______\///_____________\/////_______\////////////_____\///________\///__\///________\///__

Vodka

A modern Go web framework focused on developer experience, full-stack workflow, and fast iteration.

Vodka is a lightweight, high-performance HTTP framework for Go that combines clean routing, middleware chaining, validation, authentication utilities, and a powerful CLI for building modern full-stack applications.

Unlike traditional Go frameworks that focus only on request handling, Vodka focuses heavily on developer experience:

  • โšก Fast routing with Radix Tree architecture
  • ๐Ÿ”ฅ Built-in hot reload for Go backends
  • โš›๏ธ Vite + React full-stack scaffolding
  • ๐Ÿงฉ Middleware chaining system
  • ๐Ÿ” Authentication helpers and JWT validation
  • โœ… Request validation support
  • ๐Ÿ› ๏ธ Clean and ergonomic API design
  • ๐Ÿš€ One-command development workflow

Installation

Install the Vodka CLI

go install github.com/DevanshuTripathi/vodka/cmd/vodka@latest

Make sure your Go bin directory is in your system PATH.

Linux / macOS

export PATH=$PATH:$(go env GOPATH)/bin

Windows

Add the following directory to Environment Variables:

%USERPROFILE%\go\bin

Quick Start

Create a Full-Stack App

vodka create my-app

This generates:

  • A Go backend powered by Vodka
  • A Vite + React frontend
  • Preconfigured development workflow
  • SPA serving support for production deployments

Install Frontend Dependencies

cd my-app
cd frontend && npm install
cd ..

Start Development Mode

vodka run dev

This starts:

  • The Vite frontend dev server
  • The Vodka backend
  • Automatic Go hot reload
  • Concurrent frontend/backend workflow

Edit .jsx files โ†’ frontend updates instantly.

Edit .go files โ†’ backend rebuilds automatically.


Minimal API Example

package main

import (
	"log"

	"github.com/DevanshuTripathi/vodka"
)

func main() {
	app := vodka.DefaultRouter()

	app.GET("/ping", func(c *vodka.Context) {
		c.JSON(200, vodka.M{
			"message": "pong!",
		})
	})

	if err := app.Run(":8080"); err != nil {
		log.Fatal(err)
	}
}

Using Vodka for APIs

Create a Go Module

mkdir backend-app
cd backend-app
go mod init app
go get github.com/DevanshuTripathi/vodka

Run with Hot Reload

Inside any Go project using Vodka:

vodka

Vodka automatically:

  • Watches .go files
  • Rebuilds your backend
  • Restarts the server instantly

Features

Feature Included
Radix Tree Routing โœ…
Middleware Chaining โœ…
Route Groups โœ…
JSON Binding โœ…
Request Validation โœ…
JWT Validation Helpers โœ…
Bearer Auth Middleware โœ…
Hot Reload โœ…
Vite + React Scaffolding โœ…
SPA Serving โœ…
Panic Recovery Middleware โœ…
Logger Middleware โœ…
CORS Middleware โœ…
Request ID Middleware โœ…
Context Storage โœ…

Core Concepts

Engine

vodka.Engine is the central router and application instance.

It uses a Radix Tree-based routing architecture for fast request matching and low overhead.

app := vodka.DefaultRouter()

Context

vodka.Context wraps Go's http.Request and http.ResponseWriter into a clean and ergonomic API.

JSON Response

c.JSON(200, vodka.M{
    "message": "hello",
})

Query Parameters

name := c.Query("name")

URL Parameters

id := c.Param("id")

Bind JSON

var user User
c.BindJSON(&user)

Error Handling

c.Error(400, errors.New("invalid request"))

Middleware

Vodka middleware is just a vodka.HandlerFunc, which means it is a function with the signature:

func(*vodka.Context)

That makes middleware a regular request handler that can run before and after the route handler.

Middlewares can:

  • Modify requests
  • Attach values to context
  • Authenticate users
  • Log requests
  • Recover from panics
  • Handle errors

Middlewares are registered with app.Use(...) or on a router group with group.Use(...).

How middleware works

Each incoming request is wrapped in a *vodka.Context and the framework builds a handler chain:

  • all group middlewares
  • the final route handler

c.Next() tells Vodka to continue to the next middleware or to the route handler. If you omit c.Next(), the chain stops there, which is useful when you want to short-circuit the request (for example, when authentication fails).

Why use c.Next()

Use c.Next() inside your middleware when you want the request to continue down the chain. This lets you:

  • run code before the next handler
  • allow the next handler to execute
  • run code after the next handler finishes

A middleware that calls c.Next() can also inspect or modify the response after the rest of the chain has executed.

If a middleware wants to stop the chain immediately, it can simply avoid calling c.Next() and optionally call c.Abort().


Custom Middleware Example

func RequestTimer() vodka.HandlerFunc {
	return func(c *vodka.Context) {
		start := time.Now()

		c.Next()

		latency := time.Since(start)
		log.Printf("[RequestTimer] %s %s %v", c.Request.Method, c.Request.URL.Path, latency)
	}
}

		log.Printf(
			"[%s] %s %v",
			c.Request.Method,
			c.Request.URL.Path,
			latency, 
		)
	}
}

func main() {
	app := vodka.DefaultRouter()

	app.Use(vodka.Logger(), vodka.Recovery(), vodka.ErrorHandler())
	app.Use(RequestTimer())

	api := app.Group("/api", AdminOnly())
	api.GET("/dashboard", func(c *vodka.Context) {
		userRole, _ := c.Get("user_role")
		c.JSON(200, vodka.M{"role": userRole})
	})
}

Request ID Middleware

Track requests across your logs using automatic request ID generation. Every request gets a unique ID that's automatically added to response headers and stored in the context.

app := vodka.DefaultRouter()

// Add request ID middleware โ€” generates unique ID for each request
app.Use(mixers.RequestID())

app.GET("/api/users", func(c *vodka.Context) {
	requestID, _ := c.Get("request-id")
	log.Printf("[%v] Fetching users", requestID)
	c.JSON(200, vodka.M{"users": []string{"Alice", "Bob"}})
})

// Client receives: X-Request-ID: 550e8400-e29b-41d4-a716-446655440000

Custom Header Name

Use a different header name if needed (context key is always "request-id"):

app.Use(mixers.RequestIDWithHeader("X-Correlation-ID"))

Validation

Vodka supports request validation using struct tags.

type User struct {
	Email    string `validate:"required,email"`
	Password string `validate:"min=8"`
}

Authentication

Vodka includes built-in Bearer authentication middleware and JWT validation helpers.

You can also provide custom validation logic:

app.Use(vodka.BearerAuth(contextKey, func(token string) (any, bool) {
	return validateToken(token)
}))

Full-Stack SPA Support

Projects generated using vodka create come with SPA serving preconfigured.

app.ServeSPA("./frontend/dist")

If a route does not match an API endpoint, Vodka automatically serves the frontend application, enabling seamless React Router support in production.


Philosophy

Vodka is designed around a few core ideas:

  • Fast development workflow
  • Minimal boilerplate
  • Strong developer experience
  • Clean APIs
  • Modern full-stack integration
  • Practical defaults without excessive abstraction

Roadmap

  • More middleware packages
  • Enhanced validation system
  • Improved benchmarking suite
  • Expanded CLI tooling
  • Testing utilities

Contributing

Contributions, issues, and feature requests are welcome.

If you find bugs or have suggestions, feel free to open an issue or submit a pull request.


License

MIT License

Contributors

DevanshuTripathiSounak-starMritunjay2005EchoOfCodeOdaloVmzl2233

Issues