The Flight Booking App is a web application that allows users to search for flights, book tickets, and manage their bookings. The application is built using React for the frontend and FastAPI for the backend, providing a seamless experience for users.
The project is organized into two main directories: frontend
and backend
.
flight-booking-app/
├── backend/
│ ├── main.py
│ ├── models.py
│ ├── routes/
│ │ ├── flight_routes.py
│ │ └── user_routes.py
│ ├── test_data.py
│ ├── requirements.txt # Add this file if needed
│ └── README.md # Consolidated README for backend
├── frontend/
│ ├── public/
│ │ └── index.html
│ ├── src/
│ │ ├── components/
│ │ │ ├── Header/
│ │ │ │ ├── Header.js
│ │ │ │ └── Header.css
│ │ │ ├── Footer/
│ │ │ │ ├── Footer.js
│ │ │ │ └── Footer.css
│ │ │ ├── FlightSearch/
│ │ │ │ ├── FlightSearch.js
│ │ │ │ └── FlightSearch.css
│ │ │ ├── FlightResults/
│ │ │ │ ├── FlightResults.js
│ │ │ │ └── FlightResults.css
│ │ │ ├── BookingForm/
│ │ │ │ ├── BookingForm.js
│ │ │ │ └── BookingForm.css
│ │ │ └── Confirmation/
│ │ │ ├── Confirmation.js
│ │ │ └── Confirmation.css
│ │ ├── pages/
│ │ │ ├── Home/
│ │ │ │ ├── Home.js
│ │ │ │ └── Home.css
│ │ │ ├── SearchResults/
│ │ │ │ ├── SearchResults.js
│ │ │ │ └── SearchResults.css
│ │ │ ├── Booking/
│ │ │ │ ├── Booking.js
│ │ │ │ └── Booking.css
│ │ │ └── Confirmation/
│ │ │ ├── Confirmation.js
│ │ │ └── Confirmation.css
│ │ ├── hooks/
│ │ │ ├── useFetchFlights.js
│ │ │ ├── useBookingForm.js
│ │ │ └── useAuth.js
│ │ ├── utils/
│ │ │ ├── api.js
│ │ │ ├── helpers.js
│ │ │ └── constants.js
│ │ ├── App.js
│ │ ├── index.js
│ │ └── styles/
│ │ └── global.css
└── README.md # Main README for the entire project.
- Header Component: Displays the app title and navigation links.
- Footer Component: Contains copyright information and links.
- FlightSearch Component: Allows users to input search criteria for flights.
- FlightResults Component: Displays the list of available flights based on the search criteria.
- BookingForm Component: Collects user information for booking a flight.
- Confirmation Component: Shows booking confirmation details.
- Home Page: The landing page of the app.
- SearchResults Page: Displays the results of flight searches.
- Booking Page: Manages the booking process.
- Confirmation Page: Displays booking confirmation.
- main.py: Entry point for the FastAPI backend, initializes the app and includes middleware, CORS settings, and routes.
- models.py: Defines data models for flights and users using Pydantic for data validation.
- flight_routes.py: Contains API endpoints for searching flights, retrieving flight details, and booking flights, utilizing fake data from
test_data.py
. - user_routes.py: Contains API endpoints for user registration and login, utilizing fake data from
test_data.py
. - test_data.py: Contains fake test data for flights and users to simulate a database.
- useFetchFlights: Custom hook for fetching flight data from the backend API, managing loading and error states.
- useBookingForm: Custom hook for managing the state of the booking form, including validation and submission logic.
- useAuth: Custom hook for handling user authentication, including login and registration logic.
- api.js: Functions for making API calls to the backend, handling requests and responses.
- helpers.js: Helper functions that can be reused across components, such as formatting dates or validating input.
- constants.js: Constant values used throughout the application, such as API endpoints or default values.
To get started with the Flight Booking App, follow these steps:
- Clone the repository:
git clone https://github.com/yourusername/flight-booking-app.git cd flight-booking-app
- Set up the backend:
- Navigate to the
backend
directory and install the required dependencies:cd backend pip install -r requirements.txt
- Run the FastAPI server:
uvicorn main:app --reload
- Navigate to the
- Set up the frontend:
- Navigate to the
frontend
directory and install the required dependencies:cd frontend npm install
- Start the React app:
npm start
- Navigate to the
- Open your browser and go to
http://localhost:3000
to view the app.
Contributions are welcome! Please open an issue or submit a pull request if you have suggestions or improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the FastAPI and React communities for their amazing frameworks and resources.