Skip to the content
Precision Soft
All projects

Melody

Go

A Go framework for web and CLI applications. It is built around explicit configuration, deterministic wiring and a published support policy.

View on GitHubgo get github.com/precision-soft/melody/v3

Melody is a Go framework for HTTP applications and CLI commands. Both run on the same runtime, container, configuration, logging and validation. Boot wiring happens once, and then each request or command runs in its own scope.

It is for teams that want deterministic wiring. Behaviour is assembled through modules, services and explicit registration, not global state. There is also a clear line between the userland APIs you build on and the framework internals you never depend on. v3 is the stable, actively maintained line, and the one to pick for new projects.

Installation

v3 requires Go 1.25 or later.

go get github.com/precision-soft/melody/v3

Minimal example

A minimal HTTP application with one route:

package main
 
import (
    "context"
    nethttp "net/http"
 
    "github.com/precision-soft/melody/v3/application"
    melodyhttp "github.com/precision-soft/melody/v3/http"
    httpcontract "github.com/precision-soft/melody/v3/http/contract"
    runtimecontract "github.com/precision-soft/melody/v3/runtime/contract"
)
 
func main() {
    melodyApplication := application.NewApplication(context.Background(), nil, nil)
 
    melodyApplication.RegisterHttpRoute(
        "GET",
        "/health",
        func(
            runtimeInstance runtimecontract.Runtime,
            writer nethttp.ResponseWriter,
            request httpcontract.Request,
        ) (httpcontract.Response, error) {
            body := []byte(`{"status":"ok"}`)
 
            return melodyhttp.NewResponse(nethttp.StatusOK, body), nil
        },
    )
 
    melodyApplication.Run()
}

An HTTP process refuses to boot without at least one key from its .env files, so the sample needs a one-line .env next to go.mod. The server listens on :8080 by default:

echo 'MELODY_ENV=dev' > .env
go run .
curl http://localhost:8080/health
# {"status":"ok"}

For a fully wired application (modules, services, security, sessions, events, CLI commands and every platform integration), see the example application under v3/.example/.

Architecture

  • The application wires modules and services into a container.
  • The runtime owns the lifecycle (boot, compile, run, shutdown) and creates request and command scopes.
  • The kernel holds the container, the clock and the event dispatcher, and dispatches the kernel events a request travels through.
  • HTTP uses the runtime and container scopes to run middleware and dispatch handlers; CLI runs commands inside the same infrastructure.
  • Cross-cutting packages are wired as services: logging, event, validation, cache, session, security.

Beyond these, v3 ships packages for distributed locks, email (mailer), an asynchronous message bus, OpenAPI 3.0.3 document generation, object storage, translation with an ICU-subset formatter, and container autowiring code generation (wiring).

Melody is extended through modules (services and configuration defaults), your own container registrations, event subscribers, HTTP middleware and CLI commands. Some APIs are intentionally closed to keep behaviour deterministic; where an extension point exists, the package documentation names it.

Integrations

Optional integrations connect Melody to third-party systems. Each is a separate Go module, so you only pull in what you use:

  • amqp: RabbitMQ transport for the message bus (publisher confirms, auto-reconnect, dead-lettering).
  • awss3: S3-compatible object-storage backend for the storage package.
  • bunorm: Bun ORM database access, with MySQL and PostgreSQL wiring and migration CLI commands.
  • cron: crontab generation from registered schedules.
  • opentelemetry: distributed tracing (OTLP) and HTTP metrics (Prometheus exposition) as middlewares.
  • outbox: transactional outbox for the message bus.
  • rueidis: Redis-backed cache and rate limiter, plus distributed lock, token store and SSE backplane in v3.
  • websocket: WebSocket support bound to the server-sent-event hub.

Build tags

Two independent build tags embed configuration and assets into the binary via Go embed, so you can embed one family while keeping the other on the filesystem:

  • melody_env_embedded: embeds the .env configuration instead of reading .env / .env.local from the filesystem.
  • melody_static_embedded: embeds static assets instead of serving them from a public/ directory.
go build -o app .
go build -tags melody_env_embedded -o app .
go build -tags "melody_env_embedded melody_static_embedded" -o app .

Versions and support policy

Melody ships as parallel Go module lines. Each line is a self-contained duplicate rather than shared code, so every module and integration binds to exactly one framework version.

Each line has its own module path: github.com/precision-soft/melody/v3 for v3, the same with /v2 and /v4, and the repository root for v1.

LineReleasedStatusSupported until
v4Q1 2027 (planned)Planned. Removes the deprecations v3 accumulates.-
v32026-03-08Stable and actively maintained, the line to pick today. v3.14.0 is its last feature release.18 months after v4 ships
v22026-02-17Feature-frozen since 2026-08-182027-09-08
v12026-01-17Feature-frozen since 2026-08-182027-08-17

The rule behind the dates:

  • The current line receives security fixes, patch-level defect fixes and deprecations. New features land in it until its last feature release: for v3 that was v3.14.0, and the next features ship in v4.
  • The day a new major ships, the line it replaces keeps receiving security fixes and patch-level defect fixes for 18 more months, counted from the successor's release date. From v4 on, it also stops receiving features that day.
  • v1 was replaced by v2 on 2026-02-17 and is supported through 2027-08-17; v2 was replaced by v3 on 2026-03-08 and is supported through 2027-09-08. v3 has no end date yet: its clock starts the day v4 ships, and Q1 2027 is a plan rather than a commitment.
  • Within v3, an API that needs to change is first marked with a /* Deprecated: ... */ doc comment and kept working. Every deprecated symbol names its successor, so an application that adopts the replacements early crosses to v4 with no change beyond the module path.

An application moving off v1 or v2 starts at the "Migrating to v3" section of its upgrade guide. Vulnerabilities are reported privately through the repository's Security tab, never in a public issue.

Documentation