A production-style ledger microservice in Go. Records double-entry transactions, exposes a REST API, persists to PostgreSQL, runs background jobs with Redis + Asynq, supports full-text search via Typesense, and includes observability (health/readiness, metrics/traces, structured logs). Provides a good DX via Docker/Compose and a Makefile. Adds a small CLI for ops tasks.
POST /accounts→ create{name, currency (ISO 4217), metadata}.GET /accounts/{id}→ details incl. computed balance.GET /accounts→ list with basic filters (currency, name contains, pagination).
POST /transactionswithreference, optionalmetadata, and legs:[{account_id, amount, direction: debit|credit}].- Validate sum(debits) == sum(credits) in the same currency.
- Use decimal arithmetic (no floats).
- Persist immutable journal rows.
- Idempotency: support
Idempotency-Keyheader for safe retries. GET /transactions/{id}andGET /transactions(filters: account, reference contains, date range, pagination).
GET /accounts/{id}/balance?at=ISO8601→ point-in-time balance.- Background job (daily): compute
balance_snapshots(account_id, as_of, amount).
- Index accounts and transactions in Typesense.
GET /search?q=...→ search across account names, transaction reference, and metadata.
- Copy
.env.example→.envand adjust if needed. make compose-upto start Postgres/Redis/Typesense (and API if you wire it).make migratethenmake serve(andmake workerfor background jobs).make testto run tests.