Skip to content

About

This project is all about water quality measuremetns. This project particualry fucus on Victoria specially all beaches and river water quality.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

IE Flask API - Clean Water & Sanitation Platform

A Flask-based REST API backend supporting a clean water and sanitation monitoring platform aligned with UN Sustainable Development Goal 6: Clean Water and Sanitation.

📋 Project Overview

This API powers a comprehensive water quality and sanitation resource platform for Victoria, Australia. It enables users to:

  • Monitor water quality at beaches and rivers
  • Locate public toilets and water fountains
  • Rate and review sanitation facilities
  • Subscribe to water quality updates via email notifications
  • Access educational information about water quality measurement

Target Audience

  • Victoria residents
  • Families with children and pets
  • Australian tourists
  • Outdoor activity enthusiasts
  • Outdoor workers (delivery staff, drivers, Uber drivers)

🏗️ Architecture

AWS Infrastructure

  • EC2: Hosts the Flask API application
  • RDS (PostgreSQL): Database for storing all application data
  • Route 53: Domain name management and DNS routing
  • S3 + CloudFront: Frontend static file hosting and CDN
  • ACM (AWS Certificate Manager): SSL/TLS certificate management for secure connections

🚀 API Endpoints

Health Check

Simple status endpoint to verify API availability.

GET /api/v1/health

Response:

{
  "success": true,
  "status": "ok"
}

User Management

Endpoints for user CRUD operations.

Method Endpoint Description
GET /api/v1/users List all users
POST /api/v1/users Create new user
GET /api/v1/users/<user_id> Get user by ID
PUT /api/v1/users/<user_id> Update user details
DELETE /api/v1/users/<user_id> Delete user
GET /api/v1/users/search Search users

Beach Monitoring

Manage beach locations and water quality data.

Method Endpoint Description
GET /api/v1/beaches List all beaches
POST /api/v1/beaches Add new beach
GET /api/v1/beaches/<beach_id> Get beach by ID
PUT /api/v1/beaches/<beach_id> Update beach details
DELETE /api/v1/beaches/<beach_id> Remove beach
DELETE /api/v1/beaches/update-all-predictions Update water quality predictions for all beaches

River Monitoring

Manage river monitoring locations with ML-based water quality predictions.

Method Endpoint Description
GET /api/v1/rivers List all rivers
POST /api/v1/rivers Add new river
GET /api/v1/rivers/<river_id> Get river by ID
PUT /api/v1/rivers/<river_id> Update river details
DELETE /api/v1/rivers/<river_id> Remove river
GET /api/v1/rivers/<river_id>/predict Get prediction for specific river
POST /api/v1/rivers/<river_id>/predict Generate prediction for specific river
POST /api/v1/rivers/<river_id>/update-predict Update prediction value
POST /api/v1/rivers/update-all-predictions Batch update all river predictions
GET /api/v1/rivers/<river_id>/with-prediction Get river data with prediction

Notifications

Email notification system for water quality updates.

Method Endpoint Description
POST /api/v1/notifications Create notification subscription
GET /api/v1/notifications?booking_datetime=YYYY-MM-DD HH:MM:SS Get notifications for specific datetime
POST /api/v1/notifications/send-due Trigger sending of due notifications

Toilet Ratings

Community rating system for public toilets.

Method Endpoint Description
POST /api/v1/toilet-ratings Submit toilet rating
GET /api/v1/toilet-ratings Get all ratings
GET /api/v1/toilet-ratings/<rating_id> Get rating by ID
GET /api/v1/toilet-ratings/latest Get latest rating comments
GET /api/v1/toilet-ratings/average/<toilet_id> Get average rating for toilet

Water Fountains

Public water fountain location management.

Method Endpoint Description
GET /api/v1/water-fountains List all water fountains with place names
GET /api/v1/water-fountains/<fountain_id> Get water fountain by ID with place name

🛠️ Technology Stack

  • Framework: Flask (Python)
  • Database: PostgreSQL (AWS RDS)
  • Cloud Platform: AWS
  • API Style: RESTful

📦 Installation & Setup

Prerequisites

  • Python 3.8+
  • PostgreSQL
  • AWS Account (for deployment)

Local Development

  1. Clone the repository
git clone https://github.com/lily-yyyy/IE_Flask_Api.git
cd IE_Flask_Api
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure environment variables
# Create .env file with the following:
DATABASE_URL=postgresql://username:password@localhost:5432/dbname
FLASK_ENV=development
SECRET_KEY=your-secret-key
AWS_ACCESS_KEY_ID=your-aws-key
AWS_SECRET_ACCESS_KEY=your-aws-secret
  1. Initialize database
flask db init
flask db migrate
flask db upgrade
  1. Run the application
flask run

The API will be available at http://localhost:5000

🚢 Deployment

AWS EC2 Deployment

  1. Launch EC2 instance (Amazon Linux 2 or Ubuntu)
  2. Install Python and required dependencies
  3. Clone repository and set up application
  4. Configure RDS PostgreSQL connection
  5. Set up nginx as reverse proxy
  6. Configure SSL certificate with ACM
  7. Update Route 53 DNS records

Environment Variables

Ensure the following environment variables are set in production:

  • DATABASE_URL: PostgreSQL connection string
  • FLASK_ENV: Set to production
  • SECRET_KEY: Strong secret key for session management
  • AWS_REGION: AWS region for services
  • Email configuration for notification system

🔒 Security

  • HTTPS enforced via AWS ACM certificates
  • Environment variables for sensitive data
  • Input validation on all endpoints
  • CORS configured for frontend domain
  • SQL injection prevention through ORM

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🌐 Related Links

📧 Contact

For questions or support, please open an issue in the GitHub repository.


Built with ❤️ for cleaner water and better sanitation in Victoria, Australia

About

This project is all about water quality measuremetns. This project particualry fucus on Victoria specially all beaches and river water quality.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages