F-01
Double-entry domain model
Invariants encoded directly in Go types: an unbalanced transaction won't compile a path to disk. Validate() runs before anything touches Postgres.
open source, MIT, Go 1.26
Double-entry accounting with invariants that are impossible to violate. Built in the open over 14 weeks: atomic posting, idempotency, an immutable audit log, and one trace from HTTP to SQL.
// Validate enforces the balance invariant:
// postings must sum to exactly zero.
func (t *Transaction) Validate() error {
if len(t.Postings) < 2 {
return ErrTooFewPostings
}
var sum int64
for _, p := range t.Postings {
sum += p.Amount // signed minor units
}
if sum != 0 {
return ErrUnbalanced
}
return nil
}
01 · guarantees
Six properties a payment ledger must have, each one shipped, tested, and documented in its own build-log post.
F-01
Invariants encoded directly in Go types: an unbalanced transaction won't compile a path to disk. Validate() runs before anything touches Postgres.
F-02
SERIALIZABLE isolation plus ordered row locks, stress-tested under heavy contention. Concurrent posts either fully apply or fully retry.
F-03
An Idempotency-Key makes a retry safe: the same key returns the original transaction and never moves money twice.
F-04
Append-only, written in the same transaction as the posting, and hash-chained row to row. UPDATE and DELETE are refused by a Postgres trigger, and a verify call recomputes the whole chain to prove nothing was altered.
F-05
Two front doors over one shared domain core, so the protocols cannot drift. Same rules, same errors, same guarantees.
F-06
One OpenTelemetry trace from HTTP to SQL, the same trace_id in every log line, RED metrics beside the native ones. No amounts ever leave the process.
02 · the plan
The roadmap was published before week one. Every week ships code, a blog post, and the decision records behind it.
03 · tools
Every dependency earned its place, and each choice has an ADR explaining the trade-offs.
04 · the record
Every week, written down.
The design decisions, the dead ends, and the reasoning behind every invariant, published the week each one ships. Not a tutorial polished after the fact: the real build, in order, with the trade-offs still visible.
Read the series →05 · the book
The 14-week build, every ADR, and the senior-engineer interview questions this project would put you through, in one volume. Free.
Want it in print? Sign interest, Bangladesh only.06 · the builder
A Tech Lead and Solutions Architect with 8+ years shipping production software across fintech, hospitality, and logistics (Bangladesh, Malaysia, Luxembourg), currently at Moby Money. go-ledger is me going deep on Go and payment infrastructure in public, from an empty repo to a live deploy. Open to fintech leadership, advisory, and interesting infrastructure work.