Melody is a Go framework focused on building HTTP applications and CLI commands on top of the same runtime, container, configuration, logging, and validation infrastructure.
Using Melody for the first time? v3 is the stable, actively maintained version. Start with the module under
./v3/and the runnable showcase in./v3/.example/. See Versions & project status for why three versions exist.
Install the v3 module:
go get github.com/precision-soft/melody/v3A minimal HTTP application:
package main
import (
"context"
nethttp "net/http"
"github.com/precision-soft/melody/v3/application"
melodyhttp "github.com/precision-soft/melody/v3/http"
melodyhttpcontract "github.com/precision-soft/melody/v3/http/contract"
melodyruntimecontract "github.com/precision-soft/melody/v3/runtime/contract"
)
func main() {
app := application.NewApplication(context.Background(), nil, nil)
app.RegisterHttpRoute(
"GET",
"/health",
func(
runtimeInstance melodyruntimecontract.Runtime,
writer nethttp.ResponseWriter,
request melodyhttpcontract.Request,
) (melodyhttpcontract.Response, error) {
return melodyhttp.NewResponse(nethttp.StatusOK, []byte(`{"status":"ok"}`)), nil
},
)
app.Run()
}An http process refuses to boot when its .env files contributed no key, since every built-in parameter has a development default, so the sample carries a one-line .env beside its go.mod. Run it, then call the endpoint (the HTTP server listens on :8080 by default):
echo 'MELODY_ENV=dev' > .env
go run .
curl http://localhost:8080/health
# {"status":"ok"}-
Read the example application — a realistic catalog app wiring modules, services, security, sessions, events, CLI commands, and every platform integration. Run the whole showcase (example + every backing service) with one command from the repository root:
./dc up:all --build
Then open http://localhost:8180 (
DEV_HTTP_HOST_PORT). Use./dc up:all(backends are on the composeallprofile) — not plain./dc up; see the example README for details. -
Browse the v3 package documentation for the API reference.
-
Add an integration (database, Redis, message broker, object storage, observability).
Melody is designed for teams that want:
- A single service container and runtime lifecycle shared by HTTP and CLI entrypoints.
- Deterministic wiring: behavior is assembled through modules, services, and explicit registration rather than global state.
- Clear boundaries between userland APIs (what you build on) and framework internals (what you do not depend on).
At a high level, a Melody application is assembled as follows:
- Application (code) wires modules and services into a container (code).
- A runtime (code) owns the lifecycle (boot/compile/run/shutdown) and creates request/command scopes.
- The kernel (code) is the compiled heart handed to both fronts: it holds the container, the clock and the event dispatcher, and dispatches the kernel events a request travels through.
- HTTP (code) uses the runtime + container scopes to run middleware and dispatch handlers.
- CLI (code) runs commands inside the same runtime/container infrastructure.
- Cross-cutting packages are wired as services: logging, event, validation, cache, session, security.
Melody ships as three parallel Go module lines, with a fourth in development:
| Version line | Module path | Released | Latest | Status | Supported until |
|---|---|---|---|---|---|
| v4 | github.com/precision-soft/melody/v4 |
Q1 2027 (planned) | — | Planned — the deprecations v3 accumulates are removed there; no code exists yet | — |
| v3 | github.com/precision-soft/melody/v3 (./v3/) |
2026-03-08 | v3.14.6 | Stable, actively maintained — use this for new projects. v3.14.0 is its last feature release; security fixes, patch-level defect fixes and deprecations land here | set the day v4 ships, 18 months after it |
| v2 | github.com/precision-soft/melody/v2 (./v2/) |
2026-02-17 | v2.13.4 | Feature-frozen since 2026-08-18 (v2.13.0) |
2027-09-08 |
| v1 | github.com/precision-soft/melody (repository root) |
2026-01-17 | v1.19.4 | Feature-frozen since 2026-08-18 (v1.19.0) |
2027-08-17 |
The support policy, in two sentences. The current line receives new features, security fixes and deprecations. 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 and v2 were frozen later, on 2026-08-18, after their last minors).
Every end-of-support date in the table is that one rule applied to the release dates beside it, so a reader can check it rather than take it: 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 carries no end date because it is the current line — its clock starts the day v4 ships, and Q1 2027 for v4 is a plan rather than a commitment. "Supported until" covers security fixes and patch-level defect fixes; a feature-frozen line receives no new capability whatever remains of its window. An application that wants the v4 vocabulary early adopts the replacements v3 already carries — every deprecated symbol names its successor — and then crosses the cut with no change to its own code.
Three versions exist for historical reasons: earlier major versions introduced changes that were not backwards
compatible, and each was maintained in parallel. v3.14.0 is the last feature release of v3; the next features ship in
v4 (planned Q1 2027). Until then v3 keeps receiving security fixes and patch-level defect fixes, and the day v4 ships
it enters the 18-month window v1 and v2 are in now. v1 and v2 are feature-frozen and receive patch-level defect and
security fixes through the dates in the table above (see SECURITY.md and
CONTRIBUTING.md). An application moving off a frozen major starts at the "Migrating to v3"
section of its upgrade guide: .documentation/UPGRADE.md for v1,
v2/.documentation/UPGRADE.md for v2.
Within v3, evolution follows the standard Go approach: APIs that need to change are first marked with a /* Deprecated: ... */ doc comment and kept working, and a future v4 (planned Q1 2027) will be cut once enough breaking changes have accumulated.
The three versions are intentionally self-contained duplicates rather than shared code, so that every module and integration binds to exactly one framework version. This duplication is by design and is not to be consolidated.
Melody is extended primarily through:
- Modules: register services and configuration defaults.
- Services: your container registrations (including overriding framework defaults where supported).
- Events: subscribe to lifecycle and domain events.
- HTTP middleware: compose request behavior around handlers.
- CLI commands: register commands within the CLI integration.
Some APIs are intentionally closed to keep behavior deterministic and to avoid dependency on internal wiring. When an extension point exists, it is documented explicitly in the relevant package documentation.
Optional modules connect Melody to third-party systems (databases, Redis, message brokers, object storage, observability). Each is a separate Go module, so you only pull in what you use.
See the integrations index for the full list, supported version lines, and per-integration documentation.
Melody supports two independent embedding modes controlled by build tags:
- Environment configuration (
.env-style files) - Static assets (filesystem vs embedded)
These are intentionally independent so you can embed one family while keeping the other on the filesystem.
Build tag:
melody_env_embedded
-
Without
melody_env_embedded
Environment configuration is loaded from filesystem.envfiles (for example.env,.env.local). This is the default for local development. -
With
melody_env_embedded
Environment configuration is embedded into the binary at build time (via Goembed). The runtime reads the embedded.envcontent instead of the filesystem.
go build -o app .
go build -tags melody_env_embedded -o app .Build tag:
melody_static_embedded
-
Without
melody_static_embedded
Static assets are served from the filesystem (for example from an application-providedpublic/directory). This is the default for local development. -
With
melody_static_embedded
Static assets are embedded into the binary at build time (via Goembed). The HTTP layer serves the embedded assets.
go build -o app .
go build -tags melody_static_embedded -o app .You can combine the tags to embed both families:
go build -tags "melody_env_embedded melody_static_embedded" -o app .For a complete example that shows the same build-tag matrix applied end-to-end in a userland application, see .example/README.md.
Melody documentation follows a strict, canonical structure. The documentation canon is defined in .documentation/DOCUMENTATION.md and is normative for all Markdown files in this repository.
Key entry points:
- Framework entry document:
README.md - Example application documentation:
.example/README.md - Contribution and code style rules:
CONTRIBUTING.md - Security policy:
SECURITY.md - Package documentation (API reference):
.documentation/package/ - Roadmap (future plans):
.documentation/ROADMAP.md
The list below is the v1 package surface (repository root). The actively maintained v3 line adds lock, mailer, messagebus, openapi, storage, translation, and wiring — see the v3 package list.
Each package below links to its source folder and its package documentation.
-
APPLICATION — code | docs
High-level application bootstrap, module registration, and run modes. -
BAG — code | docs
Typed value access patterns and conversion semantics used by configuration. -
CACHE — code | docs
In-process caching contracts and implementations. -
CLI — code | docs
CLI contracts, command registration, and execution model. -
CLOCK — code | docs
Clock abstraction for deterministic time and testing. -
CONFIG — code | docs
Configuration loading and composition (file-based, env artifacts). -
CONTAINER — code | docs
Dependency injection container, scopes, service factories, and lifecycle. -
DEBUG — code | docs
Built-in CLI debug commands (container, events, router, middleware, parameters, version). -
EVENT — code | docs
Deterministic event dispatching and subscriber/listener contracts. -
EXCEPTION — code | docs
Error wrappers, context propagation, and fail-fast helpers. -
HTTP — code | docs
HTTP server, router integration, middleware execution, request orchestration. -
HTTPCLIENT — code | docs
Outbound HTTP client contracts and helpers. -
INTERNAL — code | docs
Framework-internal helper utilities, not intended for userland consumption; APIs may change without notice. -
KERNEL — code | docs
Kernel integration points that connect application, runtime, and HTTP/CLI wiring. -
LOGGING — code | docs
Structured logging contracts and framework logging conventions. -
RUNTIME — code | docs
Application runtime lifecycle, boot/compile/run, and wiring orchestration. -
SECURITY — code | docs
Access control rules, authentication integration points, and security wiring. -
SERIALIZER — code | docs
Serialization contracts and helpers for request/response boundaries. -
SESSION — code | docs
Session storage contracts and request/session lifecycle integration. -
VALIDATION — code | docs
DTO validation engine, constraints, and errors.
The full userland showcase lives under ./.example/. Start here:
Development workflow and contribution rules:
Melody was developed and iterated through multiple internal, beta, and release-candidate phases in a GitLab repository, where the full architectural evolution, design decisions, and refactors leading up to v1.0.0 took place.
This GitHub repository represents the first stable public release of Melody, starting with version v1.0.0, intentionally published with a clean history focused on long-term stability and user adoption.
If you want to explore the full development history that led to v1.0.0, see: https://gitlab.com/precision-soft-open-source/go/melody
