← All posts
Personal ProjectNext.jsPostgreSQLFull-Stack
July 20, 2026 · 6 min read

Building CREMS: A Credit-Based Economy Platform

CREMS started as a wild idea scribbled in a notebook — what if we could build a micro-economy powered by credits instead of traditional currency? Here's how I turned that into crems.app.

Every project starts with a problem. For me, CREMS started with a question: what if communities could run their own internal economy without relying on traditional banking infrastructure? Credits — not cash — as the unit of exchange.

The Core Idea

CREMS (Credit-Based Economy Management System) is a platform where users earn, spend, and transfer credits within a closed ecosystem. Think of it like a loyalty point system — but fully programmable, transparent, and user-controlled.

Tech Stack Decisions

I chose Next.js for the full-stack layer — it gives me SSR for the dashboard, API routes for backend logic, and a clean developer experience. PostgreSQL handles the ledger because ACID compliance is non-negotiable when you're dealing with financial transactions.

  • Next.js 15 (App Router) for frontend and API
  • PostgreSQL with row-level locking for the credit ledger
  • TypeScript end-to-end for type safety
  • JWT-based auth with refresh tokens

The Hardest Part: Concurrency

The trickiest engineering challenge was ensuring that two simultaneous transfers don't create a race condition and corrupt balances. I solved this using PostgreSQL's SELECT FOR UPDATE to lock rows during a transaction, ensuring atomicity at the database level.

BEGIN;
SELECT balance FROM wallets WHERE id = $1 FOR UPDATE;
UPDATE wallets SET balance = balance - $2 WHERE id = $1;
UPDATE wallets SET balance = balance + $2 WHERE id = $3;
COMMIT;

What's Next

CREMS is live at crems.app and actively being developed. The next milestone is introducing programmable credit rules — organizations can define their own earning/spending logic via a simple rule engine.