A comprehensive platform for accessing, analyzing, and visualizing flight delay data. This project includes both a command-line interface and a RESTful API for querying flight information, as well as powerful visualization tools to help identify patterns in flight delays.
- Command-line Interface: Query flight data interactively
- RESTful API: Access flight data through HTTP requests
- Data Visualization: Generate charts, graphs, and maps showing flight delay patterns:
- Bar charts of delayed flights by airline
- Percentage analysis of delays by airline and hour
- Interactive maps showing delayed routes
- Heatmaps of delay patterns
- Route maps with color-coded delay percentages
- Comprehensive Querying: Search by flight ID, date, airline, airport, and more
- Statistical Analysis: Analyze delay patterns across airlines, times, and routes
- Interactive Visualization Menu: Choose from multiple visualization options
sky-sql/
├── data/
│ └── flights.sqlite3 # SQLite database with flight data
├── tests/
│ ├── test_api.py # API tests
│ └── test_data.py # Data layer tests
├── data.py # Data access layer (SQLite database connector)
├── main.py # Command-line interface application
├── api.py # Flask REST API
├── visualization.py # Data visualization utilities
├── requirements.txt # Project dependencies
├── setup.py # Package setup file
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── license # License file
├── CONTRIBUTING.md # Contributing guidelines
└── README.md # This file
- Clone the repository:
git clone https://github.com/yourusername/sky-sql.git
cd sky-sql- Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt- Ensure the
flights.sqlite3database file is in thedata/directory. If not, create the directory and place the file there:
mkdir -p data
# Copy your flights.sqlite3 file to the data directory- Alternatively, you can use Docker to run the application:
docker-compose upRun the command-line interface:
python main.pyThis will present a menu where you can:
- Show flight by ID
- Show flights by date
- Delayed flights by airline
- Delayed flights by origin airport
- Top 5 delayed flights by date
- Generate visualizations
- Exit
The visualization menu offers several options:
- Number of delayed flights by airline
- Percentage of delayed flights by airline
- Percentage of delayed flights by hour
- Percentage of delayed flights per route on a Map (Origin <-> Destination, both directions average)
- Heatmap of delayed flights by route
- Delayed flights on a map
- Generate all visualizations
Start the API server:
python api.pyThe API will be available at http://localhost:5000/. Available endpoints:
GET /- API information and available endpointsGET /api/flights/{flight_id}- Get flight details by IDGET /api/flights/date/{year}/{month}/{day}- Get flights by dateGET /api/flights/delayed- Get all delayed flightsGET /api/flights/origin/{origin_code}- Get flights by origin airportGET /api/flights/destination/{destination_code}- Get flights by destination airportGET /api/flights/delayed/origin/{origin_code}- Get delayed flights by origin airportGET /api/flights/delayed/airline/{airline_name}- Get delayed flights by airlineGET /api/stats/airlines- Get airline delay statisticsGET /api/stats/hours- Get hourly delay statisticsGET /api/stats/routes- Get route delay statistics
All API responses are in JSON format and include a success flag and either a data array or an error message.
The database contains the following main tables:
flights: Contains flight records with delay informationairlines: Contains airline information
Key columns in the flights table include:
ID: Unique flight identifierORIGIN_AIRPORT: 3-letter IATA code for origin airportDESTINATION_AIRPORT: 3-letter IATA code for destination airportDEPARTURE_DELAY: Delay in minutesDAY,MONTH,YEAR: Flight dateHOUR: Hour of scheduled departure
- Python 3.7 or higher
- Flask 2.0 or higher
- SQLAlchemy 1.4 or higher
- Matplotlib 3.5 or higher
- Seaborn 0.11 or higher
- Pandas 1.3 or higher
- Folium (for interactive maps)
- Webbrowser (standard library, for opening maps)
The application can also be run using Docker with the provided Dockerfile and docker-compose.yml.
See requirements.txt for a complete list of dependencies.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request