Skip to content

Sameer6305/Smart-Sustainability-Manager

Repository files navigation

🌱 Sustainable Resource Management System

A professional, production-ready application built with Object-Oriented Programming (OOP) in Python and a modern Streamlit frontend. This system demonstrates sustainable management of urban resources including water, energy, and waste with stunning Lottie animations and a professional UI.

Python Streamlit License Lottie


📋 Table of Contents


✨ Features

Backend (OOP Core)

  • Abstraction: Base Resource class defines common behavior
  • Inheritance: WaterResource, EnergyResource, WasteResource extend base class
  • Encapsulation: Protected attributes with getter methods
  • Polymorphism: Uniform method calls with custom implementations
  • Error Handling: Robust validation and meaningful error messages
  • Resource Tracking: Real-time usage monitoring and history
  • Consumer Management: Multi-consumer resource assignment and tracking
  • Sustainability Scoring: Automated sustainability metrics

Frontend (Streamlit UI)

  • 🎨 Modern Design: Gradient backgrounds, card layouts, smooth animations
  • 🎬 Lottie Animations: Professional animated icons throughout the app
  • 📊 Interactive Dashboard: Real-time metrics and visualizations
  • 📈 Advanced Charts: Using Plotly for interactive graphs
  • 🎯 Resource Management: Add, view, and manage resources
  • 👥 Consumer Management: Register and track consumers
  • 📉 Consumption Tracking: Log resource usage with validation
  • 📋 Comprehensive Reports: Analytics and sustainability insights
  • ⚠️ Smart Alerts: Real-time warnings and recommendations
  • 🎭 Responsive Design: Professional UI suitable for demos and presentations
  • Smooth Animations: Fade-in, slide, pulse, glow, and bounce effects
  • 🌊 Animated Metrics: Eye-catching metric cards with hover effects

🎬 Animation Features

  • Dashboard Animation: Sustainability Lottie animation on main dashboard
  • Resource Management: Water drop animation for resources
  • Consumer Management: Analysis animation for consumer tracking
  • Consumption Tracking: Energy animation for usage recording
  • Reports: Analytics animation for report section
  • Sidebar Logo: Animated recycle icon
  • Success Celebrations: Party animation on successful actions
  • CSS Animations: Fade-in, slide-in, pulse, shimmer, bounce, rotate, and glow effects

🏗️ OOP Principles Demonstrated

1. Abstraction

class Resource(ABC):
    @abstractmethod
    def report_usage(self) -> Dict:
        """Each resource type implements its own reporting"""
        pass

2. Inheritance

class WaterResource(Resource):  # Inherits from Resource
class EnergyResource(Resource):  # Inherits from Resource
class WasteResource(Resource):   # Inherits from Resource

3. Encapsulation

class Resource:
    def __init__(self, name, total_available, renewable):
        self._total_available = total_available  # Protected attribute
        self._available = total_available         # Protected attribute
    
    @property
    def available(self):  # Getter method
        return self._available

4. Polymorphism

# Same method, different implementations
water_resource.report_usage()  # Returns water-specific report
energy_resource.report_usage()  # Returns energy-specific report
waste_resource.report_usage()   # Returns waste-specific report

📁 Project Structure

OOP Mini Project/
│
├── resource_management.py    # Backend: OOP classes
├── app.py                    # Frontend: Streamlit UI with animations
├── requirements.txt          # Dependencies
├── start.bat                 # Windows launcher
├── README.md                 # Documentation
├── UI_IMPROVEMENTS.md        # UI feature documentation
├── OOP_DOCUMENTATION.md      # OOP concepts documentation
└── DEMO_GUIDE.md             # Presentation guide

File Descriptions

resource_management.py (Backend)

  • Resource (Abstract Base Class)
  • WaterResource (Inheritance)
  • EnergyResource (Inheritance)
  • WasteResource (Inheritance)
  • Consumer (Composition)
  • ResourceManager (Orchestration)

app.py (Frontend)

  • Dashboard with live metrics and Lottie animations
  • Resource management interface with animations
  • Consumer management interface
  • Consumption tracking with energy animations
  • Reports and analytics with visual feedback
  • Custom CSS with keyframe animations
  • Professional gradient design

🎨 New UI Features

Visual Enhancements

  • Lottie Animations: Smooth, professional animations throughout the app
    • Dashboard: Sustainability animation
    • Resources: Water drop animation
    • Consumers: Analysis animation
    • Consumption: Energy animation
    • Reports: Analytics animation
    • Sidebar: Animated recycle logo
    • Success: Celebration animation

CSS Animations

  • Fade In Up: Smooth entry animations for content
  • Slide In Right: Header animations
  • Pulse: Button hover effects
  • Shimmer: Loading states
  • Bounce: Interactive elements
  • Rotate: Icon animations
  • Glow: Card hover effects with pulsing shadows

Design Features

  • 3.5rem large metric displays
  • Gradient backgrounds throughout
  • Smooth transitions on all interactive elements
  • Shadow effects with depth
  • Hover states on all cards and tables
  • Color-coded status indicators (🟢🟡🟠🔴)
  • Professional typography with Inter font family
  • Responsive layout with proper spacing

Interactive Elements

  • Animated metric cards with hover effects
  • Progress bars with gradient fills
  • Tables with zebra striping and hover scaling
  • Buttons with pulse animations
  • Expandable cards with smooth transitions
  • Tabs with gradient active states

🚀 Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)
  • Internet connection (for Lottie animations)

Step 1: Clone or Download

Download this project to your local machine.

Step 2: Install Dependencies

Open terminal/command prompt in the project directory and run:

pip install -r requirements.txt

This will install:

  • streamlit - Web framework
  • pandas - Data manipulation
  • plotly - Interactive charts
  • streamlit-lottie - Lottie animations
  • requests - HTTP library for loading animations

▶️ Running the Application

Method 1: Using Command Line

  1. Open terminal/command prompt
  2. Navigate to project directory:
    cd "path/to/OOP Mini Project"
  3. Run the application:
    streamlit run app.py
  4. The app will open in your default browser at http://localhost:8501

Method 2: Using the Batch File (Windows)

Double-click start.bat to launch the application automatically.

Method 2: Using Python

python -m streamlit run app.py

Stopping the Application

Press Ctrl + C in the terminal to stop the server.


📖 Usage Guide

1. Dashboard 🏠

  • View system overview
  • Monitor total resources and consumers
  • Check sustainability score
  • Review alerts and recommendations

2. Resources 💧

  • View Resources: See all available resources with status
  • Add New Resource:
    • Select type (Water/Energy/Waste)
    • Enter name and capacity
    • Mark as renewable or non-renewable
    • Add type-specific attributes

3. Consumers 👥

  • View Consumers: See all registered consumers and their usage
  • Add New Consumer:
    • Enter Consumer ID and Name
    • Select consumer type
    • Assign resources

4. Consumption 📊

  • Select a consumer
  • Choose a resource
  • Enter usage amount
  • System validates availability
  • Records transaction

5. Reports 📈

  • Resource Analytics: Usage charts and comparisons
  • Consumer Analytics: Activity tracking
  • Sustainability:
    • Sustainability score gauge
    • Carbon footprint calculation
    • Recommendations

🏛️ Class Architecture

Class Hierarchy

                    Resource (ABC)
                         |
        +----------------+------------------+
        |                |                  |
   WaterResource   EnergyResource    WasteResource
   
   
   Consumer (Uses resources)
   
   ResourceManager (Orchestrates everything)

Key Classes

Resource (Abstract Base Class)

  • Attributes: name, _total_available, _available, renewable
  • Methods:
    • update_availability(amount) - Encapsulation
    • report_usage() - Polymorphism (abstract)
    • get_status() - Common behavior

WaterResource (Inherits Resource)

  • Additional: water_type, unit
  • Methods:
    • report_usage() - Water-specific implementation
    • check_contamination_risk() - Water-specific

EnergyResource (Inherits Resource)

  • Additional: energy_type, unit
  • Methods:
    • report_usage() - Energy-specific implementation
    • calculate_carbon_footprint() - Energy-specific

WasteResource (Inherits Resource)

  • Additional: waste_type, unit
  • Methods:
    • report_usage() - Waste-specific implementation
    • get_recycling_rate() - Waste-specific

Consumer

  • Attributes: consumer_id, name, _assigned_resources, _usage_log
  • Methods:
    • assign_resource(resource) - Composition
    • use_resource(resource_name, amount) - Transaction
    • generate_usage_report() - Analytics

ResourceManager

  • Orchestrates: All resources and consumers
  • Methods:
    • add_resource(), add_consumer()
    • generate_system_report()
    • calculate_sustainability_score()
    • get_sustainability_recommendations()

🎯 Demo Data

The application comes with pre-loaded demo data:

Resources:

  • City Water Supply (100,000 liters, Renewable)
  • Rainwater Harvesting (50,000 liters, Renewable)
  • Solar Power (50,000 kWh, Renewable)
  • Grid Electricity (100,000 kWh, Non-Renewable)
  • Recyclable Waste (20,000 kg)
  • Organic Waste (15,000 kg)

Consumers:

  • Residential Complex A (C001)
  • Commercial Building B (C002)
  • Industrial Park C (C003)

Sample Transactions:

  • Pre-simulated usage for demonstration

🎓 Academic Submission

Report Structure Suggestion

  1. Introduction

    • Problem statement
    • Objectives
    • Scope
  2. OOP Concepts

    • Abstraction (with code examples)
    • Inheritance (class hierarchy diagram)
    • Encapsulation (protected attributes)
    • Polymorphism (method overriding)
  3. System Design

    • Class diagrams
    • Architecture overview
    • Database/state management
  4. Implementation

    • Code walkthrough
    • Key features
    • Error handling
  5. Testing

    • Test cases
    • Screenshots
    • Demo scenarios
  6. Conclusion

    • Achievements
    • Learning outcomes
    • Future enhancements

Presentation Tips

  1. Start with Dashboard: Show live metrics
  2. Add a Resource: Demonstrate modularity
  3. Add a Consumer: Show composition
  4. Record Usage: Show validation and error handling
  5. Show Reports: Highlight analytics
  6. Explain Code: Walk through key OOP concepts

🎨 Customization

Changing Colors

Edit the CSS in app.py under load_custom_css():

background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

Adding New Resource Types

  1. Create new class inheriting from Resource
  2. Override report_usage() method
  3. Add type-specific methods
  4. Update UI in app.py

Modifying Demo Data

Edit load_demo_data() function in app.py


🐛 Troubleshooting

Issue: "Module not found"

Solution: Ensure all dependencies are installed:

pip install -r requirements.txt

Issue: "Port already in use"

Solution: Use a different port:

streamlit run app.py --server.port 8502

Issue: "Session state not persisting"

Solution: This is normal - refresh resets demo data. Use the "Reset Demo Data" button.


🚀 Deployment (Optional)

Deploy to Streamlit Cloud (Free)

  1. Push code to GitHub repository
  2. Go to streamlit.io/cloud
  3. Sign in with GitHub
  4. Select your repository
  5. Click "Deploy"

Your app will be live at: https://your-app-name.streamlit.app


📝 License

This project is created for educational purposes. Feel free to use and modify for academic submissions.


👨‍💻 Author

Pranav Kadam

  • Project: OOP Mini Project
  • Technology: Python, Streamlit, OOP
  • Date: February 2026

🙏 Acknowledgments

  • Python Software Foundation
  • Streamlit Community
  • Plotly for visualization tools

📞 Support

For questions or issues:

  1. Check this README
  2. Review code comments
  3. Test with demo data
  4. Check Streamlit documentation

🎉 Features Checklist

  • ✅ Abstraction implemented
  • ✅ Inheritance demonstrated
  • ✅ Encapsulation enforced
  • ✅ Polymorphism showcased
  • ✅ Error handling included
  • ✅ Professional UI design
  • ✅ Interactive charts
  • ✅ Real-time validation
  • ✅ Comprehensive documentation
  • ✅ Demo data included
  • ✅ Production-ready code

Happy Coding! 🚀

About

A Python OOP–based system for tracking and managing urban resources with an interactive Streamlit dashboard.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors