
Building SunSwitch: AI-Powered DG-to-Solar Switch Advisor Using Amazon Bedrock & AWS Serverless
Discover how SunSwitch uses Amazon Bedrock Nova Lite and AWS Serverless to convert messy handwritten diesel generator logbooks into bankable rooftop solar investment proposals in under 60 seconds, saving housing societies ₹21+ Crores and cutting 11,400+ tonnes of CO2.
Every winter across Indian metropolitan regions like Delhi-NCR, Noida, and Gurugram, severe air pollution forces authorities to trigger CAQM / GRAP restrictions. Yet, whenever the power grid fluctuates, residential high-rises run large 125–500 kVA Diesel Generator (DG) sets, emitting hazardous PM2.5, NOx, and black carbon right into residential neighborhoods.
Housing societies want to transition away from diesel, but they face three major roadblocks:
- Crippling Fuel Costs: Diesel power costs ₹28 to ₹35+ per kWh, compared to grid electricity at ₹7–8/kWh.
- Messy, Paper-Based Records: Crucial generator fuel consumption and running hours are tracked on faded, handwritten paper notebooks in basement generator rooms.
- Decision Paralysis at AGMs: Residential Welfare Association (RWA) committees need to convince hundreds of apartment owners to invest in rooftop solar and battery storage (BESS), but lack data-backed financial ROI and subsidy modeling.
To solve this, we created SunSwitch—an AI-powered DG-to-Solar Switch Advisor built entirely on AWS serverless services. In under 60 seconds, SunSwitch extracts handwritten logbook records, performs techno-economic solar feasibility modeling, and outputs a bilingual (English + Hindi) AGM resolution report.
🏗️ System Architecture
SunSwitch was designed with zero-idle-cost serverless principles, scaling on-demand while maintaining strict data privacy:
Key AWS Services Used:
- AWS Amplify: Hosts our React 19 single-page application with continuous deployment from Git, delivering sub-second edge loading.
- Amazon S3: Uses presigned POST URLs for secure direct image uploads from the browser, bypassing API Gateway’s 10MB payload limitation. Configured with a 7-day lifecycle policy to auto-delete images for resident privacy.
- Amazon API Gateway & AWS Lambda (Python 3.12): Provides high-performance, stateless REST endpoints for presigned URL generation, document extraction, solar ROI calculation, and report retrieval.
- Amazon Bedrock (Nova Lite
us.amazon.nova-lite-v1:0): Ingests raw images of handwritten logbooks to extract runtime hours and fuel consumption with contextual document reasoning. Bedrock also generates bilingual (English + Devanagari Hindi) executive summaries.
- Amazon DynamoDB: Stores calculated reports with native Decimal financial accuracy and an automated 90-day Time-To-Live (TTL) attribute.
- AWS SAM (Serverless Application Model): Deploys the entire backend infrastructure reproducibly with Infrastructure as Code.
🧠 Multimodal Extraction with Amazon Bedrock Nova Lite
Standard OCR models fail on Indian handwritten logbooks due to cursive ink, bilingual headings, and imperfect paper condition. With Amazon Bedrock Nova Lite, we pass image bytes directly into the multimodal model:
Python
import jsonimport boto3bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")s3 = boto3.client("s3")def extract_logbook_data(bucket_name: str, object_key: str):# Fetch image from ephemeral S3 storages3_obj = s3.get_object(Bucket=bucket_name, Key=object_key)image_bytes = s3_obj["Body"].read()request_payload = {"messages": [{"role": "user","content": [{"image": {"format": "jpeg", "source": {"bytes": image_bytes}}},{"text": "Extract total diesel litres, operating hours, and duration in months from this logbook. Return valid JSON only with keys: total_litres, total_hours, period_months, confidence."}]}],"inferenceConfig": {"maxTokens": 512, "temperature": 0.1}}response = bedrock.invoke_model(modelId="us.amazon.nova-lite-v1:0",body=json.dumps(request_payload))result = json.loads(response["body"].read())return json.loads(result["output"]["message"]["content"][0]["text"])
Nova Lite reliably extracted numbers such as
269 Litres , 12 hours , and 6 months from real, handwritten sample sheets with high confidence.
📊 Real-World Case Study: The 21-Crore Switch
We tested SunSwitch with real operational figures for an apartment complex in Gurugram:
Metric | Diesel Generator (Baseline) | SunSwitch Solar + BESS Proposal |
|---|---|---|
Power Cost (LCOE) | ₹29.68 / kWh | ₹1.48 / kWh (95% reduction) |
Solar Array Sized | 0 kWp | 541 kWp Rooftop Solar |
Capital Subsidy | ₹0 | ₹90 Lakhs (PM Surya Ghar scheme) |
Payback Period | N/A | 3.6 Years |
25-Year Net Savings | ₹0 | ₹21.25 Crore |
Emissions Cut | 0 tonnes | 11,451 tonnes CO₂ avoided |
💡 Key Architectural Takeaways
- Direct-to-S3 Uploads: Never stream raw mobile photos through API Gateway or Lambda. Presigned S3 uploads make ingestion fast and prevent Lambda timeout bottlenecks.
- Cross-Region Bedrock Inference: Pairing low-latency regional storage in
ap-south-1(Mumbai) with Amazon Bedrock cross-region inference profiles inus-east-1provided sub-second AI inference without regional lock-in.
- Zero Waste Data Lifecycles: Combining S3 Lifecycle Rules with DynamoDB TTL ensures zero lingering storage costs and keeps resident data private.
🔗 Try SunSwitch & Explore the Code
- Live Web Application: https://master.d2s5glz92d1mf0.amplifyapp.com
- Verified Sample Audit Report: View Report fa843a67
- GitHub Repository: https://github.com/my-codespace/dg-solar-advisor
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article