Skip to content

maansi33/FlyFair

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlyFair – Flight Price Tracker

Overview

FlyFair is a modern flight price tracking application that helps users find the best flight deals and get notified when prices drop below their target. Built with Flask (Python) backend and a beautiful responsive frontend, it integrates with the Amadeus API for real-time flight data.

Features

  • Search Flights: Search for flights by origin, destination, and date
  • Price Tracking: Set target prices and get notified when flights drop
  • Email Alerts: Receive email notifications when prices meet your target
  • Modern UI: Beautiful, responsive design that works on all devices
  • Real-time Data: Live flight information from Amadeus API
  • Input Validation: Comprehensive form validation and error handling
  • Mobile Friendly: Fully responsive design for mobile and desktop

Project Structure

FlyFair/
├── backend/          # Python Flask backend
│   └── app.py       # Main Flask application
├── frontend/         # Frontend interface
│   └── index.html   # Single-page application
├── requirements.txt  # Python dependencies
├── .env.example     # Environment variables template
└── README.md        # Project documentation

Technologies Used

  • Backend: Python, Flask, Flask-CORS
  • Frontend: HTML5, CSS3, JavaScript (Vanilla)
  • API: Amadeus Flight Offers API
  • Email: SMTP (Gmail)
  • Environment: python-dotenv

Setup Instructions

Prerequisites

  • Python 3.7 or higher
  • Amadeus API credentials (free account available at Amadeus for Developers)
  • Gmail account (optional, for email alerts)

Installation

  1. Clone the Repository
git clone https://github.com/maansi33/FlyFair.git
cd FlyFair
  1. Create Virtual Environment (Recommended)
python -m venv venv

# On Windows
venv\Scripts\activate

# On macOS/Linux
source venv/bin/activate
  1. Install Dependencies
pip install -r requirements.txt
  1. Configure Environment Variables

    • Copy .env.example to .env:
    cp .env.example .env
    • Edit .env and add your credentials:
    AMADEUS_API_KEY=your_key_here
    AMADEUS_API_SECRET=your_secret_here
    GMAIL_EMAIL=your_email@gmail.com
    GMAIL_APP_PASSWORD=your_app_password
    

    Getting Amadeus API Credentials:

    1. Visit Amadeus for Developers
    2. Sign up for a free account
    3. Create a new app in the developer dashboard
    4. Copy your API Key and API Secret

    Setting up Gmail App Password (for email alerts):

    1. Enable 2-Step Verification on your Google Account
    2. Go to App Passwords
    3. Generate a new app password for "Mail"
    4. Use this password in .env file
  2. Run the Application

# From the project root directory
python backend/app.py

# Or from the backend directory
cd backend
python app.py

The application will start on http://localhost:5000 by default.

  1. Access the Application
    • Open your browser and navigate to: http://localhost:5000
    • The frontend will be automatically served by Flask
    • The app can be run from any directory - paths are configured automatically

Usage

  1. Search for Flights:

    • Enter origin airport code (3-letter IATA code, e.g., DEL, JFK)
    • Enter destination airport code (e.g., KTM, LAX)
    • Select departure date
    • Click "Search Flights"
  2. Set Price Alerts (Optional):

    • Enter your target price in USD
    • Provide your email address
    • If any flight matches or falls below your target price, you'll receive an email notification
  3. View Results:

    • Results are sorted by price (lowest first)
    • Each result shows airline, flight number, departure/arrival times, duration, stops, and price
    • Flights that meet your target price are highlighted

API Endpoints

GET /

  • Serves the main frontend interface

GET /check-price

  • Searches for flight offers

  • Query Parameters:

    • origin (required): 3-letter IATA airport code
    • destination (required): 3-letter IATA airport code
    • date (required): Departure date (YYYY-MM-DD)
    • targetPrice (optional): Target price in USD
    • email (optional): Email address for alerts
  • Response:

    {
      "flights": [...],
      "count": 10,
      "emails_sent": 2
    }

Error Handling

The application includes comprehensive error handling:

  • Input validation for all form fields
  • API error handling with user-friendly messages
  • Email delivery status logging
  • Graceful fallbacks for missing optional features

Improvements Made

Backend Enhancements:

  • Added comprehensive error handling and validation
  • Implemented token caching for Amadeus API (reduces API calls)
  • Fixed template path issue (uses static file serving)
  • Improved email sending logic (prevents duplicate emails)
  • Added proper logging
  • Better input validation and sanitization

Frontend Enhancements:

  • Modern, responsive UI with gradient design
  • Loading states and spinners
  • Real-time form validation
  • Better error messages and user feedback
  • Mobile-friendly responsive layout
  • Auto-uppercase for airport codes
  • Price alerts highlighted in results
  • Improved accessibility

Code Quality:

  • Updated requirements.txt with version pins
  • Added .env.example for easy setup
  • Comprehensive README documentation
  • Better code organization and structure
  • Fixed path handling - app can be run from any directory
  • Cross-platform compatibility improvements

Troubleshooting

"Failed to authenticate with Amadeus API"

  • Check that your AMADEUS_API_KEY and AMADEUS_API_SECRET are correct in .env
  • Ensure you're using test API credentials (production requires additional setup)

"Unable to connect to server"

  • Make sure the Flask backend is running
  • Check that port 5000 is not in use by another application

Email alerts not working

  • Verify Gmail credentials in .env
  • Ensure 2-Step Verification is enabled and you're using an App Password
  • Check server logs for email delivery errors

Future Improvements

  • User authentication and profiles
  • Save favorite flight searches
  • Price history tracking
  • Multiple date range searches
  • Integration with booking platforms
  • Push notifications (browser/phone)
  • Advanced filtering (airlines, stops, times)
  • Price prediction using historical data

Contributing

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

License

This project is open source and available under the MIT License.

Author

Maansi Sharma
GitHub: maansi33

Acknowledgments


Note: This application uses the Amadeus Test API. For production use, additional API configuration and authentication may be required.

About

Flight Tracker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors