A comprehensive cloud-native application for monitoring, analyzing, and optimizing energy consumption across campus buildings, built entirely on AWS serverless architecture.
The Smart Campus Energy Management System provides real-time energy monitoring and management capabilities for educational institutions. The system collects data from simulated building sensors, processes and analyzes that data in real-time, and presents actionable insights through an intuitive web dashboard.
Key Features:
- Real-time energy consumption monitoring across campus buildings
- Historical data analysis with trends and patterns visualization
- Automated alerting for abnormal energy usage or system events
- Comprehensive reporting capabilities with customizable date ranges
- RESTful API for integration with other campus systems
This application is built using a modern serverless architecture on AWS with the following components:
-
Compute Services
- AWS Lambda for serverless processing of data and API requests
- Functions for data simulation, API handling, data archiving, and alert processing
-
Database Services
- Amazon DynamoDB for high-performance, scalable NoSQL storage of real-time data
- Time-to-Live (TTL) functionality for automatic data lifecycle management
-
Storage Services
- Amazon S3 for static website hosting and long-term data archival
- Automated lifecycle rules for cost-effective data storage
-
Networking & Content Delivery
- Amazon CloudFront for global content delivery with low latency
- Amazon API Gateway for secure and scalable API management
-
Application Integration
- Amazon EventBridge for scheduled operations and event-driven architecture
- Amazon SNS for reliable alert notifications via email and SMS
-
Management & Governance
- Amazon CloudWatch for comprehensive monitoring and logging
- AWS CloudFormation for Infrastructure as Code (IaC) deployment
smart-campus-energy/
├── infrastructure/
│ └── cloudformation/
│ └── template.yaml # CloudFormation template for IaC
├── src/
│ ├── functions/
│ │ ├── data-simulation/ # Lambda function for simulating energy data
│ │ │ └── index.js
│ │ ├── api-handler/ # Lambda function for API requests
│ │ │ └── index.js
│ │ ├── archive/ # Lambda function for archiving data
│ │ │ └── index.js
│ │ └── alert-checker/ # Lambda function for checking alerts
│ │ └── index.js
│ └── web/ # Frontend web application
│ ├── index.html
│ ├── css/
│ │ └── styles.css
│ └── js/
│ └── app.js
├── README.md # Project documentation
└── deploy.sh # Deployment script
To deploy and run this application, you need:
- An AWS account with appropriate permissions
- AWS CLI installed and configured
- Node.js 14+ and npm installed
- AWS SAM CLI (optional but recommended for local testing)
Follow these steps to deploy the Smart Campus Energy Management System:
git clone https://github.com/bishaddebroy/Smart-Energy-System.git
cd Smart-Energy-System# Install dependencies for Lambda functions
cd src/functions/data-simulation
npm install
cd ../api-handler
npm install
cd ../archive
npm install
cd ../alert-checker
npm install
cd ../../..Update the configuration files:
- Edit
src/web/js/app.jsto update theCONFIG.apiEndpointvalue with your actual API Gateway URL after deployment. - Adjust parameters in
infrastructure/cloudformation/template.yamlif needed (environment, retention periods, etc.)
Run the deployment script:
./deploy.shAlternatively, deploy manually with the AWS CLI:
# Create S3 bucket for deployment artifacts
aws s3 mb s3://smart-campus-energy-deployment-bucket
# Package the CloudFormation template
aws cloudformation package \
--template-file infrastructure/cloudformation/template.yaml \
--s3-bucket smart-campus-energy-deployment-bucket \
--output-template-file packaged.yaml
# Deploy the CloudFormation stack
aws cloudformation deploy \
--template-file packaged.yaml \
--stack-name smart-campus-energy \
--capabilities CAPABILITY_IAM \
--parameter-overrides Environment=dev RetentionDays=30After infrastructure deployment, upload the web application files to the created S3 bucket:
# Get the S3 bucket name from CloudFormation outputs
WEBSITE_BUCKET=$(aws cloudformation describe-stacks --stack-name smart-campus-energy --query "Stacks[0].Outputs[?OutputKey=='WebsiteBucketName'].OutputValue" --output text)
# Upload website files
aws s3 sync src/web/ s3://$WEBSITE_BUCKET/ --acl public-readGet the CloudFront URL from the CloudFormation outputs:
CLOUDFRONT_URL=$(aws cloudformation describe-stacks --stack-name smart-campus-energy --query "Stacks[0].Outputs[?OutputKey=='CloudFrontURL'].OutputValue" --output text)
echo "Application URL: $CLOUDFRONT_URL"Visit the URL in your browser to access the Smart Campus Energy Management dashboard.
For local development and testing:
-
Use AWS SAM CLI to test Lambda functions locally:
sam local invoke DataSimulationFunction -
For the web interface, you can use a local HTTP server:
cd src/web npx http-server
This solution aligns with the AWS Well-Architected Framework's six pillars:
-
Operational Excellence
- Infrastructure as Code with CloudFormation
- Comprehensive monitoring and logging with CloudWatch
- Automated deployment processes
-
Security
- Least privilege IAM roles
- API Gateway authentication and authorization
- Encryption at rest and in transit
-
Reliability
- Multi-AZ deployment for high availability
- Serverless architecture eliminates single points of failure
- Automatic scaling with serverless services
-
Performance Efficiency
- DynamoDB's millisecond-latency for real-time data
- CloudFront for optimized content delivery
- Efficient data lifecycle management
-
Cost Optimization
- Serverless pay-per-use pricing model
- S3 lifecycle policies for cost-effective storage
- Resource rightsizing
-
Sustainability
- Serverless computing reduces idle resource waste
- Efficient resource utilization with event-driven architecture
- Data-driven insights for campus energy conservation
This project is licensed under the MIT License - see the LICENSE file for details.
- AWS for providing the cloud infrastructure and services
- Dalhousie University for inspiration and use case scenarios
- All contributors to this project