Node.js + Express + PostgreSQL backend cho hệ thống đặt vé máy bay.
Register, login, OTP, refresh token, social auth, forgot/reset password, auto lock khi sai nhiều lần.
Tìm kiếm chuyến bay, xem chi tiết, multi-leg (one-way / round-trip / multi-city).
Tạo booking, xem booking, hủy booking, tự động expire giữ chỗ quá hạn.
Hỗ trợ PayOS, MoMo, PayPal, BANK_QR. Preview, tạo, confirm payment.
Quản lý flight, airport, airline, user, coupon, booking, thống kê.
1. POST /api/date-changes/bookings/:bookingCode/change-flight → gửi OTP, status = pending_otp
2. POST /api/date-changes/confirm → verify OTP, xử lý chênh lệch giá
3. Admin approve nếu chênh lệch >= 1M
priceDifference = (newFlight.base_price * số_vé) - booking.total_price
// Kết quả:
// priceDifference > 0 → khách trả thêm (auto: tạo payment)
// priceDifference = 0 → không thay đổi
// priceDifference < 0 → hoàn tiền (auto: refund)
// priceDifference có |value| < 1M → auto approveĐơn giản: mỗi flight join bảng airlines là có đủ thông tin.
-- Flight query luôn join airlines
SELECT f.*, al.code AS airline_code, al.name AS airline_name, al.logo_url ...
FROM flights f
JOIN airlines al ON al.id = f.airline_idFrontend nhận:
{
"airline": {
"code": "VN",
"name": "Vietnam Airlines",
"logo_url": "https://..."
}
}Xem src/config/ - mỗi feature có config riêng: auth.config.js, payment.config.js, refund.config.js.
Postman collection trong postman/ folder.
Document chi tiết các flows trong hệ thống: docs/diagrams/sequence/
| Diagram | Mô tả |
|---|---|
| 01-auto-refund.md | User request → Admin approve → Payment gateway → Complete |
| 02-date-change.md | Request → OTP → Payment → Approve → Release/Reserve seats |
| 03-flight-combo.md | Mixed search: direct, 1-stop, 2-stop + roundtrip |
| 04-flight-season.md | Season/Holiday/Override detection với caching |