How azeir/flight-booking-tracker works
1. Overall shape
- This is a classic MERN split into a React frontend and an Express/MongoDB backend.
- The main architectural boundary is: UI and client state live in frontend/, while API, auth, business rules, and persistence live in backend/.
2. Frontend subsystem
- The React app is organized by pages (Login, Register, FlightCatalog, BookingRecords, Profile, SeatSelection, MockPayment) plus reusable components (Navbar, booking cards, SeatSelectionModal).
- context/AuthContext.js suggests app-wide authentication state is centralized there, likely controlling login status and user identity across pages.
- axiosConfig.jsx is the main client-side API boundary, likely where the app sets the backend base URL and attaches auth headers.
3. User-facing flows
- The UX is centered on flight booking management: users log in/register, browse flights, select seats, create or update bookings, and review booking records.
- MockPayment.jsx implies payment is simulated in the UI rather than integrated with a real provider, so the booking flow is mostly internal to the app.
- bookingHelpers.js suggests some client-side transformation or status logic around bookings before rendering.
4. Backend API layer
- The backend is structured as routes → controllers → facades/models.
- Routes are split by domain: authRoutes.js, bookingRecordRoutes.js, and flightRoutes.js.
- Controllers (authController, bookingRecordController, flightRoutesController) handle request/response concerns, while facades encapsulate multi-step booking operations.
5. Authentication and access control
- authController.js, authMiddleware.js, and the User model indicate JWT-style authenticated sessions or token-based authorization.
- Protected routes likely depend on authMiddleware to verify the user before allowing booking or profile actions.
- The README’s sample admin credentials and the presence of userFactory.js suggest there is a seeded/admin-oriented identity path for testing or bootstrapping.
6. Booking domain logic
- Booking management is the core business subsystem, backed by BookingRecords and supported by bookingCreateFacade.js and bookingUpdateFacade.js.
- The facades imply booking creation/update is not a single database write; it likely coordinates validation, seat assignment, and persistence updates.
- bookingFetchTemplate.js and baseController.js suggest reusable query/response patterns for returning booking data consistently.
7. Flight catalog / search subsystem
- AviationDatas.js and flightRoutesController.js indicate a separate data source for flight catalog or flight-search information apart from user bookings.
- FlightCatalog.jsx on the frontend likely consumes these flight endpoints to display available flights before a booking is made.
- The README’s note about flight number format validation (QF123) suggests the same validation rule is enforced on both client and server.
8. Persistence layer
- MongoDB is the sole database layer, configured through backend/config/db.js.
- There are three key collections/models: User, BookingRecords, and AviationDatas.
- This separation implies the data model is split between identity, booking transactions, and flight reference/catalog data.
9. Cross-cutting response and middleware
- responseDecorator.js indicates a standardized API response shape or error wrapping layer.
- baseController.js likely provides shared controller behavior such as common success/error handling.
- These shared pieces reduce duplication across auth, booking, and flight endpoints.
10. Testing boundaries
- Backend tests cover the main business paths: Authentication.test.js, Booking.test.js, and FlightSearch.test.js.
- The frontend has a basic App.test.js, so most meaningful verification is concentrated at the API/domain level.
- This suggests the repository treats backend behavior as the primary source of correctness.
11. Deployment and runtime
- The README shows deployment is operationally important: AWS EC2 + PM2 + Nginx + GitHub Actions self-hosted runner.
- .github/workflows/ci.yml and domain-update.yml indicate automated build/deploy and post-deploy domain/config updates.
- The system likely runs as a Node service behind Nginx on EC2, with PM2 keeping the backend process alive.
12. How data moves through the system
- A typical request starts in the React UI, goes through axiosConfig to an Express route, hits middleware for auth/formatting, then a controller/facade, then MongoDB.
- Results return through the same path and are rendered by page-level React components, often with auth state coming from AuthContext.
- The clearest architecture diagram would show three domain pipelines: authentication, flight search/catalog, and booking CRUD.
Main entry points: App.js App Shell · bookingRecordRoutes.js Booking Routes · authRoutes.js Auth Routes · bookingRecordController.js Booking Controller
Components 33
Frontend
React UI, client state, and API access
- App Shell · Root React application and routing entry
frontend/src/App.js - Auth State · Centralized login and user identity state
frontend/src/context/AuthContext.js - API Client · Frontend HTTP boundary and auth header setup
frontend/src/axiosConfig.jsx - Navbar · Top-level navigation and session-aware controls
frontend/src/components/Navbar.jsx - Login · User sign-in screen
frontend/src/pages/Login.jsx - Register · User registration screen
frontend/src/pages/Register.jsx - Flight Catalog · Browse and search available flights
frontend/src/pages/FlightCatalog.jsx - Seat Selection · Seat choice and booking step
frontend/src/pages/SeatSelection.jsx - Seat Modal · Seat selection dialog component
frontend/src/components/SeatSelectionModal.jsx - Mock Payment · Simulated payment step in booking flow
frontend/src/pages/MockPayment.jsx - Booking Records · User booking history and management view
frontend/src/pages/BookingRecords.jsx - Profile · User account and profile view
frontend/src/pages/Profile.jsx - Booking Helpers · Shared booking formatting and status logic
frontend/src/utils/bookingHelpers.js
Backend
Express API, domain logic, and persistence
- Server · Node server bootstrap and route mounting
backend/server.js - Auth Routes · Authentication endpoints
backend/routes/authRoutes.js - Booking Routes · Booking record endpoints
backend/routes/bookingRecordRoutes.js - Flight Routes · Flight catalog and search endpoints
backend/routes/flightRoutes.js - Auth Controller · Login and registration request handling
backend/controllers/authController.js - Booking Controller · Booking record request handling
backend/controllers/bookingRecordController.js - Flight Controller · Flight search and catalog request handling
backend/controllers/flightRoutesController.js - Create Facade · Multi-step booking creation workflow
backend/facades/bookingCreateFacade.js - Update Facade · Multi-step booking update workflow
backend/facades/bookingUpdateFacade.js - Auth Middleware · Token verification and route protection
backend/middleware/authMiddleware.js - Response Decorator · Standardized response and error wrapping
backend/middleware/responseDecorator.js - Base Controller · Common controller behavior and response flow
backend/controllers/baseController.js - Fetch Template · Reusable booking fetch/query structure
backend/controllers/bookingFetchTemplate.js - Mongo DB · MongoDB connection setup
backend/config/db.js - User · Identity and authentication data
backend/models/User.js - Booking Records · Booking transaction records
backend/models/BookingRecords.js - Aviation Data · Flight reference and catalog data
backend/models/AviationDatas.js
Ops
Deployment and automation
- CI Workflow · Build and test pipeline
.github/workflows/ci.yml - Domain Update · Post-deploy domain and config update workflow
.github/workflows/domain-update.yml - Deployment · AWS EC2, PM2, Nginx, and self-hosted runner setup
README.md
Connections 48
- App Shell → Navbar: renders · App shell includes shared navigation
- App Shell → Login: routes · App routes to login screen
- App Shell → Register: routes · App routes to registration screen
- App Shell → Flight Catalog: routes · App routes to flight browsing
- App Shell → Seat Selection: routes · App routes to seat selection
- App Shell → Booking Records: routes · App routes to booking history
- App Shell → Profile: routes · App routes to profile screen
- Auth State → Navbar: feeds · Auth state drives navigation UI
- Auth State → App Shell: wraps · App is wrapped by auth provider
- API Client → Auth Routes: calls · Client hits auth endpoints
- API Client → Booking Routes: calls · Client hits booking endpoints
- API Client → Flight Routes: calls · Client hits flight endpoints
- Login → Auth Routes: uses · Login submits credentials to backend
- Register → Auth Routes: uses · Registration submits user data to backend
- Flight Catalog → Flight Routes: queries · Flight catalog consumes search API
- Seat Selection → Seat Modal: opens · Seat page uses modal for seat choice
- Seat Selection → Booking Routes: creates · Seat selection leads to booking creation
- Mock Payment → Booking Routes: confirms · Mock payment continues booking flow
- Booking Records → Booking Helpers: formats · Booking page uses shared client booking logic
- Booking Records → Booking Routes: loads · Booking history is fetched from backend
- Profile → Auth Routes: reads · Profile relies on authenticated user data
- Server → Auth Routes: mounts · Server mounts auth routes
- Server → Booking Routes: mounts · Server mounts booking routes
- Server → Flight Routes: mounts · Server mounts flight routes
- Auth Routes → Auth Controller: dispatches · Auth route handlers forward to controller
- Booking Routes → Auth Middleware: protects · Booking routes require auth middleware
- Booking Routes → Booking Controller: dispatches · Booking route handlers forward to controller
- Flight Routes → Flight Controller: dispatches · Flight route handlers forward to controller
- Auth Controller → User: uses · Auth reads and writes user records
- Auth Controller → Response Decorator: formats · Auth responses use shared wrapper
- Booking Controller → Create Facade: creates · Booking creation delegates to facade
- Booking Controller → Update Facade: updates · Booking updates delegate to facade
- Booking Controller → Fetch Template: reads · Booking retrieval uses fetch template
- Booking Controller → Base Controller: extends · Booking controller shares base behavior
- Flight Controller → Aviation Data: reads · Flight API queries aviation data
- Flight Controller → Response Decorator: formats · Flight responses use shared wrapper
- Create Facade → Booking Records: persists · Create flow writes booking records
- Create Facade → Aviation Data: checks · Create flow validates flight data and seats
- Update Facade → Booking Records: persists · Update flow modifies booking records
- Update Facade → Aviation Data: checks · Update flow validates seat availability
- Auth Middleware → User: verifies · Auth middleware resolves user identity
- Mongo DB → User: connects · Mongo connection backs user model
- Mongo DB → Booking Records: connects · Mongo connection backs booking model
- Mongo DB → Aviation Data: connects · Mongo connection backs flight model
- CI Workflow → Server: tests · CI exercises backend build and tests
- CI Workflow → App Shell: tests · CI exercises frontend build and tests
- Domain Update → Deployment: implements · Workflow supports documented deployment flow
- Domain Update → Server: deploys · Automation updates production service