Skip to content
← All work

Personal · finance backend · 2026In progress

Ledger API

A ledger API I built in phases to practise writing money code properly: layered TypeScript and Express, storage that moved from JSON to SQLite through a migration, and authentication hardened step by step.

Who wrote whatI used an AI tutor to explain concepts while learning; I wrote the code.

Request path
  1. helmet, CORS allow-list, rate limit on /auth
  2. JWT middleware + revoked-token check
  3. Controller
  4. Service and validation
  5. TransactionRepository interface
  6. JSON or SQLite adapter

The idea

Money code should be boring, traceable and secure. This started as a command-line expense tracker. Each phase added one thing and a document explaining why.

What's in it

Controllers call a service, and the service talks to a TransactionRepository interface. Both a JSON file and SQLite implement it, so I swapped storage with a migration script instead of a rewrite. Every query is scoped to the signed-in user. SQLite runs in WAL mode with foreign keys on.

Auth

Passwords are hashed with bcrypt. Access tokens last 15 minutes and carry an ID, so logout can revoke them. Refresh tokens last 7 days, rotate on every use, and are stored only as SHA-256 hashes, so a database leak doesn't hand out sessions. Auth routes are rate-limited, and helmet and a CORS allow-list sit in front of everything.

Next

Store amounts as whole pesewas instead of floats, add idempotency keys so a retried request can't record a payment twice, write an OpenAPI spec, add CI and deploy a demo.

NextSite Scope→

07 · Contact

Write to me.

I'm open to software engineering and data roles, and to freelance work. If you have a process that still runs on copy and paste, I'd like to hear about it.