🛠️ Backend | Node.js | Express.js | MySQL | Sequelize | JWT | Microservices
Flight Booking Service
- Microservices Architecture: Separates booking logic from flight search to handle high search traffic without affecting booking stability.
- API Gateway / Reverse Proxy: Directs frontend requests to appropriate microservices.
- Load Balancer: Distributes incoming traffic across service instances for high availability.
- Service Communication: Booking Service may call Search Service to verify availability or update inventory.
- Concurrency Handling: Implements row-level locking to prevent double-booking when multiple users try to book the same seat simultaneously.
High-Level Request Flow:
Frontend Request
↓
Load Balancer
↓
API Gateway
↓
Flight Booking Service ↔ Flight Search Service (if needed)
- Booking Management: Create, view, update, or cancel bookings.
- Seat Allocation: Tracks seat availability and ensures atomic booking operations.
- Concurrency Control: Row-level locking prevents double-booking during high load.
- User Authentication: JWT-based authentication for secure access.
- Payment Simulation: Handles fake payments to simulate seat reservation scenarios.
- Service Resilience: Isolated microservice ensures system remains operational even if other services fail.
- Users can create a booking with selected flights and seats.
- Users can cancel or update their bookings.
- The system validates seat availability before confirming bookings.
- Payment flow (simulated) locks seats during transaction.
- Service communicates with Search Service to fetch flight information if required.
- Scalability: Service can handle concurrent booking requests during peak periods.
- Reliability: Microservice isolation ensures platform stability even under high search traffic.
- Performance: Efficient DB queries and connection pooling reduce latency.
- Security: JWT authentication secures endpoints; sensitive actions validated.
- Maintainability: Modular codebase with Sequelize ORM and Express middlewares.
Backend:
- Node.js – JavaScript runtime for server-side applications
- Express.js – Framework for building RESTful APIs
Database & ORM:
- MySQL – Relational database for bookings, users, and flights
- Sequelize ORM – ORM for clean and maintainable DB operations
Authentication & Security:
- JWT – Token-based authentication
- Row-level locking & Transactions – Prevents double-booking and ensures consistency
Architecture & Patterns:
- Microservices – Booking logic isolated from search for reliability
- API Gateway / Reverse Proxy – Routes requests to the correct service
- Concurrency & Atomic Operations – Guarantees booking integrity
Other Key Features:
- RESTful APIs for booking operations
- Seat locking mechanism during booking
- Real-time booking simulation for high concurrency scenarios
- Environment configuration with
.envfor DB, JWT secrets, and endpoints
| Endpoint | Method | Description |
|---|---|---|
/bookings |
POST | Create a new booking |
/bookings/:id |
GET | Retrieve booking details |
/bookings/:id |
PUT | Update existing booking |
/bookings/:id |
DELETE | Cancel a booking |
/payment/simulate |
POST | Simulate payment and seat lock |
(Include sample request/response in future if needed for documentation)
- Clone the repository:
git clone https://github.com/Bhupesh-aher/Flights-Booking-Service.git- Install dependencies:
cd Flights-Booking-Service
npm install- Configure environment variables:
Create a
.envfile and add:
DB_HOST=your_db_host
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_db_name
JWT_SECRET=your_jwt_secret
- Run database migrations with Sequelize:
npx sequelize-cli db:migrate- Start the server:
npm run dev- Implements row-level locking to prevent two users from booking the same seat simultaneously.
- Ensures that one service crashing doesn’t affect the overall platform, thanks to microservice isolation.
- Simulated payment system demonstrates how high-demand seat reservations are handled in real time.
- Integrate real payment gateways for live transactions
- Add rate limiting & caching for search and booking APIs
- Implement webhooks or message queues for async communication between services
- Add logging and monitoring for production readiness