# Product Requirements Document: Airlines Management System

## 1. Overview

The Airlines Management System is a lightweight web application designed to manage core airline operations including flight scheduling, aircraft management, passenger bookings, and crew assignments. The system provides a simplified interface for airline staff to efficiently manage flights, track bookings, and maintain operational data without the complexity of user authentication. This application serves as an internal tool for small to medium-sized airline operations teams.

## 2. User Roles

### Anonymous User (Default Role)
Since there is no login system, all users have the same access level with full permissions to:
- View, create, edit, and delete flights
- Manage aircraft inventory
- Create and manage passenger bookings
- Assign and manage crew members
- View reports and dashboards
- Configure airline settings

## 3. Core Entities

### Aircraft
Represents physical airplanes in the airline's fleet.
- **Description**: Stores information about each aircraft including model, capacity, and operational status.

### Flight
Represents scheduled flight operations.
- **Description**: Contains flight details including route, schedule, assigned aircraft, and operational status.

### Passenger
Represents customers who book flights.
- **Description**: Stores passenger personal information and contact details.

### Booking
Represents a reservation made by a passenger for a specific flight.
- **Description**: Links passengers to flights with booking details, seat assignments, and payment status.

### Crew Member
Represents airline staff who operate flights (pilots, flight attendants).
- **Description**: Stores crew member information, role, and certification details.

### Flight Assignment
Represents the assignment of crew members to specific flights.
- **Description**: Links crew members to flights with their assigned role for that flight.

### Airport
Represents airports that serve as origins and destinations.
- **Description**: Stores airport codes, names, locations, and timezone information.

### Booking Payment
Represents payment transactions for bookings.
- **Description**: Tracks payment amount, method, status, and transaction details.

## 4. Entity Relationships

### Aircraft ↔ Flight
- **Relationship**: One-to-Many
- **Description**: One aircraft can be assigned to multiple flights (at different times), but each flight is assigned to exactly one aircraft.

### Flight ↔ Airport
- **Relationship**: Many-to-One (Origin), Many-to-One (Destination)
- **Description**: Each flight has one origin airport and one destination airport. Each airport can serve many flights.

### Flight ↔ Booking
- **Relationship**: One-to-Many
- **Description**: One flight can have multiple bookings, but each booking is for exactly one flight.

### Passenger ↔ Booking
- **Relationship**: One-to-Many
- **Description**: One passenger can make multiple bookings, but each booking belongs to exactly one passenger.

### Booking ↔ Booking Payment
- **Relationship**: One-to-One
- **Description**: Each booking has exactly one payment record.

### Flight ↔ Flight Assignment
- **Relationship**: One-to-Many
- **Description**: One flight can have multiple crew assignments, but each assignment is for exactly one flight.

### Crew Member ↔ Flight Assignment
- **Relationship**: One-to-Many
- **Description**: One crew member can be assigned to multiple flights, but each assignment involves exactly one crew member.

## 5. Key Workflows

### Workflow 1: Flight Creation and Scheduling
1. User navigates to "Flights" section
2. User clicks "Create New Flight"
3. User selects origin airport from dropdown
4. User selects destination airport from dropdown
5. User enters departure date and time
6. User enters arrival date and time
7. User selects available aircraft from dropdown
8. User enters flight number
9. User sets base ticket price
10. User sets flight status (Scheduled/Active/Cancelled/Completed)
11. System validates that aircraft is not double-booked for the time slot
12. System saves flight and displays confirmation
13. Flight appears in flight list

### Workflow 2: Passenger Booking Process
1. User navigates to "Bookings" section
2. User clicks "Create New Booking"
3. User searches and selects an existing passenger OR creates a new passenger
4. If creating new passenger:
   - User enters passenger name, email, phone, passport number
   - System saves passenger
5. User selects a flight from available flights list
6. System displays available seats (total capacity minus existing bookings)
7. User enters seat number
8. User selects booking class (Economy/Business/First Class)
9. System calculates total price based on flight base price and class multiplier
10. User enters payment details (amount, method, status)
11. System validates seat availability
12. System creates booking and payment record
13. System displays booking confirmation with booking reference number

### Workflow 3: Crew Assignment to Flight
1. User navigates to "Flights" section
2. User selects a specific flight
3. User clicks "Manage Crew"
4. User clicks "Add Crew Member"
5. User selects crew member from dropdown
6. User selects role for this flight (Captain/First Officer/Flight Attendant)
7. System validates crew member is not assigned to overlapping flights
8. System saves flight assignment
9. Assignment appears in flight crew list
10. User can repeat to add multiple crew members

### Workflow 4: Flight Status Management
1. User views flight list or flight details
2. User clicks "Update Status" on a flight
3. User selects new status:
   - Scheduled → Active (flight is boarding/in progress)
   - Active → Completed (flight has landed)
   - Scheduled/Active → Cancelled (flight is cancelled)
   - Cancelled → Scheduled (reinstate flight)
4. If cancelling, system flags all associated bookings
5. System updates flight status
6. System displays confirmation

### Workflow 5: Aircraft Fleet Management
1. User navigates to "Aircraft" section
2. User clicks "Add Aircraft"
3. User enters aircraft registration number
4. User enters aircraft model/type
5. User enters manufacturer
6. User enters total seating capacity
7. User sets operational status (Active/Maintenance/Retired)
8. System validates unique registration number
9. System saves aircraft
10. Aircraft appears in fleet list and becomes available for flight assignment

## 6. Features & Requirements

### Module: Dashboard
**FR-DASH-001**: Display summary statistics
- Total flights (today, this week, this month)
- Total bookings count
- Total revenue from bookings
- Active aircraft count
- Total crew members

**FR-DASH-002**: Display upcoming flights list
- Show next 10 upcoming flights with departure time, route, and status
- Allow quick navigation to flight details

**FR-DASH-003**: Display recent bookings
- Show last 10 bookings with passenger name, flight, and booking date

**FR-DASH-004**: Display fleet status overview
- Show count of aircraft by status (Active/Maintenance/Retired)

### Module: Flight Management
**FR-FLT-001**: List all flights
- Display flights in a table with columns: Flight Number, Origin, Destination, Departure Time, Arrival Time, Aircraft, Status
- Support sorting by any column
- Support filtering by status, date range, origin, destination

**FR-FLT-002**: Create new flight
- Form with fields: Flight Number, Origin Airport, Destination Airport, Departure DateTime, Arrival DateTime, Aircraft, Base Price, Status
- Validate all required fields
- Validate departure time is before arrival time
- Validate aircraft availability for the time slot

**FR-FLT-003**: Edit existing flight
- Load flight details into editable form
- Allow modification of all fields except flight number
- Re-validate aircraft availability if aircraft or times changed

**FR-FLT-004**: Delete flight
- Show confirmation dialog
- Prevent deletion if flight has existing bookings
- If no bookings, delete flight and all crew assignments

**FR-FLT-005**: View flight details
- Display all flight information
- Show assigned crew members list
- Show bookings list with passenger names
- Show available seats count

**FR-FLT-006**: Manage flight crew
- Display current crew assignments for the flight
- Add new crew assignment (select crew member and role)
- Remove crew assignment
- Validate crew member availability (no overlapping flights)

### Module: Aircraft Management
**FR-AIR-001**: List all aircraft
- Display aircraft in a table with columns: Registration Number, Model, Manufacturer, Capacity, Status
- Support sorting and filtering by status

**FR-AIR-002**: Create new aircraft
- Form with fields: Registration Number, Model, Manufacturer, Capacity, Status
- Validate unique registration number
- Validate capacity is a positive integer

**FR-AIR-003**: Edit existing aircraft
- Load aircraft details into editable form
- Allow modification of all fields
- Validate unique registration number if changed

**FR-AIR-004**: Delete aircraft
- Show confirmation dialog
- Prevent deletion if aircraft is assigned to any future flights
- If no future flights, allow deletion

**FR-AIR-005**: View aircraft details
- Display all aircraft information
- Show list of upcoming flights assigned to this aircraft
- Show maintenance history (if status is/was Maintenance)

### Module: Booking Management
**FR-BKG-001**: List all bookings
- Display bookings in a table with columns: Booking Reference, Passenger Name, Flight Number, Route, Seat, Class, Price, Payment Status, Booking Date
- Support sorting and filtering by flight, passenger, payment status, date range

**FR-BKG-002**: Create new booking
- Select or create passenger
- Select flight from available flights
- Enter seat number
- Select booking class (Economy/Business/First Class)
- System calculates price based on flight base price and class multiplier
- Enter payment details (amount, method, status)
- Generate unique booking reference
- Validate seat availability

**FR-BKG-003**: Edit existing booking
- Allow modification of seat number, booking class
- Recalculate price if class changed
- Update payment amount if price changed
- Validate new seat availability

**FR-BKG-004**: Cancel booking
- Show confirmation dialog
- Mark booking as cancelled
- Update payment status to Refunded/Cancelled
- Free up the seat for the flight

**FR-BKG-005**: View booking details
- Display all booking information
- Show passenger details
- Show flight details
- Show payment information

### Module: Passenger Management
**FR-PSG-001**: List all passengers
- Display passengers in a table with columns: Name, Email, Phone, Passport Number, Total Bookings
- Support search by name, email, or passport number

**FR-PSG-002**: Create new passenger
- Form with fields: First Name, Last Name, Email, Phone, Passport Number, Date of Birth, Nationality
- Validate email format
- Validate unique passport number

**FR-PSG-003**: Edit existing passenger
- Load passenger details into editable form
- Allow modification of all fields
- Re-validate email and passport number uniqueness

**FR-PSG-004**: Delete passenger
- Show confirmation dialog
- Prevent deletion if passenger has any bookings
- If no bookings, allow deletion

**FR-PSG-005**: View passenger details
- Display all passenger information
- Show booking history with flight details
- Show total amount spent

### Module: Crew Management
**FR-CRW-001**: List all crew members
- Display crew members in a table with columns: Name, Role, License Number, Status, Total Flights
- Support filtering by role and status

**FR-CRW-002**: Create new crew member
- Form with fields: First Name, Last Name, Role (Pilot/Co-Pilot/Flight Attendant), License Number, Email, Phone, Status (Active/On Leave/Inactive)
- Validate unique license number
- Validate email format

**FR-CRW-003**: Edit existing crew member
- Load crew member details into editable form
- Allow modification of all fields
- Re-validate license number uniqueness

**FR-CRW-004**: Delete crew member
- Show confirmation dialog
- Prevent deletion if crew member is assigned to any future flights
- If no future flights, allow deletion

**FR-CRW-005**: View crew member details
- Display all crew member information
- Show upcoming flight assignments
- Show flight history

### Module: Airport Management
**FR-APT-001**: List all airports
- Display airports in a table with columns: Code, Name, City, Country, Timezone
- Support search by code, name, or city

**FR-APT-002**: Create new airport
- Form with fields: Airport Code (IATA), Name, City, Country, Timezone
- Validate unique airport code
- Validate code is 3 characters

**FR-APT-003**: Edit existing airport
- Load airport details into editable form
- Allow modification of all fields except code

**FR-APT-004**: Delete airport
- Show confirmation dialog
- Prevent deletion if airport is used in any flights
- If no flights, allow deletion

**FR-APT-005**: View airport details
- Display all airport information
- Show flights departing from this airport
- Show flights arriving at this airport

### Module: Reports
**FR-RPT-001**: Flight occupancy report
- Show list of flights with booking count vs capacity
- Calculate occupancy percentage
- Filter by date range
- Export to CSV

**FR-RPT-002**: Revenue report
- Show total revenue by date range
- Break down by booking class
- Show average ticket price
- Export to CSV

**FR-RPT-003**: Crew utilization report
- Show crew members with their flight assignment count
- Filter by date range
- Show hours flown (calculated from flight durations)

**FR-RPT-004**: Fleet utilization report
- Show aircraft with their flight count
- Calculate utilization percentage
- Show maintenance downtime

## 7. Business Rules

### Flight Rules
**BR-FLT-001**: A flight's departure time must be before its arrival time.

**BR-FLT-002**: An aircraft cannot be assigned to overlapping flights (considering departure and arrival times plus 2-hour buffer for turnaround).

**BR-FLT-003**: Flight number must be unique for flights on the same date.

**BR-FLT-004**: A flight cannot be deleted if it has any bookings.

**BR-FLT-005**: Only flights with status "Scheduled" can be edited. Active, Completed, or Cancelled flights are read-only.

**BR-FLT-006**: Minimum flight duration must be 30 minutes.

**BR-FLT-007**: Origin and destination airports must be different.

### Booking Rules
**BR-BKG-001**: Total bookings for a flight cannot exceed the aircraft's seating capacity.

**BR-BKG-002**: Seat numbers must be unique within a flight.

**BR-BKG-003**: Bookings can only be made for flights with status "Scheduled".

**BR-BKG-004**: Booking reference must be unique across all bookings.

**BR-BKG-005**: Booking class price multipliers:
- Economy: 1.0x base price
- Business: 2.5x base price
- First Class: 4.0x base price

**BR-BKG-006**: Payment amount must match the calculated booking price.

**BR-BKG-007**: Bookings cannot be created for flights in the past.

### Aircraft Rules
**BR-AIR-001**: Aircraft registration number must be unique.

**BR-AIR-002**: Seating capacity must be between 50 and 850.

**BR-AIR-003**: Aircraft with status "Maintenance" or "Retired" cannot be assigned to new flights.

**BR-AIR-004**: An aircraft cannot be deleted if it's assigned to any future flights.

### Passenger Rules
**BR-PSG-001**: Passport number must be unique across all passengers.

**BR-PSG-002**: Email must be unique across all passengers.

**BR-PSG-003**: Passenger must be at least 18 years old to make a booking (calculated from date of birth).

**BR-PSG-004**: A passenger cannot be deleted if they have any bookings.

### Crew Rules
**BR-CRW-001**: License number must be unique across all crew members.

**BR-CRW-002**: A crew member cannot be assigned to overlapping flights (considering flight times plus 1-hour buffer before and after).

**BR-CRW-003**: Each flight must have at least one pilot (Captain or First Officer) assigned.

**BR-CRW-004**: Each flight must have at least one flight attendant assigned.

**BR-CRW-005**: Crew members with status "On Leave" or "Inactive" cannot be assigned to new flights.

**BR-CRW-006**: A crew member cannot be deleted if assigned to any future flights.

### Airport Rules
**BR-APT-001**: Airport code must be exactly 3 uppercase letters (IATA format).

**BR-APT-002**: Airport code must be unique.

**BR-APT-003**: An airport cannot be deleted if it's used in any flights.

### Payment Rules
**BR-PAY-001**: Payment status must be one of: Pending, Completed, Failed, Refunded, Cancelled.

**BR-PAY-002**: Payment method must be one of: Credit Card, Debit Card, Cash, Bank Transfer.

**BR-PAY-003**: Payment amount must be greater than zero.

## 8. Non-Functional Requirements

### Performance
**NFR-PERF-001**: Page load time should not exceed 2 seconds under normal load.

**NFR-PERF-002**: Database queries should return results within 500ms for standard operations.

**NFR-PERF-003**: The system should support up to 100 concurrent users without performance degradation.

**NFR-PERF-004**: List views should implement pagination with maximum 50 records per page.

**NFR-PERF-005**: Search and filter operations should return results within 1 second.

### Scalability
**NFR-SCAL-001**: The system should handle up to 10,000 flights per year.

**NFR-SCAL-002**: The system should handle up to 100,000 bookings per year.

**NFR-SCAL-003**: The system should support up to 50 aircraft in the fleet.

**NFR-SCAL-004**: The system should support up to 500 crew members.

**NFR-SCAL-005**: Database should be designed to accommodate 5 years of historical data.

### Usability
**NFR-USE-001**: The interface should be responsive and work on desktop, tablet, and mobile devices.

**NFR-USE-002**: All forms should provide clear validation messages for errors.

**NFR-USE-003**: Critical actions (delete, cancel) should require confirmation dialogs.

**NFR-USE-004**: The system should provide breadcrumb navigation for easy orientation.

**NFR-USE-005**: All date/time inputs should use user-friendly date pickers.

**NFR-USE-006**: The interface should use consistent color coding for statuses (e.g., green for active, red for cancelled).

### Reliability
**NFR-REL-001**: The system should have 99% uptime during business hours.

**NFR-REL-002**: All data modifications should be transactional to prevent data corruption.

**NFR-REL-003**: The system should implement automatic database backups daily.

**NFR-REL-004**: Failed operations should provide clear error messages and not leave data in inconsistent state.

### Security
**NFR-SEC-001**: All data transmission should use HTTPS encryption.

**NFR-SEC-002**: Input validation should be performed on both client and server side to prevent injection attacks.

**NFR-SEC-003**: Sensitive data (passport numbers, payment information) should be stored encrypted.

**NFR-SEC-004**: The system should implement CORS policies to restrict API access to authorized domains.

**NFR-SEC-005**: Database credentials and API keys should be stored in environment variables, not in code.

### Maintainability
**NFR-MAINT-001**: Code should follow consistent naming conventions and style guides.

**NFR-MAINT-002**: The system should use a modular architecture with clear separation of concerns.

**NFR-MAINT-003**: Database schema should include proper indexes for frequently queried fields.

**NFR-MAINT-004**: The system should log all errors with sufficient detail for debugging.

**NFR-MAINT-005**: API endpoints should follow RESTful conventions.

### Data Integrity
**NFR-DATA-001**: All foreign key relationships should be enforced at the database level.

**NFR-DATA-002**: Deletion of records should cascade appropriately or be prevented if dependencies exist.

**NFR-DATA-003**: All timestamps should be stored in UTC and converted to local timezone for display.

**NFR-DATA-004**: Numeric fields (prices, capacities) should use appropriate data types to prevent overflow.

**NFR-DATA-005**: All required fields should be enforced with NOT NULL constraints at database level.

### Browser Compatibility
**NFR-BROW-001**: The system should support the latest versions of Chrome, Firefox, Safari, and Edge.

**NFR-BROW-002**: The system should gracefully degrade features for older browsers where possible.

### Accessibility
**NFR-ACC-001**: The interface should follow WCAG 2.1 Level AA guidelines where feasible.

**NFR-ACC-002**: All interactive elements should be keyboard accessible.

**NFR-ACC-003**: Color should not be the only means of conveying information.

---

**Document Version**: 1.0  
**Last Updated**: 2025  
**Domain**: Travels and Tours  
**Domain URL**: https://harsh.dev.dalfin.ai