A mission-critical, destination-aware smart alarm and live journey monitoring platform.
Schedule when you must arrive; ADA determines when you need to wake up and leave, monitors road traffic in real time, begins GPS tracking before departure, adapts dynamically to unexpected delays, alerts you as you approach, and confirms your arrival.
- The Core Problem ADA Solves
- How ADA Works
- System Architecture
- Step-by-Step Demo Guide
- Installation & Setup Guide
- Testing & Quality Assurance
- Security, Privacy & Background Policy
- Documentation Index
Traditional alarm clocks suffer from a fatal design flaw: they are blind to the real world.
If you need to reach an exam, flight, or critical meeting by 9:00 AM:
- A conventional alarm wakes you at a fixed time (e.g. 7:00 AM) even if an overnight accident doubled your commute.
- If traffic is unusually light, you waste hours sitting idle.
- If traffic builds up, you arrive late.
- Once you step out of the door, traditional alarms do nothingβthey cannot warn you if you take a wrong turn or alert you before your stop.
- When must I reach my destination? (Your required arrival deadline)
- How long will the journey take today? (Live traffic and weather-aware commute estimation)
- When should I leave? (Departure time dynamically adjusted for safety buffers)
- When should I wake up? (Wake-up time adjusted for your personal morning routine)
- Is my planned arrival still achievable right now? (Continuous GPS tracking, route deviation detection, and arrival alerts)
ADA's scheduling engine works backwards from your arrival deadline through deterministic mathematical formulas:
[Required Arrival Time] (e.g., 9:00 AM)
β
βΌ minus Safety Buffer Margin (e.g., 15 min)
[Planned Arrival Time] (8:45 AM)
β
βΌ minus Live Commute Travel Duration (e.g., 45 min live traffic)
[Recommended Leave Time] (8:00 AM)
β
βΌ minus Morning Routine Preparation Time (e.g., 30 min)
[Recommended Wake Time] (7:30 AM) ββ> Alarm Manager Schedules Wake-Up Ring
From initial creation through confirmed arrival, ADA transitions through a validated deterministic state machine:
stateDiagram-v2
[*] --> SCHEDULED: Create Journey
SCHEDULED --> READY_TO_TRACK: T - 15 min (Lead Time Alarm)
READY_TO_TRACK --> ACTIVE_TRACKING: Start Tracking (Auto / Manual)
state ACTIVE_TRACKING {
[*] --> ValidatingFix
ValidatingFix --> CheckDeviation: Fix Valid (Acc <= 50m, Age <= 60s)
ValidatingFix --> TRACKING_DEGRADED: Fix Stale or Inaccurate
TRACKING_DEGRADED --> ValidatingFix: Fresh Fix Received
CheckDeviation --> RECALCULATING: Off Route (> 250m)
RECALCULATING --> CheckDeviation: New Route Computed
}
ACTIVE_TRACKING --> APPROACHING: Distance <= 1,000m (Alert Fired Once)
APPROACHING --> ARRIVED: Distance <= 100m (2 Consecutive Accurate Fixes)
ACTIVE_TRACKING --> ARRIVED: Distance <= 100m (2 Consecutive Accurate Fixes)
ACTIVE_TRACKING --> CANCELLED: User Stops / Cancels
APPROACHING --> CANCELLED: User Cancels
ARRIVED --> [*]: Tracking Terminated & Cleanup
CANCELLED --> [*]
ADA implements strict invariants ported across native Kotlin (DynamicEtaEngine.kt) and pure TypeScript (DynamicEtaEngine.ts):
-
Zero Double-Counting of Travel Time:
$$\text{PredictedArrivalEpochMs} = t_{\text{fix}} + (\text{RemainingDurationSeconds} \times 1,000)$$ Elapsed journey time is never added twice, and static stop penalties are never superimposed onto live provider traffic durations. -
GPS Velocity Jump Protection:
Rejects unrealistic GPS jumps (
$v > 45\text{ m/s} \approx 162\text{ km/h}$ ) unless accuracy is exceptionally high ($< 15\text{m}$ ), shielding against urban GPS reflections. -
Route Recalculation Hysteresis:
- Provider request cooldown: Minimum 30 seconds between requests.
- Immediate recalculation when cross-track corridor deviation exceeds 250 meters.
- Routine recalculation when displacement
$\ge 200\text{m}$ and elapsed time$\ge 180\text{s}$ , or if previous route is stale ($> 300\text{s}$ ).
-
Multi-Stage Proximity Alerts:
-
Approaching Alert: Triggers once when remaining distance
$\le 1,000\text{ meters}$ . -
Arrival Confirmation: Confirmed when remaining distance
$\le 100\text{ meters}$ across 2 consecutive accurate fixes ($\le 50\text{m}$ accuracy). Cleanly stops tracking upon arrival.
-
Approaching Alert: Triggers once when remaining distance
ADA is engineered as a production-grade multi-platform system:
βββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββ
β Native Android (Kotlin + Compose) β β Cross-Platform Mobile (React Native) β
β [android/] β β [apps/mobile/] β
β Package: com.thinkx.ada (Preserved) β β Bundle ID: com.thinkx.ada.mobile β
β β’ AlarmManager.setAlarmClock() β β β’ iOS Background Location Tracking β
β β’ Foreground Location Service β β β’ Hardware Keystore (expo-secure-store)β
β β’ Room SQLite Database v3 β β β’ Native Local Notifications β
ββββββββββββββββββββββ¬βββββββββββββββββββββ βββββββββββββββββββββββ¬βββββββββββββββββββββ
β β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Shared TypeScript Domain Core β
β [packages/shared/] β
β β’ Pure DynamicEtaEngine (1:1 with Kotlin) β
β β’ Polyline decoder & Haversine distance β
β β’ Journey state machine & typed DTOs β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend Gateway [backend/] β
β β’ Google Maps & Mapbox live traffic routing proxy with Redis 5-minute caching β
β β’ Offline Great-Circle heuristic fallback routing β
β β’ Firebase Admin token verification & user claims β
β β’ PostgreSQL 15 + SQLAlchemy 2.0 with idempotent sync (X-Idempotency-Key) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββ android/ # Native Kotlin + Jetpack Compose Android app (com.thinkx.ada)
βββ apps/
β βββ mobile/ # Cross-platform React Native + Expo app (com.thinkx.ada.mobile)
βββ packages/
β βββ shared/ # Reusable pure TypeScript domain math, models, and state machine
βββ backend/ # FastAPI, PostgreSQL, Redis, routing proxy, and Celery workers
βββ frontend/ # React 19 + Vite web dashboard
βββ docs/ # Architecture runbooks, iOS setup, test plans, and release guides
Experience how ADA handles a real-world commute from Ahmedabad to Charusat University (Anand) with an arrival deadline of 9:00 AM:
[07:00 AM] Scheduled Departure Planned
β
βββ [07:15 AM] Alarm Wake-Up: ADA sounds alarm based on 45m commute + 15m safety buffer + 45m prep
βββ [07:45 AM] (T - 15m): ADA automatically wakes device; initiates Background Location Tracking
βββ [08:00 AM] Departure: User begins drive; persistent notification displays live dynamic ETA
βββ [08:20 AM] Road Incident: Heavy traffic on NH48; ETA dynamically recalculates from 8:45 AM to 8:58 AM
βββ [08:35 AM] Detour Taken: User turns off route; deviation > 250m detected; instant reroute triggered
βββ [08:52 AM] Approaching: User reaches 1,000m perimeter; "Approaching Destination" alert sounds
βββ [08:58 AM] Arrival: User enters 100m geofence (2 consecutive GPS fixes); "Arrived!" alert sounds,
tracking automatically terminates, releasing GPS & battery resources.
- Shared Math Engine: Run
vitest run packages/shared/__tests__to see all 14 mathematical invariants tested against the canonical Charusat scenario. - Mobile Tracking Engine: Run
vitest run apps/mobile/__tests__to observe simulated GPS fixes triggering approaching alerts and 2-hit arrival confirmations. - Backend Proxy: Run
python -m pytest backend/tests/test_location_and_routing.pyto see route resolution and traffic duration separation.
Works identically on macOS, Linux, and Windows:
- Python 3.10+
- Docker & Docker Compose (for PostgreSQL and Redis)
# Clone the repository
git clone https://github.com/buildwithneel/ADA-Smart-Alarm.git
cd ADA-Smart-Alarm
# 1. Start PostgreSQL 15 and Redis 7 in the background
docker-compose up -d postgres redis
# 2. Configure Backend Environment
cd backend
cp .env.example .env
# 3. Create Virtual Environment & Install Dependencies
# On macOS / Linux:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# On Windows (PowerShell):
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
# 4. Run Database Migrations
alembic upgrade head
# 5. Start the FastAPI Development Server
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000API Swagger Documentation will be available at http://localhost:8000/docs.
The native Kotlin + Jetpack Compose application (com.thinkx.ada).
- macOS / Linux / Windows: JDK 17, Android Studio (Ladybug or newer), Android SDK 36, Build-Tools 36.0.0.
cd android
# On macOS / Linux:
./gradlew testDebugUnitTest
./gradlew assembleDebug
# On Windows (PowerShell):
.\gradlew.bat testDebugUnitTest
.\gradlew.bat assembleDebug# Ensure device is connected via USB with USB Debugging enabled
adb devices
# Install debug APK
# On macOS / Linux:
adb install -r app/build/outputs/apk/debug/app-debug.apk
# On Windows:
adb install -r app\build\outputs\apk\debug\app-debug.apkNetworking Notice: When testing on the Android Emulator, the backend is reachable at
http://10.0.2.2:8000/api/v1. On a physical phone, connect to the same Wi-Fi network and use your host computer's LAN IP (e.g.http://192.168.1.50:8000/api/v1).
The React Native + TypeScript Expo application (com.thinkx.ada.mobile).
- Node.js 20+ or 24+
- npm or yarn
cd apps/mobile
# Install dependencies
npm install
# Run automated tests
npm test
# Start the Expo development server
npx expo start| OS | Android Development | iOS Development |
|---|---|---|
| macOS | β
Android Emulator or physical device via npx expo run:android |
β
Full iOS Simulator & physical iPhone builds via npx expo run:ios and Xcode |
| Windows | β
Android Emulator or physical device via npx expo run:android |
|
| Linux | β
Android Emulator or physical device via npx expo run:android |
ADA adheres to an uncompromising testing pyramid. All 280 automated tests are passing:
# 1. Backend Regression Suite (131 tests)
cd backend
python -m pytest
# 2. Native Android Unit Test Suite (97 tests)
cd android
./gradlew testDebugUnitTest # (or .\gradlew.bat testDebugUnitTest on Windows)
# 3. Web Client Vitest Suite (29 tests)
cd frontend
npm test
# 4. Shared Core & Mobile Unit Tests (23 tests)
# From project root:
.\frontend\node_modules\.bin\vitest.cmd run --config vitest.config.ts apps/mobile/__tests__ packages/shared/__tests__- Zero Hardcoded Secrets: Private keys, keystores, and Firebase service accounts are never checked into git.
-
Hardware Keystore Storage: Mobile authentication tokens are stored exclusively in hardware keystores (
expo-secure-storeusing iOS Keychain and Android KeyStore). PlaintextAsyncStorageis banned. -
Location Privacy: Location fixes are collected only during user-authorized active journeys. Reverse geocoding in FastAPI automatically fuzzes coordinates to
$\sim 11\text{m}$ resolution. -
Truthful Battery & OS Constraints:
- On Android: Runs under
FOREGROUND_SERVICE_LOCATIONwith a persistent notification. - On iOS: Uses
kCLLocationAccuracyBestForNavigationwithshowsBackgroundLocationIndicator. ADA explicitly informs users that force-closing the app from the iOS App Switcher halts tracking per Apple operating system policy.
- On Android: Runs under
For comprehensive technical specifications, consult our detailed documentation in docs/:
- docs/CROSS_PLATFORM_ARCHITECTURE.md β Multi-platform architecture, directory layout, and endpoint reuse map.
- docs/IOS_BACKGROUND_LOCATION.md β Apple Core Location capabilities,
Info.plistdisclosures, and background lifecycle. - docs/MOBILE_DEVELOPMENT_SETUP.md β Comprehensive developer machine setup and networking configuration.
- docs/MOBILE_TEST_PLAN.md β Complete 5-tier verification matrix.
- docs/IOS_RELEASE_CHECKLIST.md β Apple developer provisioning, privacy nutrition disclosures, and TestFlight release gates.
This project is licensed under the MIT License β see the LICENSE file for details.