Skip to content

arjunadhikary/PillReminder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’Š PillReminder - Offline-First Medication Management

A multimodal AI system to digitize medication instructions with 100% offline reliability, mitigating clinical errors in low-resource settings.

πŸ† Winner: Best Poster Presenter, NIRAMAYA Conference (2026)

🌟 Key Features

πŸ”’ Edge-First AI Architecture

  • 100% Offline Processing - Works perfectly without internet connection
  • Instant Results - <1 second processing time
  • Privacy-First - All data stays on your device by default
  • Zero Cost - No API charges for normal operation

πŸ€– Advanced AI Stack

  • Dual-Layer Offline Pipeline - Combines ML Kit for text recognition with a custom computer vision validation module.
  • Interpretable Computer Vision - Hand-engineered marker detection using dual-axis spatial projection histograms, adaptive ROI localization (silver foil segmentation), and valley-splitting peak detection.
  • Gemini 2.0 Flash - Optional cloud enhancement for complex cases
  • TensorFlow.js - 1024-dimensional visual embeddings for medication matching
  • Fuzzy Matching - Spell-corrects OCR errors against medication database

πŸ“± Smart Features

  • Multi-image scanning (front + back of packaging)
  • Handwritten dosage detection (circles, loops, marks)
  • Grid layout detection (2x5, 3x7, etc.)
  • Visual medication matching
  • Nepali/English support
  • Medication reminders & scheduling

🌐 Multilingual Support

  • English - Full support
  • Nepali - Full support (Devanagari script)
  • Dosage pattern detection for both languages
  • Context-aware timing extraction ("ΰ€–ΰ€Ύΰ€¨ΰ€Ύ ΰ€ͺΰ€›ΰ€Ώ" / "after food")

πŸ” Privacy & Security

  • βœ… Offline-first: No data sent to cloud by default
  • βœ… Local storage: All medications stored on-device
  • βœ… No tracking: No analytics or telemetry
  • βœ… Optional cloud: Explicit user consent required
  • βœ… Medical data: Complies with privacy best practices

πŸ—οΈ Architecture

Dual-Layer Offline Processing Flow

πŸ“Έ Scan Blister Pack Image
   ↓
πŸ” Layer 1: ML Kit OCR (Extract Text / Brand / Instructions)
   ↓
πŸ‘οΈ Layer 2: Custom CV Validation (Spatial Histograms for Handwritten Marks)
   ↓
🧠 Offline Parser + Fuzzy Matching (Reconcile OCR & CV outputs)
   ↓
βœ… Return Results (<1 second total)
   ↓
πŸ’Ύ Save to Local Database (WatermelonDB)

Optional Cloud Enhancement

// For complex cases, users can manually enhance:
import { enhanceWithCloudAI } from '@/services/ai/ocr';

const enhanced = await enhanceWithCloudAI(imageUri, currentData);
console.log(`Confidence improved by ${(enhanced.confidence - currentData.confidence) * 100}%`);

πŸ› οΈ Technology Stack

Core Framework

  • React Native - Cross-platform mobile framework
  • Expo - Development tooling and SDK
  • TypeScript - Type-safe JavaScript
  • Expo Router - File-based navigation

AI/ML

  • @google/generative-ai - Gemini 2.0 Flash (optional cloud)
  • @tensorflow/tfjs - Machine learning in JavaScript
  • @tensorflow/tfjs-react-native - TensorFlow for React Native
  • @react-native-ml-kit/text-recognition - Offline OCR

State & Data

  • @nozbe/watermelondb - Offline-first reactive database
  • zustand - Lightweight state management
  • @react-native-async-storage/async-storage - Persistent storage

UI/UX

  • nativewind - Tailwind CSS for React Native
  • react-native-reanimated - Smooth animations
  • expo-notifications - Local medication reminders
  • expo-haptics - Tactile feedback

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Expo CLI
  • iOS Simulator or Android Emulator (or physical device)

Installation

  1. Clone and install dependencies

    cd PillReminder
    npm install
  2. Start the development server

    npx expo start
  3. Run on device

    • Press i for iOS simulator
    • Press a for Android emulator
    • Scan QR code with Expo Go app on physical device

πŸ“ Environment Variables

Create a .env file in the root directory:

# Optional: Only needed if enabling cloud enhancement
EXPO_PUBLIC_GEMINI_API_KEY=your_api_key_here

Note: App works fully without this key (offline-only mode).


🎯 AI Configuration

Default Settings

// services/ai/config.ts
const DEFAULT_CONFIG = {
    processingMode: 'offline-only',    // No cloud by default
    logPerformance: true,               // Track processing times
    trackOfflineAccuracy: true,         // Collect data for model training
};

Enable Cloud Enhancement

import { setAIConfig } from '@/services/ai/config';

await setAIConfig({
    processingMode: 'allow-cloud-enhancement'
});

πŸ§ͺ Testing Offline Mode

Verify 100% Offline Reliability

  1. Enable airplane mode on your test device
  2. Open PillReminder app
  3. Scan a medication image
  4. Verify instant results without errors

Expected: Processing completes in <1 second with no network errors.


πŸ“‚ Project Structure

PillReminder/
β”œβ”€β”€ app/                    # Expo Router screens
β”‚   β”œβ”€β”€ camera.tsx         # Medication scanning
β”‚   β”œβ”€β”€ modal.tsx          # Add/edit medication
β”‚   β”œβ”€β”€ alarm.tsx          # Medication reminders
β”‚   └── ...
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ ai/
β”‚   β”‚   β”œβ”€β”€ ocr.ts         # Main AI processing (offline-first)
β”‚   β”‚   β”œβ”€β”€ config.ts      # AI preferences & metrics
β”‚   β”‚   β”œβ”€β”€ vision-matcher.ts  # 1024-dim embeddings
β”‚   β”‚   β”œβ”€β”€ marker-detector.ts # Handwriting CV
β”‚   β”‚   β”œβ”€β”€ offline-parser.ts  # Text parsing
β”‚   β”‚   └── medication-db.ts   # Fuzzy matching
β”‚   β”œβ”€β”€ db/                # WatermelonDB models
β”‚   └── scheduler.ts       # Notification scheduling
β”œβ”€β”€ components/            # Reusable UI components
└── lib/                   # Utilities & state

πŸ“Š Performance Metrics

Metric Target Actual
Processing Time (Offline) <1s ~800ms ⚑
Processing Time (Online) <5s ~3-4s
Offline Accuracy (Simple) >80% ~85%
Offline Accuracy (Complex) >70% ~75%
Cloud Accuracy >90% ~95%

Metrics tracked automatically via config.ts


πŸ”¬ Future Enhancements

Model Fine-Tuning

The app tracks offline processing metrics for future improvements:

// Automatically logged
interface ProcessingMetrics {
    timestamp: number;
    processingTime: number;
    confidence: number;
    mode: 'offline' | 'online';
    medicationName: string;
}

Roadmap:

  1. Collect 1000+ medication scans with user corrections
  2. Train specialized OCR model for medication packaging
  3. Fine-tune handwriting detection for local practices
  4. Deploy updated TensorFlow.js model

πŸ› Troubleshooting

Camera not working

# iOS: Rebuild with camera permissions
npx expo prebuild --clean
npx expo run:ios

Slow processing

  • Check device specs (needs TensorFlow.js support)
  • Reduce image size in camera settings
  • Verify ML Kit is installed correctly

TypeScript errors

# Rebuild with proper types
rm -rf node_modules
npm install
npx expo start --clear

πŸ“„ License

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


πŸ™ Acknowledgments

  • Google Gemini - Multimodal AI capabilities
  • TensorFlow.js - Edge ML framework
  • ML Kit - Fast offline OCR
  • Expo - Development platform

πŸ“§ Contact

For questions, support, or to contribute, please visit the GitHub Repository and open an issue.


Built with ❀️ for improving medication safety in low-resource settings

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors