vef

package module
v0.21.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

README

VEF Framework Go

VEF Framework Mascot

An opinionated Go framework for enterprise applications, built with Fiber, Uber FX, and Bun.

Unified API resources, generic CRUD, authentication, RBAC, validation, caching, events, storage, MCP, and more.

English | 简体中文 | Quick Start | Documentation | API Reference

GitHub Release Build Status Coverage Go Reference Go Report Card Ask DeepWiki License

VEF Framework Go combines dependency injection, HTTP routing, and data access into a cohesive application framework, with built-in support for API resources, authentication, RBAC, validation, caching, events, storage, MCP, and more.

This README is intentionally brief. Detailed tutorials and reference material are available on the documentation site.

Development status: the project is still pre-1.0. Expect breaking changes while conventions and APIs continue to evolve.

Why VEF

  • One resource model for both RPC and REST APIs
  • Generic CRUD primitives that reduce repetitive backend code
  • Modular composition with Uber FX for clean wiring and extension
  • Built-in auth, RBAC, rate limiting, audit, caching, events, storage, MCP, and other infrastructure you would otherwise assemble yourself

Quick Start

Requirements:

  • Go 1.26.0 or newer
  • A supported database such as PostgreSQL, MySQL, or SQLite

Install:

go get github.com/coldsmirk/vef-framework-go

Create main.go:

package main

import "github.com/coldsmirk/vef-framework-go"

func main() {
	vef.Run()
}

Create configs/application.toml:

[vef.app]
name = "my-app"
port = 8080

[vef.data_source]
type = "sqlite"
path = "./my-app.db"

This is the smallest runnable configuration. Sections such as vef.monitor, vef.mcp, and vef.approval are optional.

Run:

go run main.go

VEF loads application.toml from ./configs, ., ../configs, or the path pointed to by VEF_CONFIG_PATH.

Core Concepts

  • vef.Run(...) starts the framework and wires the default module chain: config, database, ORM, middleware, API, security, event, CQRS, cron, redis, mold, storage, sequence, schema, monitor, MCP, and app.
  • API endpoints are defined as resources with api.NewRPCResource(...) or api.NewRESTResource(...).
  • Business modules are composed with FX options, for example vef.ProvideAPIResource(...), vef.ProvideMiddleware(...), and vef.ProvideMCPTools(...).
  • CRUD-heavy modules can build on the generic helpers in crud/ instead of writing repetitive handlers from scratch.

Typical application layout:

my-app/
├── cmd/
├── configs/
└── internal/
    ├── auth/
    ├── sys/
    ├── <domain>/
    └── web/

Documentation

If you need step-by-step guides, architectural deep dives, or feature-specific reference, prefer the documentation site rather than expanding this README.

Development

Common verification commands:

go test ./...
go test -race ./...
golangci-lint run
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test ./...

License

Licensed under the Apache License 2.0.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Provide    = fx.Provide
	Supply     = fx.Supply
	Annotate   = fx.Annotate
	As         = fx.As
	ParamTags  = fx.ParamTags
	ResultTags = fx.ResultTags
	Self       = fx.Self
	Invoke     = fx.Invoke
	Decorate   = fx.Decorate
	Module     = fx.Module
	Private    = fx.Private
	OnStart    = fx.OnStart
	OnStop     = fx.OnStop
)
View Source
var (
	From     = fx.From
	Replace  = fx.Replace
	Populate = fx.Populate
)

Functions

func NamedLogger

func NamedLogger(name string) logx.Logger

NamedLogger creates a named logger instance for the specified component. This is a convenience function that wraps the internal logger factory.

func ProvideAPIResource

func ProvideAPIResource(constructor any, paramTags ...string) fx.Option

ProvideAPIResource provides an API resource to the dependency injection container. The resource will be registered in the "vef:api:resources" group. The constructor must return api.Resource (not a concrete type).

func ProvideCQRSBehavior

func ProvideCQRSBehavior(constructor any, paramTags ...string) fx.Option

ProvideCQRSBehavior provides a CQRS behavior middleware to the dependency injection container. The constructor must return cqrs.Behavior (not a concrete type).

func ProvideChallengeProvider

func ProvideChallengeProvider(constructor any, paramTags ...string) fx.Option

ProvideChallengeProvider provides a login challenge provider to the dependency injection container. The provider will be registered in the "vef:security:challenge_providers" group. The constructor must return security.ChallengeProvider (not a concrete type).

func ProvideMCPPrompts

func ProvideMCPPrompts(constructor any, paramTags ...string) fx.Option

ProvideMCPPrompts provides an MCP prompt provider. The constructor must return mcp.PromptProvider (not a concrete type).

func ProvideMCPResourceTemplates

func ProvideMCPResourceTemplates(constructor any, paramTags ...string) fx.Option

ProvideMCPResourceTemplates provides an MCP resource template provider. The constructor must return mcp.ResourceTemplateProvider (not a concrete type).

func ProvideMCPResources

func ProvideMCPResources(constructor any, paramTags ...string) fx.Option

ProvideMCPResources provides an MCP resource provider. The constructor must return mcp.ResourceProvider (not a concrete type).

func ProvideMCPTools

func ProvideMCPTools(constructor any, paramTags ...string) fx.Option

ProvideMCPTools provides an MCP tool provider. The constructor must return mcp.ToolProvider (not a concrete type).

func ProvideMiddleware

func ProvideMiddleware(constructor any, paramTags ...string) fx.Option

ProvideMiddleware provides a middleware to the dependency injection container. The middleware will be registered in the "vef:app:middlewares" group. The constructor must return app.Middleware (not a concrete type).

func ProvideSPAConfig

func ProvideSPAConfig(constructor any, paramTags ...string) fx.Option

ProvideSPAConfig provides a Single Page Application configuration to the dependency injection container. The config will be registered in the "vef:spa" group.

func Run

func Run(options ...fx.Option)

Run starts the VEF framework with the provided options. It initializes all core modules and runs the application.

func SupplyMCPServerInfo

func SupplyMCPServerInfo(info *mcp.ServerInfo) fx.Option

SupplyMCPServerInfo supplies MCP server info.

func SupplySPAConfigs

func SupplySPAConfigs(config *middleware.SPAConfig, configs ...*middleware.SPAConfig) fx.Option

SupplySPAConfigs supplies multiple Single Page Application configurations to the dependency injection container. All configs will be registered in the "vef:spa" group.

Types

type Hook

type Hook = fx.Hook

func StartHook

func StartHook[T HookFunc](start T) Hook

func StartStopHook

func StartStopHook[T1, T2 HookFunc](start T1, stop T2) Hook

func StopHook

func StopHook[T HookFunc](stop T) Hook

type HookFunc

type HookFunc = fx.HookFunc

type In

type In = fx.In

type Lifecycle

type Lifecycle = fx.Lifecycle

type Out

type Out = fx.Out

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL