03chrisk
Update streamlit README.md how to run the app
9a7c521 unverified

A newer version of the Streamlit SDK is available: 1.56.0

Upgrade

Utrecht Air Quality Monitoring Application πŸŒπŸ’¨

Welcome to the Utrecht Air Quality Monitoring application! This interactive app, built with Streamlit, provides timely insights into the levels of key air pollutantsβ€”NOβ‚‚ and O₃—in Utrecht, helping users monitor and forecast air quality based on WHO standards.


🌟 Features

  • Real-Time Monitoring: Stay updated on today’s air quality with data updated every 6 hours.
  • 3-Day Forecasts: View predicted NOβ‚‚ and O₃ levels for the upcoming three days.
  • User & Admin Dashboards: Easy-to-use interfaces for general users and detailed analytics for admins.
  • Comprehensive MVC Structure: Organized codebase for easy navigation, maintenance, and scalability.

πŸ“‚ Folder Structure

streamlit_src/
β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ home_controller.py      # Manages logic for the main dashboard and user access
β”‚   β”œβ”€β”€ user_controller.py      # Controls data display on the user dashboard
β”‚   └── admin_controller.py     # Extends user_controller for admin-specific features
β”‚
β”œβ”€β”€ json_interactions/          # Handles JSON data interactions for configuration and storage
β”‚   └── (JSON handling scripts)
β”‚
β”œβ”€β”€ models/
β”‚   └── air_quality_model.py    # Contains model loading, preprocessing, and prediction logic
β”‚
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ home_view.py            # Sets up the main interface and role selection
β”‚   β”œβ”€β”€ user_view.py            # Displays air quality data and forecasts for users
β”‚   └── admin_view.py           # Presents analytics and monitoring tools for admins
β”‚
β”œβ”€β”€ README.md                   # Documentation for the Streamlit application
β”œβ”€β”€ __init__.py                 # Initializes the streamlit_src package
└── app.py                      # Main entry point to run the Streamlit application

βš™οΈ Design Pattern: MVC

To make the application easy to manage and extend, we’ve structured it using the Model-View-Controller (MVC) design pattern. Here’s how each part contributes:

1. Model (air_quality_model.py)

Our Model forms the backbone of the application, handling:

  • Data loading and preprocessing to ensure consistency in predictions.
  • Air quality prediction models for NOβ‚‚ and O₃, using data collected over past days.
  • Prediction logic that leverages our trained models to provide accurate, actionable forecasts.

2. Views (home_view.py, user_view.py, admin_view.py)

The View components shape the look of the application, providing different displays for each user role:

  • home_view.py: Sets up the main page layout, including a field for users to switch roles or log in as an admin.
  • user_view.py: Manages the visual elements and display of air quality forecasts for NOβ‚‚ and O₃ on the user dashboard.
  • admin_view.py: Handles all visual elements on the admin dashboard, including advanced metrics, monitoring tools, and model performance data.

3. Controllers (home_controller.py, user_controller.py, admin_controller.py)

Our Controller modules serve as intermediaries, connecting the model's data and logic with the views’ visual representation. Each controller is aligned with a specific view:

  • home_controller.py: Manages the logic for the main dashboard, handling user access and controlling the display of either the user or admin dashboard.
  • user_controller.py: Manages the logic for the user dashboard, making use of the user_view.py script to correctly format the user dashboard including.
  • admin_controller.py: Manages the logic for the admin dashboard, extending the UserController to provide additional features tailored to admin needs.

πŸš€ How to Run the App

To launch the Utrecht Air Quality Monitoring application, follow these simple steps:

  1. Navigate to the streamlit_src folder in your terminal where the app files are located.

  2. Run the Streamlit application by entering the following command:

    streamlit run app.py
    > [!TIP]
    > **Alternative Path**: If you are not in the `streamlit_src` folder, provide the full path to `app.py`. For example, from the root directory:
    > - **Windows**: 
    >   ```bash
    

streamlit run .\streamlit_src\app.py

- **macOS/Linux**: 
```bash
streamlit run ./streamlit_src/app.py