All case studies
CASE / 04 — Database reliability

ACID Transaction Ledger

How can a fund-transfer system protect balances when a transaction fails or multiple transfers happen at once?

PostgreSQLPythonSQLAlchemyPsycopg2
Vintage terminal artwork representing the transaction ledger, not a test-result screenshot
FIG. 01 / LEDGER CONCEPT ART — NOT TEST OUTPUT

01 / THE QUESTION

How can a fund-transfer system protect balances when a transaction fails or multiple transfers happen at once?

02 / THE APPROACH

Build a PostgreSQL and Python ledger with debit, credit, and transaction logging inside one database transaction. Add a non-negative balance constraint and a concurrency test comparing isolation levels.

03 / THE RESULT

Implemented schema and atomic transfer logic, with concurrency and durability tests still being run and documented in the repository.

[ Project insights ]

EVIDENCE / FINDINGS
/01

A transfer is one unit of work

The transfer function wraps debit, credit, and logging in conn.begin(). If a step fails, the transaction rolls back instead of leaving a partially completed transfer.

/02

Guardrails belong in the database

CHECK (balance >= 0) protects the balance invariant at the database level, regardless of which application writes to the table.

/03

Concurrency is a separate question

The repository includes a multithreaded scenario comparing READ COMMITTED and SERIALIZABLE. Published test outcomes are not complete, so neither isolation nor crash durability is presented as fully verified.

CONTEXT / LIMITATIONS
The repository explicitly marks this project In Progress. Concurrency and durability evidence is incomplete; the illustration is concept artwork, not proof of a successful test run.