overview
THE PROBLEM
Indonesian SMBs were stuck using WhatsApp catalogs and spreadsheets to manage their online stores. Existing platforms like Tokopedia were either too expensive or too rigid for small vendors. NusaCart was built to fill that gap - a self-hosted, open-source alternative with full control over inventory, pricing, and customer data.
The biggest challenge was building something robust enough for flash sales (where hundreds of orders can hit in under a minute) while keeping the UI simple enough for vendors with minimal tech experience.
engineering
CHALLENGES & SOLUTIONS
01
Race conditions during flash sales. When 300+ users hit "Buy Now" simultaneously, inventory counts would desync. Solved using SELECT FOR UPDATE with PostgreSQL row-level locking and a Redis queue to serialize order writes.
02
Payment gateway fragmentation. Indonesia has 12+ popular payment methods (GoPay, OVO, DANA, virtual accounts). Built a unified PaymentAdapter interface so each provider plugs in without touching core logic.
03
Real-time inventory sync. Multiple vendor admins editing stock at the same time caused stale reads. Implemented a WebSocket broadcast system using socket.io rooms per vendor - updates propagate to all tabs instantly.
01async function createOrder(payload: OrderPayload) {
02 return db.transaction(async (trx) => {
03 // Lock the product row to prevent race conditions
04 const product = await trx('products')
05 .where({ id: payload.productId })
06 .forUpdate() // SELECT FOR UPDATE
07 .first();
08
09 if (product.stock < payload.qty)
10 throw new Error('Out of stock');
11
12 await trx('products')
13 .where({ id: payload.productId })
14 .decrement('stock', payload.qty);
15
16 const [orderId] = await trx('orders').insert(payload);
17 await redis.publish('inventory:update', payload.productId);
18 return orderId;
19 });
20}
outcomes
RESULTS
After 6 months in production across 8 pilot vendors in Bandung and Jakarta, NusaCart processed over 14,000 orders without a single inventory desync error during flash sales.
99.8%
Uptime over 6 months
<200ms
Avg. API response time