I'm a software architect and founder in Izmir, Türkiye. I run Mobixify, an independent software studio, and write engineering notes with code.
I have worked on production software since 2013, across the full stack: backend, frontend, mobile, AWS and real-time systems.
Newest first. Each note carries working code.
2026-10-24Freeze invoices as snapshots: totals, rule versions and numbering2026-10-23Design the reconnect first: sequence numbers, replay and snapshots2026-10-23Run AI agents like queue workers: briefs, budgets and stop reasons
Shorter code references are at mnevfel.com/snippets. All notes are at mnevfel.com/notes.
From Gapless invoice numbering in PostgreSQL without a sequence. The row lock orders issuers, and a rollback gives the number back.
-- per issue, READ COMMITTED (the default)
BEGIN;
UPDATE number_counters SET last_seq = last_seq + 1
WHERE tenant_id = $1 AND series = $2
RETURNING last_seq; -- zero rows: no such series, ROLLBACK
INSERT INTO documents (id, tenant_id, series, seq_no, idempotency_key)
VALUES ($3, $1, $2, $4, $5); -- $4 is the last_seq returned above
COMMIT; -- on any error, including 23505: ROLLBACK2026-11-13pg-gapless: Gapless invoice and receipt numbers in PostgreSQL for Node.js, safe under retries and rollbacks
Most of my work was for employers and clients, so it is not public.
mnevfel.com · Now · LinkedIn · X




