In the world of online marketplaces, trust is everything. For a hybrid platform like Zolanc, where buyers purchase code templates and immediately hire the original creators for custom updates, the core challenge is securing transaction escrows. We needed a payment ledger that prevents double spending, operates with strict transactional guarantees, and reports balances with zero sync latency.
Initially, we explored distributed ledgers and third-party accounting APIs. However, we realized that introducing third-party network calls inside lock routines caused unacceptable overhead. We decided to build a self-hosted transaction ledger directly inside our core PostgreSQL database.
To ensure 100% financial integrity, we implemented strict database-level row locks (using SELECT ... FOR UPDATE) and transaction isolation guarantees. By using PostgreSQL's SERIALIZABLE isolation level for ledger calculations, we prevent race conditions during concurrent milestone releases.
Here is a look at our core ledger entry structure:
-- Create transaction journal table
CREATE TABLE milestone_ledger (
id SERIAL PRIMARY KEY,
order_id VARCHAR(50) NOT NULL,
milestone_id VARCHAR(50) NOT NULL,
amount NUMERIC(12, 2) NOT NULL,
type VARCHAR(10) CHECK (type IN ('HOLD', 'RELEASE', 'REFUND')),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
When a buyer funds a milestone, a 'HOLD' journal entry is appended inside a transaction block. The creator profile updates with zero sync latency because balance calculations read the sum of released milestone journals directly, indexed by user ID.
By avoiding mutable 'balance' columns and calculating values dynamically from double-entry logs, we prevent balance mismatch errors entirely. Zolanc ensures secure, fast payouts, giving creators peace of mind that their work is fully protected.