Tatang Romadhona

TMPRJCT

Launching Nov 2025

Backend for a Gym Management Platform

NestJS, TypeScript, MikroORM, PostgreSQL, AWS S3

Overview

TMPRJCT is a comprehensive backend system built for a gym management platform that handles everything from memberships to flash sales. The platform is designed to keep operations smooth during high-traffic events like promotional campaigns while managing day-to-day activities like class bookings and member check-ins.

Built with scalability in mind, the system uses NestJS and PostgreSQL to handle complex business logic around inventory management, payment processing, and multi-branch operations.

Key Features

  • Real-time Inventory Tracking: Handles flash sales and promotional items with accurate stock management to prevent overselling during high-demand periods.
  • Smart Membership Management: Multi-branch membership system with flexible plans, automated renewals, and member tier management.
  • Payment Integration: Seamless Midtrans payment gateway integration supporting multiple payment methods including credit cards, e-wallets, and bank transfers.
  • Class Booking System: Members can book classes in advance with QR-code based attendance tracking for seamless check-ins.
  • Multi-Branch Support: Centralized management across multiple gym locations with branch-specific inventory and class schedules.

Technical Implementation

Architecture

Built using NestJS with a modular architecture that separates concerns between memberships, inventory, payments, and bookings. Uses MikroORM for database management with PostgreSQL, ensuring type-safe queries and efficient data handling.

Flash Sales Management

Implemented pessimistic locking strategies to handle concurrent purchases during flash sales, preventing overselling while maintaining system performance under high load.

Payment Processing

Integrated with Midtrans payment gateway, handling webhooks for real-time payment status updates and implementing idempotent transaction processing to prevent duplicate charges.

File Management

Uses AWS S3 for storing member photos, QR codes, and promotional materials with presigned URLs for secure access.

Challenges & Solutions

Challenge: Flash Sale Concurrency

Managing inventory during flash sales where hundreds of users try to purchase limited items simultaneously was challenging. Race conditions could lead to overselling.

Solution:

Implemented database-level pessimistic locking combined with a queue system to serialize critical inventory updates. Added real-time inventory checks with atomic operations to ensure data consistency.

Challenge: Multi-Branch Complexity

Handling different memberships, classes, and inventory across multiple branches while maintaining centralized control was complex.

Solution:

Designed a hierarchical data model with branch-level isolation for day-to-day operations while maintaining cross-branch visibility for administrators. Used MikroORM's unit of work pattern to manage complex cross-branch transactions.

Technology Stack

Backend

  • NestJS - Scalable Node.js framework
  • TypeScript - Type-safe development
  • MikroORM - TypeScript ORM

Infrastructure

  • PostgreSQL - Primary database
  • AWS S3 - File storage
  • Midtrans - Payment gateway

Key Learnings

  • Mastered handling high-concurrency scenarios with pessimistic locking and queue-based processing for critical operations.
  • Learned to design multi-tenant architectures that balance isolation with centralized management.
  • Gained experience integrating payment gateways with idempotent transaction handling and webhook processing.
  • Improved understanding of MikroORM's unit of work pattern and how to leverage it for complex business transactions.