// The Origin: Why build another screen time app?
This project is my brainchild, born from watching how many people—especially youth and children—waste their valuable time and energy doomscrolling. Modern social media algorithms are engineered to optimize for engagement, often making toxic behavior and negative emotions look "cool" just to keep users hooked. The physical and psychological harms of this addiction triggered me to create a solution. I didn't want to build just another dumb app blocker; those just cause frustration and are easily bypassed. I wanted an active countermeasure with a personal feel—something that gives users a scientifically proven reason, and a better alternative, every single time they try to open a social app out of pure habit.
Want to experience the real-time sensor fusion and interactive coaching firsthand? [Download the latest Android APK here](#).
// The Interface: What does it look like?
The interface is designed using a custom "Cyber-Arctic" dark theme built natively in Jetpack Compose. Instead of nesting insights deeply within endless settings pages, everything is exposed cleanly via an intuitive Bento-box layout and floating system-level overlays.

// Why does digital wellness need AI?
Standard screen-time limits fail because they are entirely punitive. When a timer hits zero, an app blocks you, your brain craves the interrupted dopamine loop, and you immediately look for a way to override it. This is why I introduced **Neo**, a friendly AI bot powered by Gemini 2.5 Flash. Neo’s job is to keep you accountable with a personal touch. When you cross a distraction limit, Neo doesn't just lock your phone; he provides evidence-backed health tips and better alternatives tailored to exactly what your body is experiencing in that moment.

// Does running continuous camera scans drain the battery?
This was one of the biggest engineering hurdles. Keeping an Android front-facing camera powered on indefinitely will rapidly drain the battery and cause the phone to overheat. To solve this, MindfulFlow relies on strict camera duty-cycling handled by a persistent `ContextEngineService`. Instead of running the camera permanently, it utilizes a lightweight 5-second polling loop to evaluate app usage. The actual camera analysis is restricted to short, strategic windows (15 seconds ON, followed by a variable OFF duration). Furthermore, this is completely **motion-gated**—if the IMU sensors detect that the phone is perfectly stationary or face-down, the camera framework is instantly put to sleep.
// Are the posture and blink rate metrics actually accurate?
Tracking posture with a phone camera is notoriously unreliable because the phone itself is constantly moving. If you lie back on a couch, a standard face-detection algorithm will incorrectly assume you are looking straight up at the ceiling. To fix this, I engineered a **Posture Fusion Engine**. It calculates an absolute head angle relative to the world frame by mathematically isolating the phone's movement from your skull's movement. It queries the ML Kit Face Detection API for your head pitch ($Camera\ \theta_x$) and subtracts the hardware IMU Rotation Vector sensor ($IMU\ \theta_{tilt}$) using this core formula: $P_{abs} = Camera\ \theta_x - IMU\ \theta_{tilt} - 90^\circ$ This establishes a "True Horizon," making the posture tracking immune to device tilt. This is combined with a 468-point face mesh that tracks your Eye Aspect Ratio (EAR) to compute a highly accurate Blinks-Per-Minute (BPM) value.
// Calculates absolute head pitch independent of phone tilt
fun calculateTrueHorizon(cameraEulerX: Float, imuTiltAngle: Float): Float {
// Fuses camera pitch and physical device rotation vector
val absolutePitch = cameraEulerX - imuTiltAngle - 90f
// Apply motion-gated debouncing to prevent flickering states
return applyHysteresis(absolutePitch)
}

// Are the intervention methods effective? Do they really change habits?
Habits are broken by inserting intentional cognitive friction into subconscious routines. When you open a social media application out of pure muscle memory, MindfulFlow deploys a system-level overlay accompanied by distinct haptic vibration patterns. Rather than instantly killing the app, the interface introduces a 3-step friction pattern: an initial confirmation prompt, a manual timer commitment selection, and an intentional "Go Home" escape hatch. By forcing your brain out of autopilot and requiring physical touch confirmation, the app systematically fragments the neurological cue-routine-reward cycle of digital addiction.
// How technically backed is the architecture?
Because MindfulFlow processes physiological data, privacy and performance are non-negotiable. All machine learning pipelines run 100% locally on-device. Camera frames are processed strictly in volatile memory and destroyed immediately. No imagery is ever saved or uploaded.

The architecture relies on a single-activity MVVM pattern. The `ContextEngineService` orchestrates the hardware sensors and pushes data into the `InterventionManager`—a centralized Kotlin Singleton serving as the single source of truth via `StateFlow`. When network availability drops, an asynchronous Outbox Repository queues daily aggregations and posture snapshots locally, draining seamlessly to Firebase Firestore once a connection is re-established.
// What is the future roadmap?
The next major phase for MindfulFlow is shifting from reactive tracking to proactive behavioral planning. I am currently building a local journaling and goal-tracking engine directly into the app. Once integrated, Neo will have access to your actual daily tasks and life goals. Instead of just reacting to screen time numbers, the AI will understand your intent. It will know exactly when it is appropriate to strictly block a distraction, and when to gently remind you about the goals you set for yourself, offering a much more personalized and human approach to digital wellness.