It is menu driven Python app about Air Quality Index Data
A comprehensive command-line application for monitoring and managing air quality index (AQI) data across different cities. This system allows users to input, store, search, and analyze air quality data with a focus on user-friendly terminal interface and data persistence.
- Features
- Requirements
- Installation
- Usage
- Project Structure
- Data Storage
- Menu Options
- Admin Functions
- References
- Author
- License
- Data Entry: Add new cities and their AQI measurements with automatic timestamp recording
- City Management: Choose from existing cities or add new ones dynamically
- Search Functionality: Search for specific cities and view their AQI history
- Data Sorting & Analysis:
- Sort cities by AQI (highest to lowest, lowest to highest)
- Sort cities alphabetically (A-Z, Z-A)
- Calculate average AQI across all data
- Administrative Controls:
- Database deletion (password-protected)
- Database backup with timestamped filenames
- Beautiful Terminal Interface: Color-coded menus and formatted displays using custom display library
- Persistent Storage: Data saved to JSON file with automatic file creation
- Python Version: Python 3.x
- Standard Libraries Used:
json- For data serialization and storagedatetime- For timestamp generationos- For file operationsshutil- For file copying (database backup)
Both of the following files must be present in the same directory for the application to function properly:
air_quality_index_app.py- Main application filedisplay_library.py- Terminal display and formatting utilities (required dependency)
Note: No external Python packages are required - all dependencies are built-in standard library modules or the included display_library.py file.
-
Clone the Repository:
git clone https://github.com/CookieMonster-alt/Air-Quality-Monitor-System.git cd Air-Quality-Monitor-System -
Verify Files: Ensure both main files are present in the directory:
air_quality_index_app.py(Main application)display_library.py(Display formatting utilities)
-
Run the Application:
python air_quality_index_app.py
The application automatically creates a cities.json file if it doesn't exist when you first run the program.
Upon running, you'll be presented with a main menu offering five options:
- Data Entry Menu - Add new AQI records
- Search Menu - Search and display existing city data
- Reports and Analysis Menu - View sorted data and calculations
- Admin Menu - Database management functions
- Exit Program - Safely exit the application
- Start the application
- Choose option 1 for Data Entry
- Either select an existing city or add a new one
- Enter the AQI value (accepts decimal numbers)
- Data is automatically saved with timestamp
- Return to main menu or continue entering data
air-quality-monitor/
├── air_quality_index_app.py # Main application file with menu system and core functions
├── display_library.py # Display utilities for terminal formatting and UI
├── cities.json # Database file (created automatically)
├── backup_file_*.json # Backup files (created via admin menu)
└── README.md # This file
air_quality_index_app.py
- Main entry point of the application
- Contains all menu systems and core business logic
- Handles data manipulation, file operations, and calculations
display_library.py
- Terminal display and formatting utilities
- Provides color-coded output and aligned text display
- Contains functions for screen division and menu presentation
- Reusable for other terminal-based applications
The application stores all data in a cities.json file with the following structure:
{
"London": [
{
"AQI": 45.2,
"Timestamp": "2025-11-21 19:30"
},
{
"AQI": 38.7,
"Timestamp": "2025-11-21 18:45"
}
],
"Manchester": [
{
"AQI": 52.1,
"Timestamp": "2025-11-21 19:15"
}
]
}- JSON file is created automatically if it doesn't exist
- Timestamps use ISO format with minutes precision
- Data persists between application sessions
- Display all existing cities as numbered options
- Option to add new cities dynamically
- Input validation for AQI values (accepts floats)
- Confirmation for multiple entries per city
- Sort by AQI: High to low and low to high
- Sort by City Name: Alphabetical A-Z and Z-A
- Average Calculation: Overall AQI average with 2 decimal precision
- Formatted table display with borders
- Case-insensitive city name search
- Displays formatted table of AQI history
- Informative messages for found/not found cities
- Password-protected operation
- Deletes the entire
cities.jsonfile - Confirmation dialog to prevent accidental deletion
- Creates timestamped copies of the database
- Backup format:
backup_file_TIMESTAMP_cities.json - No password required for backup operations
The development of this application referenced the following sources:
- Real Python (2025). How to Write Beautiful Python Code With PEP 8.
- GeeksforGeeks (2021). Isoformat() Method Of Datetime Class In Python.
- Fadheli, A. (2024). Keyboard module: Controlling your Keyboard in Python.
- Python Software Foundation (n.d.). os.path — Common pathname manipulations.
- Mwiti, D. (2025). Python Try-Except Tutorial: Best Practices and Real-World Examples.
- GeeksforGeeks (2025). How To Check If Variable Is Empty In Python?.
- GeeksforGeeks (2025). Check If Value Is Int or Float in Python.
- KDnuggets (2024). Convert Python Dict to JSON: A Tutorial for Beginners.
- PyNative (n.d.). Python File Handling.
- AskPython (n.d.). How to Copy a File in Python.
- Zaric, D. (2022). How to sort with lambda key function in Python.
- PythonExamples.org (n.d.). Python JSON to List.
- Programiz (n.d.). Python String center() Method (With Examples).
- Tutorials Point (2023). How to Align Text Strings using Python?.
- Sentry (2023). Print colored text to terminal with Python.
Iliya Metodiev
- Created: October 17, 2025 - November 7, 2025
- Purpose: School assignment for Air Quality Monitor System
- Additional Note:
display_library.pywas developed as a reusable terminal display module
This project was developed for educational purposes as part of a school assignment. All rights reserved.
Important Notes:
- Both
air_quality_index_app.pyanddisplay_library.pymust be in the same directory for the application to function properly. - The display library includes color coding that works best on terminals supporting ANSI color codes.