Skip to content

seun-ja/ledger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ledger Microservice

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.


Functional Scope

1) Accounts

  • 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).

2) Double-Entry Transactions

  • POST /transactions with reference, optional metadata, 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-Key header for safe retries.
  • GET /transactions/{id} and GET /transactions (filters: account, reference contains, date range, pagination).

3) Balances & Snapshots

  • GET /accounts/{id}/balance?at=ISO8601 → point-in-time balance.
  • Background job (daily): compute balance_snapshots(account_id, as_of, amount).

4) Search

  • Index accounts and transactions in Typesense.
  • GET /search?q=... → search across account names, transaction reference, and metadata.

Quickstart

  1. Copy .env.example.env and adjust if needed.
  2. make compose-up to start Postgres/Redis/Typesense (and API if you wire it).
  3. make migrate then make serve (and make worker for background jobs).
  4. make test to run tests.

About

Ledger Microservice in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published