https://github.com/xraph/forge
A very opionated distributed backend framework with everything in between.
https://github.com/xraph/forge
Last synced: 10 days ago
JSON representation
A very opionated distributed backend framework with everything in between.
- Host: GitHub
- URL: https://github.com/xraph/forge
- Owner: xraph
- License: apache-2.0
- Created: 2025-07-10T19:52:24.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2026-06-04T02:34:53.000Z (22 days ago)
- Last Synced: 2026-06-05T23:02:47.139Z (20 days ago)
- Language: Go
- Homepage: https://forge.xraph.com
- Size: 220 MB
- Stars: 7
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# π¨ Forge
Forgeβ’ is a backend framework, and Forge Cloudβ’ is its AI cloud offering, maintained by XRAPHβ’.
**Enterprise-Grade Web Framework for Go**
> Build scalable, maintainable, and observable Go applications with Forgeβthe modern framework that brings clean architecture, dependency injection, and powerful extensions to your production services.
[](https://golang.org/)
[](https://goreportcard.com/report/github.com/xraph/forge)
[](LICENSE)
[](https://github.com/xraph/forge)
[](https://github.com/xraph/forge/actions/workflows/go.yml)
---
## π Quick Start
### Installation
```bash
# Install the Forge CLI
go install github.com/xraph/forge/cmd/forge@latest
# Verify installation
forge --version
```
### Forge Your First App
```bash
# Initialize a new project
forge init my-app
# Start the development server
forge dev
```
### Minimal Example
```go
package main
import "github.com/xraph/forge"
func main() {
// Create app with default configuration
app := forge.NewApp(forge.AppConfig{
Name: "my-app",
Version: "1.0.0",
Environment: "development",
HTTPAddress: ":8080",
})
// Register routes
router := app.Router()
router.GET("/", func(ctx forge.Context) error {
return ctx.JSON(200, map[string]string{
"message": "Hello, Forge!",
})
})
// Run the application (blocks until SIGINT/SIGTERM)
app.Run()
}
```
**Built-in endpoints:**
- `/_/info` - Application information
- `/_/metrics` - Prometheus metrics
- `/_/health` - Health checks
---
## β¨ Key Features
### ποΈ Core Framework
- **β
Dependency Injection** - Type-safe container with service lifecycle
- **β
HTTP Router** - Fast, lightweight routing with middleware support
- **β
Middleware** - Auth, CORS, logging, rate limiting, and more
- **β
Configuration** - YAML/JSON/TOML support with environment variable override
- **β
Observability** - Structured logging, metrics, distributed tracing
- **β
Health Checks** - Automatic discovery and reporting
- **β
Lifecycle Management** - Graceful startup and shutdown
### π Extensions
| Extension | Description | Status |
|-----------|-------------|--------|
| **AI** | LLM integration, agents, inference engine | β
|
| **Auth** | Multi-provider authentication (OAuth, JWT, SAML) | β
|
| **Cache** | Multi-backend caching (Redis, Memcached, In-Memory) | β
|
| **Consensus** | Raft consensus for distributed systems | β
|
| **Database** | SQL (Postgres, MySQL, SQLite) + MongoDB support | β
|
| **Events** | Event bus and event sourcing | β
|
| **GraphQL** | GraphQL server with schema generation | β
|
| **gRPC** | gRPC server with reflection | β
|
| **HLS** | HTTP Live Streaming | β
|
| **Kafka** | Apache Kafka integration | β
|
| **MCP** | Model Context Protocol | β
|
| **MQTT** | MQTT broker and client | β
|
| **orpc** | ORPC transport protocol | β
|
| **Queue** | Message queue management | β
|
| **Search** | Full-text search (Elasticsearch, Typesense) | β
|
| **Storage** | Multi-backend storage (S3, GCS, Local) | β
|
| **Streaming** | WebSocket, SSE, WebRTC | β
|
| **WebRTC** | Real-time peer-to-peer communication | β
|
### π οΈ CLI Tools
- **β
Project Scaffolding** - Initialize new projects with templates
- **β
Code Generation** - Generate handlers, controllers, and services
- **β
Database Migrations** - Schema management with versioning
- **β
Interactive Prompts** - Arrow-key navigation, multi-select
- **β
Server Management** - Development server with hot reload
- **β
Testing** - Built-in test runner and coverage reports
---
## π Documentation
### Getting Started
- [**Installation Guide**](docs/content/docs/getting-started/installation.mdx)
- [**Quick Start**](docs/content/docs/getting-started/quick-start.mdx)
- [**Architecture**](docs/content/docs/architecture/index.mdx)
- [**Examples**](examples/)
### Core Concepts
- [**Application Lifecycle**](docs/content/docs/core/lifecycle.mdx)
- [**Dependency Injection**](docs/content/docs/core/dependency-injection.mdx)
- [**Routing**](docs/content/docs/core/routing.mdx)
- [**Middleware**](docs/content/docs/core/middleware.mdx)
- [**Configuration**](docs/content/docs/core/configuration.mdx)
- [**Observability**](docs/content/docs/core/observability.mdx)
### Extensions
- [**AI Extension**](extensions/ai/README.md) - LLM integration and AI agents
- [**Auth Extension**](extensions/auth/README.md) - Authentication providers
- [**Database Extension**](extensions/database/) - SQL and NoSQL databases
- [**GraphQL Extension**](extensions/graphql/README.md) - GraphQL server
- [**gRPC Extension**](extensions/grpc/README.md) - gRPC services
- [**Streaming Extension**](extensions/streaming/) - WebSocket and SSE
### CLI Reference
- [**CLI Documentation**](cli/README.md)
- [**Commands Reference**](cmd/forge/COMMANDS.md)
---
## π Why Forge?
### Production-Ready
Forge is built for production from day one:
- **β
Graceful Shutdown** - Proper resource cleanup on SIGTERM
- **β
Health Monitoring** - Automatic discovery and reporting
- **β
Observability** - Metrics, logging, and distributed tracing
- **β
Error Handling** - Comprehensive error management
- **β
Security** - Built-in security best practices
### Developer Experience
- **β
Type Safety** - Generics and compile-time guarantees
- **β
Zero Config** - Sensible defaults with full customization
- **β
Hot Reload** - Instant feedback during development
- **β
CLI Tools** - Fast project scaffolding and generation
- **β
Rich Docs** - Comprehensive documentation and examples
### Performance
- **β
Low Latency** - Optimized HTTP router and middleware
- **β
Efficient Routing** - Trie-based path matching
- **β
Concurrent Safe** - Thread-safe components
- **β
Memory Efficient** - Minimal allocations
### Extensible
- **β
Extension System** - Modular, composable extensions
- **β
Plugin Architecture** - Easy to add custom functionality
- **β
Multi-Backend** - Switch implementations without code changes
- **β
Middleware Chain** - Powerful middleware composition
---
## ποΈ Architecture
```go
// Application Structure
app := forge.NewApp(forge.AppConfig{
Name: "my-service",
Version: "1.0.0",
Environment: "production",
// Extensions
Extensions: []forge.Extension{
database.NewExtension(database.Config{
Databases: []database.DatabaseConfig{
{
Name: "primary",
Type: database.TypePostgres,
DSN: "postgres://localhost/mydb",
},
},
}),
auth.NewExtension(auth.Config{
Provider: "oauth2",
// ... auth configuration
}),
},
})
// Dependency Injection
forge.RegisterSingleton(app.Container(), "userService", func(c forge.Container) (*UserService, error) {
db, err := database.GetSQL(c)
if err != nil {
return nil, err
}
logger := forge.Must[forge.Logger](c, "logger")
return NewUserService(db, logger), nil
})
// Routing
router := app.Router()
router.GET("/users/:id", getUserHandler)
router.POST("/users", createUserHandler)
// Run
app.Run()
```
---
## π§© Extension Example
### Using the AI Extension
```go
package main
import (
"github.com/xraph/forge"
"github.com/xraph/forge/extensions/ai"
)
func main() {
app := forge.NewApp(forge.AppConfig{
Extensions: []forge.Extension{
ai.NewExtension(ai.Config{
LLMProviders: map[string]ai.LLMProviderConfig{
"openai": {
APIKey: os.Getenv("OPENAI_API_KEY"),
Model: "gpt-4",
},
},
}),
},
})
// Access AI service via DI using helper function
aiService, err := ai.GetAIService(app.Container())
if err != nil {
log.Fatal(err)
}
// Use in your handlers
router := app.Router()
router.POST("/chat", func(ctx forge.Context) error {
result, err := aiService.Chat(ctx, ai.ChatRequest{
Messages: []ai.Message{
{Role: "user", Content: "Hello!"},
},
})
if err != nil {
return err
}
return ctx.JSON(200, result)
})
app.Run()
}
```
---
## π οΈ Development
### Prerequisites
- **Go 1.24+** - Latest Go compiler
- **Make** - Build tool (optional but recommended)
### Build
```bash
# Build the CLI
make build
# Build with debug symbols
make build-debug
# Build for all platforms
make release
```
### Run Tests
```bash
# Run all tests
make test
# Run with coverage
make test-coverage
# Run specific package
go test ./extensions/ai/...
```
### Code Quality
```bash
# Format code
make fmt
# Run linter
make lint
# Fix linting issues
make lint-fix
# Run security scan
make security-scan
# Check vulnerabilities
make vuln-check
```
### Development Server
```bash
# Start development server
forge dev
# Start with hot reload
forge dev --watch
# Start on custom port
forge dev --port 3000
```
---
## π Project Status
### Core Framework
- **β
Dependency Injection** - Production ready
- **β
HTTP Router** - Fast, lightweight
- **β
Middleware System** - Comprehensive
- **β
Configuration** - Multi-format support
- **β
Observability** - Metrics, logging, tracing
- **β
Health Checks** - Automatic discovery
- **β
CLI Tools** - Full-featured CLI
### Extensions (17 total)
**Production Ready (14):**
- β
AI - LLM integration and agents
- β
Auth - Multi-provider authentication
- β
Cache - Multi-backend caching
- β
Consensus - Raft consensus
- β
Database - SQL and NoSQL
- β
Events - Event bus and sourcing
- β
GraphQL - GraphQL server
- β
gRPC - gRPC services
- β
HLS - HTTP Live Streaming
- β
Kafka - Apache Kafka
- β
MCP - Model Context Protocol
- β
MQTT - MQTT broker
- β
Storage - Multi-backend storage
- β
Streaming - WebSocket, SSE, WebRTC
**In Progress (3):**
- π Queue - Message queue management
- π Search - Full-text search
- π orpc - ORPC transport protocol
---
## π§ͺ Examples
The `examples/` directory contains production-ready examples:
- **[Minimal App](examples/minimal-app/)** - Hello World
- **[Configuration](examples/config-example/)** - Config management
- **[Database](examples/database-demo/)** - Database integration
- **[Auth](extensions/auth/examples/auth_example/)** - Authentication
- **[GraphQL](extensions/graphql/examples/graphql-basic/)** - GraphQL server
- **[gRPC](examples/grpc-basic/)** - gRPC services
- **[WebRTC](examples/webrtc/)** - Real-time communication
- **[MCP](examples/mcp-basic/)** - Model Context Protocol
- **[AI Agents](examples/ai-agents-demo/)** - AI agent system
---
## π€ Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
### Development Workflow
```bash
# Fork and clone
git clone https://github.com/your-username/forge.git
cd forge
# Install tools
make install-tools
# Make changes
# ...
# Run tests
make test
# Check code quality
make ci
# Commit with conventional commits
git commit -m "feat: add new feature"
```
### Conventional Commits
```bash
feat: add new feature
fix: fix bug in router
docs: update documentation
style: format code
refactor: refactor DI container
perf: optimize routing performance
test: add tests for middleware
chore: update dependencies
```
### Releasing
Releases are managed by [Release Please](https://github.com/googleapis/release-please) and a unified GitHub Actions workflow.
**Automated releases** β Push to `main` with conventional commits. Release Please opens a PR with version bumps and changelogs. Merging the PR creates a tag, which triggers the release pipeline.
**Manual releases** β Go to [Actions > Release](../../actions/workflows/release.yml), click **Run workflow**, select the module and version, and optionally enable dry-run mode.
The release workflow supports:
- **Main module + CLI**: Builds cross-platform binaries, Docker images, and publishes to Homebrew/Scoop/NFPM via GoReleaser.
- **Extension modules**: Creates a GitHub release and notifies the Go module proxy.
- **Dry run**: Validates the full pipeline without publishing.
- **Skip tests**: For hotfixes when tests have already passed on CI.
---
## π License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
---
## π Acknowledgments
Built with β€οΈ by [Rex Raphael](https://github.com/juicycleff)
**Special thanks to:**
- [Bun](https://github.com/uptrace/bun) - SQL ORM
- [Uptrace](https://github.com/uptrace/uptrace) - Observability platform
- [Chi](https://github.com/go-chi/chi) - Router inspiration
- All contributors and maintainers
---
## π Links
- **[Documentation](https://forge.dev)** - Comprehensive docs
- **[GitHub](https://github.com/xraph/forge)** - Source code
- **[Issues](https://github.com/xraph/forge/issues)** - Bug reports
- **[Discussions](https://github.com/xraph/forge/discussions)** - Questions and ideas
- **[Examples](examples/)** - Code examples
- **[CLI Reference](cli/README.md)** - CLI documentation
---
## π License
Forge uses a **dual-licensing approach**:
### Forge Core & Most Extensions: MIT License
The core framework and most extensions are licensed under the **MIT License** - one of the most permissive open source licenses.
β
**Use freely for:**
- Commercial products and services
- Personal projects
- Closed-source applications
- Modifications and distributions
See the [LICENSE](LICENSE) file for full terms.
### AI Extension: Commercial Source-Available License
The AI Extension (`extensions/ai/`) uses a more restrictive **Commercial Source-Available License**.
β
**Free for:**
- Personal projects
- Educational purposes
- Research and academic use
- Internal evaluation (90 days)
β **Commercial license required for:**
- Production deployments
- Commercial products/services
- Revenue-generating applications
See [extensions/ai/LICENSE](extensions/ai/LICENSE) for full terms or [LICENSING.md](LICENSING.md) for the complete licensing guide.
**Need a commercial license?** Contact: licensing@xraph.com
---
## π Roadmap
### v2.1 (Q1 2025)
- [ ] Complete remaining extensions (Queue, Search, orpc)
- [ ] Enhanced AI agent orchestration
- [ ] Real-time collaboration features
- [ ] Advanced monitoring dashboard
### v2.2 (Q2 2025)
- [ ] Kubernetes operator
- [ ] Helm charts and deployment automation
- [ ] Advanced caching strategies
- [ ] Performance optimization pass
### v3.0 (Q3 2025)
- [ ] TypeScript/Node.js runtime
- [ ] Multi-language code generation
- [ ] Enhanced observability platform
- [ ] Enterprise features (SLA, auditing, compliance)
---
**Ready to build?** [Get Started β](docs/content/docs/getting-started/quick-start.mdx)