Smart Insulin Calculator: A Personal Journey

Inspiration

Diabetes management isn't just a challenge—it's a way of life for millions, including myself. Diagnosed at 17 with a mother who has battled diabetes since childhood, I understand the daily struggles diabetics face. The constant juggling act of keeping blood sugar levels balanced is exhausting: hypoglycemia leaves you shaky and dizzy, while hyperglycemia brings thirst and fatigue. Both can be dangerous if not addressed quickly.

This personal experience drove me to leverage my technical expertise and create something meaningful—a system that could make diabetes management more precise and less burdensome for myself and others in the diabetic community.

What it does

My Smart Insulin Calculator is an intelligent system that goes beyond basic carb counting to provide precise insulin dosage recommendations. The system:

  • Analyzes food descriptions using AI to extract detailed nutritional data (carbohydrates, proteins, fats, and glycemic index)
  • Calculates personalized insulin doses based on current blood glucose levels and individual insulin-to-carb ratios
  • Accounts for circadian rhythms - factoring in dawn phenomenon and daily insulin sensitivity variations that affect dosing needs
  • Implements advanced FPU calculations (Fat-Protein Units) using evidence-based medical protocols for extended insulin coverage
  • Optimizes injection timing by modeling when insulin activity best matches food absorption patterns
  • Provides detailed dosing schedules with specific timing recommendations for both immediate and extended insulin needs

How we built it

I built the system using AWS cloud services for scalability and reliability:

  • AWS Bedrock powers the AI nutritional analysis, using Claude to parse natural language food descriptions into structured nutritional data
  • AWS Lambda handles the core calculation logic, implementing complex mathematical models based on clinical research
  • DynamoDB stores historical data and user profiles for pattern analysis and personalized recommendations
  • Python with NumPy for the mathematical modeling of insulin pharmacokinetics and carbohydrate absorption curves
  • Evidence-based algorithms derived from clinical studies, including the Warsaw Method for FPU calculations and gamma distribution models for timing optimization

The architecture uses asynchronous processing to handle multiple food items simultaneously and implements robust error handling for real-world reliability.

Challenges we ran into

Translating Medical Research into Code: The biggest challenge was converting complex clinical studies into accurate algorithms. I spent extensive time studying insulin pharmacokinetics research and circadian metabolism patterns to create mathematical models that reflected real biological processes.

Handling Inconsistent Food Data: Getting reliable nutritional information from natural language descriptions proved difficult. I solved this by implementing cached prompts, robust error handling, and fallback mechanisms for when AI responses were inconsistent.

Ensuring Medical Safety: Building a system that provides medical recommendations required extreme precision. I implemented multiple validation layers, conservative safety margins, and evidence-based defaults to ensure the system never gives potentially dangerous advice.

Complex Timing Calculations: Modeling the interaction between insulin activity curves and food absorption patterns required sophisticated mathematical modeling using gamma distributions and optimization algorithms.

Accomplishments that we're proud of

  • Evidence-based accuracy: Successfully implemented clinically-validated algorithms like the Warsaw Method for FPU calculations
  • Personalized circadian modeling: Created a system that adjusts recommendations based on time-of-day insulin sensitivity variations
  • Real-world usability: Built a system that handles the messiness of actual food descriptions while maintaining medical precision
  • Comprehensive coverage: Goes beyond simple carb counting to include proteins, fats, and their delayed glucose effects
  • Safety-first design: Implemented multiple safeguards and conservative approaches to ensure user safety

What we learned

This project taught us that the most impactful technology comes from solving your own problems. Key learnings include:

  • Medical software requires different standards - precision, safety, and evidence-based approaches are non-negotiable
  • Personal experience drives better design - understanding the daily reality of diabetes management informed every technical decision
  • Complex biology can be modeled mathematically - with enough research and careful implementation
  • AI can handle medical complexity - but requires careful prompt engineering and validation
  • Cloud architecture enables healthcare innovation - AWS services provided the reliability and scalability needed for health applications

What's next for Insulin Calculator

Enhanced Machine Learning: Implement personalized learning algorithms that adapt recommendations based on individual response patterns and historical data.

Continuous Glucose Monitor Integration: Connect with CGM devices to provide real-time feedback and predictive recommendations based on current glucose trends.

Mobile Application: Develop a user-friendly mobile interface with photo-based food recognition and voice input capabilities.

Clinical Validation Studies: Partner with healthcare providers to conduct formal clinical trials and gather real-world effectiveness data.

Expanded Food Database: Build a comprehensive database of regional and cultural foods with verified nutritional information.

Healthcare Provider Dashboard: Create tools for endocrinologists to monitor patient patterns and adjust treatment plans based on system data.

Community Features: Add peer support and data sharing capabilities to help diabetics learn from each other's experiences while maintaining privacy.

Built With

Share this project:

Updates