Design Principles
1. Standard Library First
Mizu is built on Go’snet/http package:
2. Thin Abstractions
Mizu adds minimal layers on top of the standard library:3. Composition Over Inheritance
Everything composes through functions:4. Explicit Over Magic
No reflection-based routing, no DI containers, no hidden behavior:Component Architecture
Core
The maingithub.com/go-mizu/mizu package:
Middlewares
Separate packages ingithub.com/go-mizu/mizu/middlewares/*:
- Each middleware is independent
- Install only what you need
- Consistent configuration pattern
Contract
Transport-neutral API definitions ingithub.com/go-mizu/mizu/contract:
- Define services as Go structs
- Generate handlers for REST, JSON-RPC, MCP
- Generate client SDKs
View
Server-side rendering ingithub.com/go-mizu/mizu/view:
- Template engine with layouts
- Live for real-time updates
- Sync for state synchronization
Frontend
SPA integration ingithub.com/go-mizu/mizu/frontend:
- Development proxy
- Asset embedding
- SPA routing
Request Lifecycle
Detailed Flow
- HTTP arrives: Go’s
net/httpparses the request - Ctx created: Mizu wraps request/response in
Ctx - Middleware chain: Each middleware can:
- Modify the request
- Stop processing (return early)
- Modify the response
- Pass to next handler
- Router matches: URL pattern matched to handler
- Handler executes: Your business logic runs
- Response written: Via
Ctxmethods or rawWriter() - Middleware unwinds: Post-processing in reverse order
Extension Points
Custom Middleware
Custom Error Handler
Custom Not Found
Custom Transports
Implement the transport interface for Contract:Custom SDK Generators
Implement the generator interface:Performance Characteristics
Memory
- Ctx is pooled and reused
- Minimal allocations per request
- No reflection in hot paths
Latency
- Router uses radix tree (O(n) where n = path length)
- Middleware adds ~100ns per layer
- No regex matching in routes
Concurrency
- Each request runs in its own goroutine
- No global locks in hot paths
- Ctx is not safe for concurrent use
Comparison with Other Architectures
vs. MVC Frameworks
vs. Microframeworks
vs. Enterprise Frameworks
Best Practices
Project Structure
Handler Organization
Dependency Injection
Learn More
Core Concepts
Detailed concept documentation.
Contributing
Contribute to Mizu.