Skip to content

A comprehensive system for real-time flight status updates, designed to notify users about tagged flights through email and SMS. Built with FastAPI, MongoDB, RabbitMQ, and React.

Notifications You must be signed in to change notification settings

sumionochi/Flight-Status-And-Notification

Repository files navigation

Real-Time Flight Status Tracking System


Video Demo -

Flight.Status.project.mp4

A comprehensive system for real-time flight status updates, designed to notify users about tagged flights through email and SMS. Built with FastAPI, MongoDB, RabbitMQ, and React.

Table of Contents

Introduction

The Real-Time Flight Status Tracking System provides users with real-time updates on flight statuses. Users can tag specific flights they want to monitor, and receive updates through email and SMS.

image

Features

  • Real-time flight status updates
  • Notifications via email and SMS for tagged flights
  • Search for flights by departing, arriving, flight number, and departure date
  • User-friendly interface for tagging and monitoring flights

Screenshot 2024-07-31 005948 Screenshot 2024-07-31 010043 Screenshot 2024-07-31 010049

Architecture

  • Backend: FastAPI
  • Database: MongoDB
  • Message Queue: RabbitMQ
  • Frontend: React, Typescript

Installation

Prerequisites

  • Python 3.x
  • Node.js
  • MongoDB
  • RabbitMQ

Backend Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/flight-status-tracker.git
    cd flight-status-tracker/backend
  2. Install dependencies:

    fastapi
    pydantic
    uvicorn
    pymongo
    python-dotenv
    requests
    twilio
    pika
    

Create and Activate Virtual Environment

```sh
python -m venv venv
source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
```
  1. Create a .env file with the following variables:

    MONGODB_CONNECTION_STRING=your_mongodb_connection_string
    MAILGUN_API_KEY=your_mailgun_api_key
    MAILGUN_DOMAIN=your_mailgun_domain
    NOTIFICATION_TO_EMAIL=your_email
    TWILIO_ACCOUNT_SID=your_twilio_account_sid
    TWILIO_AUTH_TOKEN=your_twilio_auth_token
    TWILIO_PHONE_NUMBER=your_twilio_phone_number
    NOTIFICATION_TO_PHONE=your_phone_number
  2. Run the FastAPI server:

    uvicorn main:app --reload

Frontend Setup

  1. Navigate to the frontend directory:

    cd ../frontend
  2. Install dependencies:

    npm install
  3. Start the React development server:

    npm start

Usage

  1. Visit the frontend URL (usually http://localhost:3000).
  2. Use the search form to find flights.
  3. Tag flights to monitor them.
  4. Receive real-time updates for tagged flights.

API Endpoints

Get Flights

  • URL: /api/flights
  • Method: GET
  • Query Parameters: departing, arriving, flightNo, departureDate

Update Flight

  • URL: /api/flights/update
  • Method: POST
  • Body: JSON containing flight details

Code Snippets

Backend (FastAPI)

@app.get("/api/flights")
async def get_flights(departing: str, arriving: str, flightNo: str, departureDate: str):
    query = { ... }
    flights = list(flights_collection.find(query, {"_id": 0}))
    return flights

def send_email_notification(flight):
    response = requests.post(
        f"https://api.mailgun.net/v3/{MAILGUN_DOMAIN}/messages",
        auth=("api", MAILGUN_API_KEY),
        data={"from": f"Flight Notifications <mailgun@{MAILGUN_DOMAIN}>",
              "to": NOTIFICATION_TO_EMAIL,
              "subject": f'Flight {flight["flightNumber"]} Status Update',
              "text": f'Flight {flight["flightNumber"]} status changed to {flight["status"]}. Gate: {flight["gate"]}, Departure Time: {flight["departureTime"]}, Arrival Time: {flight["arrivalTime"]}.'})

Screenshot 2024-07-31 010105

Frontend (React)

const handleSubmit = (e) => {
  e.preventDefault();
  fetchFlights(formData);
};

const tagFlight = (flight) => {
  setTaggedFlights([...taggedFlights, flight]);
};

Screenshot 2024-07-31 010056 Screenshot 2024-07-31 010137

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss improvements or features.

About

A comprehensive system for real-time flight status updates, designed to notify users about tagged flights through email and SMS. Built with FastAPI, MongoDB, RabbitMQ, and React.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published