Skip to content

An intelligent, privacy-first conversational AI assistant for troubleshooting step tracking issues across iOS (HealthKit) and Android (Health Connect) health platforms - by HCL Healthcare Product Team

License

Notifications You must be signed in to change notification settings

Vinamra111/Step-Sync-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Step Sync ChatBot

Flutter Dart License Tests

An intelligent, privacy-first conversational AI assistant for troubleshooting step tracking issues across iOS (HealthKit) and Android (Health Connect) health platforms.

Step Sync ChatBot Banner

🎯 Overview

Step Sync ChatBot is a production-ready Flutter package that provides an intelligent conversational interface for diagnosing and resolving step syncing issues. It combines rule-based logic, comprehensive diagnostics, and optional LLM-powered AI while maintaining strict privacy controls to ensure no Personal Health Information (PHI) is ever sent to external services.

Key Features

  • πŸ€– Hybrid Intelligence: Rule-based (80%) + On-device ML [TODO] (15%) + Cloud LLM (5%)
  • πŸ”’ Privacy-First: HIPAA-aware design, PHI sanitization, critical PII blocking
  • πŸ₯ Health Platform Integration: iOS HealthKit + Android Health Connect
  • πŸ” Comprehensive Diagnostics: Automatic issue detection and guided remediation
  • πŸ’Ύ Conversation Persistence: SQLite-based history with multi-device sync
  • πŸ’° Cost Control: Rate limiting, budget caps, usage monitoring
  • πŸ§ͺ 150+ Tests: Comprehensive test coverage across all components
  • πŸ“¦ Modular Design: Easy integration into any Flutter app

πŸš€ Quick Start

Installation

Add to your pubspec.yaml:

dependencies:
  step_sync_chatbot:
    path: ../path/to/packages/step_sync_chatbot

Basic Usage

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:step_sync_chatbot/step_sync_chatbot.dart';

void main() {
  runApp(
    const ProviderScope(
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              // Open chatbot with mock service
              final config = ChatBotConfig.development(
                userId: 'user123',
                useMockService: true,
              );

              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ChatScreen(config: config),
                ),
              );
            },
            child: const Text('Open ChatBot'),
          ),
        ),
      ),
    );
  }
}

Run Example App

cd packages/step_sync_chatbot
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
cd example
flutter run

Or use the batch scripts (Windows):

# From project root
run.bat
# Select option 1: Full Setup
# Then select option 4: Run Example App

πŸ“‹ Features by Phase

Phase 1: Foundation βœ…

Core Architecture & Rule-Based Intelligence

  • 🎨 Conversational UI with Material Design
  • 🧠 Rule-based intent classification (32 patterns, 12 intents)
  • πŸ’¬ Template-based response system
  • πŸ”„ Riverpod state management
  • πŸ“± Quick reply buttons and interactive messages
  • 🎯 Intent confidence scoring

Key Files: 40+ files, 3,500+ lines of code

Phase 2: Real Health SDK Integration βœ…

Production Health Data Integration

  • πŸ₯ HealthSync SDK integration
  • πŸ“Š iOS HealthKit support
  • πŸ€– Android Health Connect support
  • πŸ” Permission management
  • πŸ“ˆ Step data fetching (last 7 days)
  • πŸ”„ Data source detection
  • ⚑ Smart caching

Key Files: RealHealthService, Health Platform Adapters

Phase 3: Conversation Persistence βœ…

SQLite Database & State Persistence

  • πŸ’Ύ SQLite database (3 tables: conversations, messages, user_preferences)
  • πŸ”„ Automatic conversation saving
  • πŸ“± Multi-device sync support
  • πŸ—‚οΈ Conversation history loading
  • 🧹 Automatic cleanup (90-day retention)
  • πŸ“Š Conversation statistics
  • πŸ” Search and retrieval

Key Files: 15 tests, conversation repository implementation

Phase 4: Enhanced Diagnostics βœ…

Comprehensive System Health Checks

  • πŸ” Platform availability detection
  • βœ… Permission status checking
  • πŸ”‹ Battery optimization detection (Android)
  • πŸ“Š Data source analysis
  • 🎯 Issue severity classification (info, warning, error, critical)
  • πŸ’‘ Actionable quick replies
  • πŸ› οΈ Automatic settings navigation
  • πŸ“± Health Connect installation flow
  • 🌐 Platform-specific guidance

Key Files: 33 tests, diagnostic service, platform utilities

Phase 5: LLM Integration βœ…

AI-Powered Intelligence with Privacy

  • πŸ€– Azure OpenAI provider (HIPAA-ready)
  • πŸ”’ PHI/PII sanitization pipeline
  • 🎯 Hybrid intent routing (3-tier)
  • πŸ’¬ Conversation context management
  • πŸ’° Rate limiting & cost monitoring
  • πŸ“Š Usage statistics & analytics
  • πŸ›‘οΈ Critical PII blocking
  • πŸ§ͺ 70+ LLM-specific tests

Key Files: 11 new files, 3,200+ lines of code

πŸ—οΈ Architecture

System Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Flutter App (Host)                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚  Step Sync ChatBot      β”‚
                β”‚  Package                β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                    β”‚                    β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
   β”‚   UI    β”‚         β”‚  Core   β”‚         β”‚  Data   β”‚
   β”‚ Layer   β”‚         β”‚ Servicesβ”‚         β”‚ Layer   β”‚
   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
        β”‚                   β”‚                    β”‚
        β”‚              β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
        β”‚              β”‚  Hybrid Intent Router        β”‚
        β”‚              β”‚  (Rule β†’ ML β†’ LLM)           β”‚
        β”‚              β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                   β”‚
        β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚         β”‚         β”‚         β”‚
        β”‚    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”
        β”‚    β”‚ Rule   β”‚ β”‚ ML   β”‚ β”‚ LLM  β”‚
        β”‚    β”‚ Based  β”‚ β”‚[TODO]β”‚ β”‚Cloud β”‚
        β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”˜
        β”‚                           β”‚
        β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
        β”‚                    β”‚ PHI         β”‚
        β”‚                    β”‚ Sanitizer   β”‚
        β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Health Services                        β”‚
   β”‚  β”œβ”€ iOS HealthKit                       β”‚
   β”‚  └─ Android Health Connect              β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Intelligence Routing

User Query
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Rule-Based      β”‚  Confidence β‰₯ 0.7?
β”‚ Classification  β”‚  ────────────────► YES ─► Response (80%)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ NO
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ On-Device ML    β”‚  [TODO]
β”‚ Model           β”‚  ────────────────► YES ─► Response (15%)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ NO
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PHI Sanitizer   β”‚  Safe to send?
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ YES
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Cloud LLM       β”‚  ────────────────────► Response (5%)
β”‚ (Azure OpenAI)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Privacy Architecture

User Input: "I walked 10,000 steps yesterday on my iPhone 15"
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PHI/PII Detector                                    β”‚
β”‚ β”œβ”€ Numbers: 10,000 β†’ [NUMBER]                       β”‚
β”‚ β”œβ”€ Dates: yesterday β†’ recently                      β”‚
β”‚ β”œβ”€ Devices: iPhone 15 β†’ phone                       β”‚
β”‚ β”œβ”€ Apps: Google Fit β†’ fitness app                   β”‚
β”‚ └─ Critical PII: emails, phones, names β†’ BLOCK      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
Sanitized: "I walked [NUMBER] steps recently on my phone"
                         β”‚
                         β–Ό
                    Cloud LLM βœ…

πŸ“ Project Structure

ChatBot_StepSync/
β”œβ”€β”€ packages/
β”‚   └── step_sync_chatbot/              # Main package
β”‚       β”œβ”€β”€ lib/
β”‚       β”‚   β”œβ”€β”€ src/
β”‚       β”‚   β”‚   β”œβ”€β”€ config/             # Configuration
β”‚       β”‚   β”‚   β”œβ”€β”€ core/               # Core services
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ chatbot_controller.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ chatbot_state.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ diagnostic_service.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ intents.dart
β”‚       β”‚   β”‚   β”‚   └── rule_based_intent_classifier.dart
β”‚       β”‚   β”‚   β”œβ”€β”€ data/               # Data models & repositories
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ models/
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ chat_message.dart
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ conversation.dart
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ diagnostic_result.dart
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ permission_state.dart
β”‚       β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ step_data.dart
β”‚       β”‚   β”‚   β”‚   β”‚   └── user_preferences.dart
β”‚       β”‚   β”‚   β”‚   └── repositories/
β”‚       β”‚   β”‚   β”‚       β”œβ”€β”€ conversation_repository.dart
β”‚       β”‚   β”‚   β”‚       └── sqlite_conversation_repository.dart
β”‚       β”‚   β”‚   β”œβ”€β”€ health/             # Health SDK integration
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ health_service.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ mock_health_service.dart
β”‚       β”‚   β”‚   β”‚   └── real_health_service.dart
β”‚       β”‚   β”‚   β”œβ”€β”€ llm/                # LLM & AI
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ llm_provider.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ llm_response.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ azure_openai_provider.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ mock_llm_provider.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ hybrid_intent_router.dart
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ conversation_context.dart
β”‚       β”‚   β”‚   β”‚   └── llm_rate_limiter.dart
β”‚       β”‚   β”‚   β”œβ”€β”€ privacy/            # Privacy & security
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ pii_detector.dart
β”‚       β”‚   β”‚   β”‚   └── sanitization_result.dart
β”‚       β”‚   β”‚   β”œβ”€β”€ ui/                 # UI components
β”‚       β”‚   β”‚   β”‚   └── screens/
β”‚       β”‚   β”‚   β”‚       └── chat_screen.dart
β”‚       β”‚   β”‚   └── utils/              # Utilities
β”‚       β”‚   β”‚       └── platform_utils.dart
β”‚       β”‚   └── step_sync_chatbot.dart  # Public API
β”‚       β”œβ”€β”€ test/                       # 150+ tests
β”‚       β”‚   β”œβ”€β”€ core/
β”‚       β”‚   β”œβ”€β”€ data/
β”‚       β”‚   β”œβ”€β”€ health/
β”‚       β”‚   β”œβ”€β”€ llm/
β”‚       β”‚   └── privacy/
β”‚       β”œβ”€β”€ example/                    # Example apps
β”‚       β”‚   β”œβ”€β”€ lib/
β”‚       β”‚   β”‚   β”œβ”€β”€ main.dart           # Main example
β”‚       β”‚   β”‚   └── llm_example.dart    # LLM demo
β”‚       β”‚   └── pubspec.yaml
β”‚       β”œβ”€β”€ pubspec.yaml
β”‚       β”œβ”€β”€ QUICK_START.md
β”‚       └── README.md
β”œβ”€β”€ run.bat                             # Master batch script
β”œβ”€β”€ BATCH_SCRIPTS_GUIDE.md
└── README.md                           # This file

πŸ§ͺ Testing

Test Coverage

Component Tests Coverage
Phase 1 ~20 Core, Intents, Templates
Phase 2 ~12 Health Service Integration
Phase 3 15 SQLite Persistence
Phase 4 33 Diagnostics
Phase 5 70+ LLM & Privacy
Total 150+ Comprehensive

Run Tests

# All tests
cd packages/step_sync_chatbot
flutter test

# Specific test suite
flutter test test/core/chatbot_controller_test.dart
flutter test test/privacy/pii_detector_test.dart
flutter test test/llm/llm_rate_limiter_test.dart

# With coverage
flutter test --coverage

Using Batch Scripts (Windows)

# Quick test
packages\step_sync_chatbot\quick_test.bat

# Phase 4 tests only
packages\step_sync_chatbot\test_phase4.bat

# Full setup + test
packages\step_sync_chatbot\setup_and_test.bat

πŸ“– Documentation

Comprehensive Phase Summaries

Located in C:\Users\Vinamra Jain\Desktop\:

  • Phase3_ConversationPersistence_Summary.md - SQLite integration, conversation history
  • Phase4_EnhancedDiagnostics_Summary.md - Diagnostic system, platform detection
  • Phase5_LLM_Integration_Summary.md - LLM providers, privacy, rate limiting

Quick References

  • QUICK_START.md - Get started in 5 minutes
  • BATCH_SCRIPTS_GUIDE.md - Windows automation scripts
  • packages/step_sync_chatbot/README.md - Package documentation

API Documentation

Generate API docs:

cd packages/step_sync_chatbot
dart doc .
# Open doc/api/index.html

πŸ” Privacy & Security

Privacy Guarantees

We NEVER send to cloud LLM:

  • ❌ Exact step counts (10,000 steps)
  • ❌ Specific dates (yesterday, Monday, 2024-01-15)
  • ❌ App names (Google Fit, Samsung Health)
  • ❌ Device models (iPhone 15, Galaxy S24)
  • ❌ User names (John Smith)
  • ❌ Email addresses (john@example.com)
  • ❌ Phone numbers (123-456-7890)
  • ❌ Location data

We DO send (sanitized):

  • βœ… Generic references: "[NUMBER] steps", "recently", "fitness app", "phone"
  • βœ… Non-specific problems: "Steps not syncing", "Need help with permissions"

HIPAA-Aware Design

  1. PHI Sanitization: Multi-layer detection and removal
  2. Critical PII Blocking: Emails, phones, names block sending entirely
  3. Azure OpenAI BAA: Business Associate Agreement available
  4. Audit Logging: All LLM calls tracked (optional)
  5. Data Encryption: At rest and in transit
  6. User Control: Delete data, export data, disable features

Security Best Practices

// βœ… GOOD: Secure API key storage
final provider = AzureOpenAIProvider(
  apiKey: await SecureStorage.getApiKey(),
  endpoint: await SecureStorage.getEndpoint(),
);

// ❌ BAD: Hardcoded secrets
final provider = AzureOpenAIProvider(
  apiKey: 'sk-1234567890...', // NEVER DO THIS!
);

πŸ’° Cost Analysis

LLM Pricing (GPT-4o-mini)

Metric Cost
Input tokens $0.150 per 1M
Output tokens $0.600 per 1M
Typical query $0.001-0.005
Average $0.0002

Monthly Projections

Daily Users LLM Queries (5%) Monthly Cost
1,000 150/day $9
10,000 1,500/day $90
100,000 15,000/day $900

Cost Controls

  • βœ… Rate limiting: 50 calls/user/hour
  • βœ… Global caps: 100 calls/hour
  • βœ… Budget enforcement: $10/hour max
  • βœ… Hybrid routing: 80% free (rule-based)
  • βœ… Context pruning: Max 10 messages

πŸ› οΈ Development

Prerequisites

  • Flutter 3.10+
  • Dart 3.0+
  • Android Studio / VS Code
  • iOS development (macOS only)

Setup

# Clone repository
git clone <repository-url>
cd ChatBot_StepSync

# Install dependencies
cd packages/step_sync_chatbot
flutter pub get

# Generate code (Freezed models)
flutter pub run build_runner build --delete-conflicting-outputs

# Run tests
flutter test

# Run example
cd example
flutter run

Using Batch Scripts (Windows)

# Master menu
run.bat

# Full setup
packages\step_sync_chatbot\setup_and_test.bat

# Clean rebuild
packages\step_sync_chatbot\clean_and_rebuild.bat

🎨 Customization

Theme Customization

final config = ChatBotConfig(
  userId: 'user123',
  theme: ChatBotTheme(
    primaryColor: Colors.blue,
    userMessageColor: Colors.blue[100],
    botMessageColor: Colors.grey[200],
    backgroundColor: Colors.white,
  ),
);

LLM Provider Customization

// Use Azure OpenAI
final azureProvider = AzureOpenAIProvider(
  endpoint: 'your-endpoint.openai.azure.com',
  apiKey: 'your-api-key',
  deploymentName: 'gpt-4o-mini',
  maxTokens: 500,
  temperature: 0.7,
);

// Or use Mock LLM for development
final mockProvider = MockLLMProvider(
  simulatedDelayMs: 800,
);

// Configure router
final router = HybridIntentRouter(llmProvider: azureProvider);

Conversation Templates

// Add custom intents
enum UserIntent {
  // ... existing intents
  customIntent,
}

// Add custom templates
class ConversationTemplates {
  static const templates = {
    UserIntent.customIntent: 'Your custom response here',
  };
}

🚒 Deployment

Production Checklist

  • Configure Azure OpenAI with HIPAA BAA
  • Set up secure API key storage
  • Enable conversation persistence
  • Configure rate limiting
  • Set up monitoring and alerting
  • Test on iOS and Android devices
  • Verify PHI sanitization
  • Review privacy policy
  • Run full test suite
  • Performance testing
  • Security audit

Environment Configuration

// Development
final devConfig = ChatBotConfig.development(
  userId: userId,
  useMockService: true,
  enablePersistence: false,
);

// Production
final prodConfig = ChatBotConfig.production(
  userId: userId,
  healthService: RealHealthService(),
  conversationRepository: SQLiteConversationRepository(),
  llmProvider: AzureOpenAIProvider(...),
  enablePersistence: true,
);

πŸ“Š Analytics & Monitoring

Built-in Metrics

// LLM usage statistics
final stats = rateLimiter.getStats();
print('Calls: ${stats.callsInLastHour}');
print('Cost: \$${stats.totalCostUSD.toStringAsFixed(4)}');
print('Avg response time: ${stats.averageResponseTimeMs}ms');

// User-specific stats
final userStats = rateLimiter.getUserStats(userId);
print('User calls: ${userStats.callsInLastHour}');
print('Remaining: ${userStats.remainingCallsThisHour}');

// Conversation statistics
final convStats = await repository.getStats(userId);
print('Total conversations: ${convStats.totalConversations}');
print('Total messages: ${convStats.totalMessages}');

Routing Strategy Tracking

final router = HybridIntentRouter(...);
final result = await router.route(userInput);

// Track which strategy was used
switch (result.strategyUsed) {
  case RoutingStrategy.ruleBased:
    analytics.logEvent('rule_based_classification');
  case RoutingStrategy.cloudLLM:
    analytics.logEvent('llm_classification', {
      'cost': result.llmResponse?.estimatedCost,
      'tokens': result.llmResponse?.totalTokens,
    });
}

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Write/update tests
  5. Run tests (flutter test)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Code Style

  • Follow Effective Dart guidelines
  • Use flutter format . before committing
  • Add documentation comments for public APIs
  • Write tests for new features
  • Update README if adding new features

Testing Guidelines

  • Maintain 80%+ test coverage
  • Write unit tests for business logic
  • Write integration tests for UI flows
  • Test privacy sanitization thoroughly
  • Test error handling and edge cases

πŸ› Troubleshooting

Common Issues

Issue: Tests failing after setup

# Solution: Clean and rebuild
flutter clean
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter test

Issue: "Flutter not found" in batch scripts

# Solution: Add Flutter to PATH
# Windows: System Properties β†’ Environment Variables β†’ PATH
# Add: C:\flutter\bin (or your Flutter installation path)

Issue: Health Connect not working on Android

# Solution: Check Android version
# Android 14+: Built-in
# Android 9-13: Install Health Connect from Play Store
# Android 8-: Not supported

Issue: LLM responses not working

// Solution: Check configuration
final provider = AzureOpenAIProvider(
  endpoint: 'https://...',  // Must be HTTPS
  apiKey: 'valid-key',      // Must be valid
  deploymentName: 'gpt-4o-mini', // Must exist
);

// Verify availability
final available = await provider.isAvailable();
print('Provider available: $available');

Debug Mode

// Enable verbose logging
final config = ChatBotConfig(
  debugMode: true,  // Prints detailed logs
);

// Check conversation context
print(context.getSummary());

// Check sanitization
final result = detector.sanitize(input);
print('Original: ${result.originalText}');
print('Sanitized: ${result.sanitizedText}');
print('Safe: ${result.isSafe}');
print('Entities: ${result.detectedEntities}');

πŸ“œ License

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

πŸ™ Acknowledgments

  • Flutter Team - Amazing framework
  • Riverpod - State management
  • Freezed - Code generation
  • Azure OpenAI - LLM provider
  • Health Sync SDK - Health data integration

πŸ—ΊοΈ Roadmap

Phase 6: On-Device ML (Planned)

  • DistilBERT model integration
  • TensorFlow Lite conversion
  • On-device intent classification
  • Offline capability
  • A/B testing infrastructure

Future Enhancements

  • Voice input support
  • Multi-language support
  • Advanced analytics dashboard
  • Webhook integrations
  • Custom action handlers
  • Real-time collaboration
  • Admin dashboard

πŸ“ˆ Stats

  • Total Code: ~15,000 lines
  • Total Tests: 150+
  • Test Coverage: 85%+
  • Packages: 1 main package
  • Dependencies: 12 core dependencies
  • Platforms: iOS, Android, Web, Desktop (Flutter support)
  • Development Time: 5 phases
  • Documentation: 3 comprehensive phase summaries

Made with ❀️ HCL Healthcare Product Team

Version: 0.5.0 Last Updated: January 12, 2026 Status: Production Ready βœ…

About

An intelligent, privacy-first conversational AI assistant for troubleshooting step tracking issues across iOS (HealthKit) and Android (Health Connect) health platforms - by HCL Healthcare Product Team

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •