Back to Portfolio
Full Stack Application

BookOrbit

Two readers tap 'borrow' on the last copy at the same instant. Without transactional guarantees, both succeed — and the inventory is now a lie that surfaces weeks later as a billing dispute. BookOrbit was built so that moment cannot happen.

A comprehensive Library Management System and Marketplace built for reliability, scalability, and secure transactions.

Problem

Marketplace and library systems face high data integrity risks during concurrent operations, such as multiple users attempting to claim the same inventory item. Without strict transactional guarantees, this leads to over-borrowing and financial inconsistencies.

Solution

A comprehensive transactional system built around ACID guarantees. It ensures 100% inventory accuracy through row-level locking while providing a scalable marketplace experience with secure payment handling.

Architecture

Relational Integrity

Utilized a MySQL database with Sequelize ORM. Implemented explicit transactions with row-level locks on critical inventory tables to prevent race conditions during concurrent user actions.

Scalable File Workflows

Automated digital asset management using AWS S3. Engineered middleware to handle multipart file uploads via streams, significantly reducing memory overhead on the application server.

Infrastructure: Inventory Transaction

// Secure borrowing logic with transaction
const borrowBook = async (userId, bookId) => {
  const t = await sequelize.transaction();
  try {
    const book = await Book.findByPk(bookId, 
      { lock: true, transaction: t });
    if (book.copies < 1) throw new Error('Out of stock');
    
    await book.decrement('copies', { transaction: t });
    await Loan.create({ userId, bookId }, 
      { transaction: t });
    await t.commit();
  } catch (error) {
    await t.rollback();
    throw error;
  }
}

Key Decisions

01Pessimistic locking over optimistic retries

ConsideredOptimistic concurrency — detect the conflict after the fact and retry the transaction.

ChoseExplicit transactions with row-level locks on critical inventory tables. A borrow or purchase must be right the first time, not eventually.

Trade-offLower throughput under heavy contention. The win: 100% inventory accuracy with no reconciliation debt.

02Streaming uploads instead of buffering

ConsideredBuffering multipart uploads in application memory before pushing to storage — the default in most tutorials.

ChoseStream-based middleware that pipes file uploads to AWS S3 without holding them in memory.

Trade-offTrickier middleware and error handling. The win: a flat memory profile on the app server no matter how large the file.

03Hardening the backend, not trusting the layers

ConsideredImplicit trust between application layers — the pattern most marketplaces run with until it bites.

ChoseExplicit auth checks at every external boundary: Stripe webhooks, S3 uploads, MySQL writes.

Trade-offMore verification code at every seam. The win: no single compromised layer can reach the data behind it.

Technology

Node.jsExpressMySQLAWS S3Stripe APISequelize ORMSequelize

Outcome

Before

Concurrent claims on the same item quietly produce over-borrowing and billing inconsistencies.

After

Row-level locks and ACID transactions make every inventory count and every payment exact.

BookOrbit successfully demonstrated the capacity to handle heavy transactional loads while maintaining absolute data integrity. The integration of cloud-native storage and secure financial gateways created a production-ready solution for digital marketplaces.