Skip to content

AprajitSarkar/google-flights-clon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Google Flights Clone ✈️

A modern, responsive flight search application built with React that mimics the Google Flights interface. Search for flights, view results in multiple formats, and explore destination information.

React License Status

🌟 Features

Core Functionality

  • Smart Airport Search: Real-time airport search with autocomplete
  • Flexible Search Options: Round-trip and one-way flight searches
  • Multiple View Modes: Toggle between Google Flights-style view and traditional list view
  • Responsive Design: Works seamlessly on desktop, tablet, and mobile devices

Search Features

  • πŸ” Intelligent Airport Autocomplete: Type-ahead search with airport names, cities, and IATA codes
  • πŸ“… Date Selection: Interactive date pickers for departure and return dates
  • πŸ‘₯ Passenger Options: Select number of passengers (1-9)
  • πŸ’Ί Cabin Class Selection: Economy, Premium Economy, Business, or First class
  • πŸ”„ Quick Airport Swap: One-click swap between origin and destination

Display Options

  • Google Flights View: Mimics the official Google Flights interface with flights and destination info
  • List View: Traditional flight results display with sorting and filtering
  • Flight Details: Airline information, duration, stops, and pricing

Data Handling

  • API Integration: Real-time data from Sky Scrapper API
  • Fallback System: Mock data ensures functionality even when API is unavailable
  • Error Handling: Graceful error states with user-friendly messages

πŸš€ Quick Start

Prerequisites

  • Node.js 14+ and npm installed on your machine
  • A modern web browser (Chrome, Firefox, Safari, Edge)

Installation

  1. Clone the repository
git clone https://github.com/AprajitSarkar/google-flights-clon.git
cd google-flights-clon
  1. Install dependencies
npm install
  1. Set up environment variables (optional) Create a .env file in the root directory:
REACT_APP_RAPIDAPI_KEY=your_api_key_here
REACT_APP_RAPIDAPI_HOST=sky-scrapper.p.rapidapi.com
  1. Start the development server
npm start

The application will open automatically at http://localhost:3000

🎯 How to Use

Searching for Flights

  1. Enter Origin:

    • Type in the "From" field
    • Select an airport from the dropdown suggestions
    • Suggestions show airport names, IATA codes, and cities
  2. Enter Destination:

    • Type in the "To" field
    • Select your destination airport
    • Use the swap button (⇄) to quickly exchange origin and destination
  3. Select Dates:

    • Click on the departure date field
    • Choose your travel date from the calendar
    • For round trips, select a return date
  4. Configure Options:

    • Click the passenger/class button
    • Adjust number of passengers
    • Select your preferred cabin class
  5. Search:

    • Click "Search flights" button
    • View results in either Google or List view
    • Toggle between views using the switch button

Viewing Results

Google View displays:

  • Flight options with airline and duration
  • Destination information and imagery
  • Weather information for the destination

List View offers:

  • Sortable results (by price, duration, departure time)
  • Filter by number of stops
  • Detailed flight information cards

πŸ› οΈ Technology Stack

Frontend

  • React 18.2.0 - UI framework
  • React Router - Navigation
  • Axios - HTTP client for API calls
  • Lucide React - Modern icon library
  • React DatePicker - Date selection component

Styling

  • CSS3 - Custom styling
  • Responsive Design - Mobile-first approach
  • Google Fonts - Typography

Development Tools

  • Create React App - Build tooling
  • ESLint - Code linting
  • npm - Package management

πŸ“ Project Structure

google-flights-clone/
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ index.html
β”‚   └── manifest.json
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ AirportSearch.js      # Airport search autocomplete
β”‚   β”‚   β”œβ”€β”€ SearchForm.js         # Main search form
β”‚   β”‚   β”œβ”€β”€ FlightResults.js      # List view results
β”‚   β”‚   β”œβ”€β”€ FlightCard.js         # Individual flight card
β”‚   β”‚   └── GoogleFlightsDisplay.js # Google-style view
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ mockAirports.js       # Fallback airport data
β”‚   β”‚   └── mockFlights.js        # Fallback flight data
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── flightService.js      # API integration
β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   β”œβ”€β”€ AirportSearch.css
β”‚   β”‚   β”œβ”€β”€ SearchForm.css
β”‚   β”‚   β”œβ”€β”€ FlightResults.css
β”‚   β”‚   β”œβ”€β”€ FlightCard.css
β”‚   β”‚   └── GoogleFlightsDisplay.css
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── helpers.js            # Utility functions
β”‚   β”œβ”€β”€ App.js                    # Main app component
β”‚   β”œβ”€β”€ App.css                   # App styles
β”‚   └── index.js                  # Entry point
β”œβ”€β”€ package.json
└── README.md

πŸ”§ Configuration

API Configuration

The app uses the Sky Scrapper API from RapidAPI. To use your own API key:

  1. Sign up at RapidAPI
  2. Subscribe to the Sky Scrapper API
  3. Add your credentials to .env file

Mock Data

The application includes comprehensive mock data for:

  • Major airports worldwide
  • Sample flight results
  • Testing without API access

πŸ“ Available Scripts

# Start development server
npm start

# Build for production
npm run build

# Run tests
npm test

# Eject from Create React App (irreversible)
npm run eject

πŸ› Troubleshooting

Common Issues

Airport search not showing results:

  • Check your internet connection
  • Verify API key is configured correctly
  • The app will automatically use mock data if API fails

Flights not updating on new search:

  • The app now properly clears previous results
  • Each search triggers a fresh API call
  • Loading states are shown during data fetching

Styling issues:

  • Clear browser cache
  • Ensure all CSS files are properly imported
  • Check browser console for errors

🚒 Deployment

Deploy to GitHub Pages

  1. Install gh-pages:
npm install --save-dev gh-pages
  1. Add to package.json:
"homepage": "https://AprajitSarkar.github.io/google-flights-clon",
"scripts": {
  "predeploy": "npm run build",
  "deploy": "gh-pages -d build"
}
  1. Deploy:
npm run deploy

Deploy to Netlify

  1. Build the project:
npm run build
  1. Drag the build folder to Netlify

Deploy to Vercel

  1. Install Vercel CLI:
npm i -g vercel
  1. Deploy:
vercel

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘ Acknowledgments

  • Design inspired by Google Flights
  • Airport data from Sky Scrapper API
  • Icons from Lucide React
  • React community for excellent documentation

πŸ“§ Contact

Aprajit Sarkar


⭐ Star this repository if you find it helpful!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors