Backend for a Gym Management Platform
NestJS, TypeScript, MikroORM, PostgreSQL, AWS S3
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.
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.
Implemented pessimistic locking strategies to handle concurrent purchases during flash sales, preventing overselling while maintaining system performance under high load.
Integrated with Midtrans payment gateway, handling webhooks for real-time payment status updates and implementing idempotent transaction processing to prevent duplicate charges.
Uses AWS S3 for storing member photos, QR codes, and promotional materials with presigned URLs for secure access.
Managing inventory during flash sales where hundreds of users try to purchase limited items simultaneously was challenging. Race conditions could lead to overselling.
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.
Handling different memberships, classes, and inventory across multiple branches while maintaining centralized control was complex.
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.