devlog

I Built an App to Track My Poop (And Learned a Lot About Health)

Okay. Let’s talk about poop.

I love taking a dump early in the morning right after waking up, and I know you do too, be it early morning or after a cup of black coffee. Maybe after the gym too idk how your routine is.

I don’t recall when I actually got this idea but I do recall watching a Matt D’Avella video where he timed everything, in sorts of an experiment king of, not sure I can go back and check it out but will just try to keep everything from memory. 1

Everybody that knows me says I spend a lot of time in the toilet, I would disagree because I listen to music in the toilet and when I do I usually last around 3 tracks maximum and 1 track if I’m taking the rollercoaster down town, but without hoping around, lets get to the poop app, why did I make it? still don’t have a concrete reason and I do not believe I do so too.

So one again, Lets get talking about poop but not in a gross way in a data way. Because when you actually sit down (pun intended) and think about it, your bowel patterns are one of the richest, most underutilized health signals your body produces. Daily. Reliably. Without fail. ( this is me selling it to you, and actually it do be true too )

So with the aid of a fuck load of agents and some couple prompting and architectural structuring or so I hope I built bowels it is a mobile app that tracks bowel and urine sessions, correlates them with daily health inputs, and predicts when you’re likely to go next.

This is the story of building it, the algorithm that powers the predictions, and why I think the humble toilet log could become the foundation of a full personal health ecosystem.

This is going to be a long piece, it’s even taken me days to get this down with work and what not, so I would recommended taking breaks in between and getting back to it, or just skipping to the parts your curious about using the table of contents.


Why Even Build This?

Every had diarrhea? Every had digestion issues?

Here’s the thing nobody tells you: your gut is not only just a tube that processes food. It’s a sensitive system that mirrors everything else going on in your body. Bad sleep? Your gut knows. Stressed at work? Your gut feels it. Too much coffee? Your gut is very aware. And trust me I’ve been there.

The problem is that most people don’t track this data, and why should they? who would go to take a dump and start tracking information about their dump sessions? and even if they do, it’s usually when something has gone wrong and they’re trying to explain it to a doctor from memory. “Uhh… I think it’s been normal? Maybe a bit off last week?”

I wanted to change that. Track it passively, surface patterns automatically, and give people a real-time picture of their gut health without making it feel clinical or gross. Would have been a nice twist to include a camera feature and say take of photo of your dump but hey, wanted to be at least a bit more serious on this one.


The Architecture: Simple, Local, Fast

Before getting to the fun algorithm stuff, here’s the boring but important foundation.

graph TD
    A[User Logs Session] --> B[SQLite on Device]
    C[Daily Health Check] --> B
    B --> D[Analytics Engine]
    D --> E[Prediction Algorithm]
    D --> F[Insight Engine]
    D --> G[Weekly Wrapped]
    E --> H[Home Screen Badge]
    F --> H

Everything lives on device. No cloud, no accounts, no syncing your poop data to a server somewhere. SQLite via expo-sqlite handles persistence. Three main tables:

  • sessions — each bathroom visit with timestamps and duration
  • session_answers — per-session metadata: stool type (Bristol Scale 1–7), pain level, urgency, blood, completion, tags
  • daily_health — daily snapshot: water, fiber, meals, stress, sleep, exercise, caffeine, alcohol, medication, mood

The schema is intentionally flat. No joins needed for most reads, which keeps the analytics fast.


What Gets Tracked & Why It Matters

Each session captures both the event and the context. Context is what makes the data meaningful. Because without the context why would you want a list of your visits to the toilet? I mean I wouldn’t mind but enough talking and lets get to it.

Session-level data:

Field Why
Stool type (Bristol 1–7) Transit time proxy — Type 1–2 = constipation, Type 6–7 = diarrhea
Duration Long sessions may indicate straining or incomplete evacuation
Urgency (1–5) High urgency repeatedly = possible sensitivity or gut-brain axis response
Blood Red flag. Should always be surfaced.
Pain level None / mild / moderate / severe
Adaptive tags Bloating, straining, gas

Daily health context:

mindmap
  root((Daily Health))
    Intake
      Water
      Fiber
      Meals
      Caffeine
      Alcohol
    Body State
      Sleep
      Exercise
      Medication
    Mental
      Stress
      Mood

These 10 variables get correlated against session quality. The insight engine looks back 7 days and flags patterns. High caffeine + loose stools repeatedly? The app will tell you. Poor sleep 4+ days + irregular patterns? It knows.


The Bristol Stool Scale: Your Gut’s Report Card

Before the algorithm, you need to understand the data it runs on. The Bristol Stool Scale is a medical classification system developed at the University of Bristol. It categorizes stool into 7 types based on form and consistency which directly correlates to intestinal transit time.

Type Description Transit Signal
1 🪨 Hard pellets Too slow - constipation
2 🥔 Lumpy, compact Slow
3 🌭 Sausage with cracks Slightly slow
4 🐍 Smooth, soft Ideal
5 ☁️ Soft blobs Slightly fast
6 🌊 Mushy, fluffy Fast
7 💧 Liquid, watery Too fast - diarrhea

Types 3 and 4 are the gold standard. The peak dumping experience. The app highlights these in the distribution charts and steers users toward understanding what moves them toward or away from that range.

The beauty of logging this over time is that you start seeing your personal baseline. Most people cluster around 2–3 types depending on their diet. Your normal might be slightly different from someone else’s normal, and that’s okay. And depending on external factors it might constantly shift as well.


The Prediction Algorithm

This is the part I’m most proud of. And also the part that taught me the most about blending simple statistics with behavioral data. I do not claim to be a mathematical genius but I was happy to crack this out with help of the glorious internet and AI.

The Core Problem

Predicting when someone will next use the bathroom sounds trivial. Just average the gaps between sessions and add that to the last one, right?

Wrong. Human bodies don’t run on fixed intervals. They run on rhythms shaped by sleep cycles, meal timing, stress, and the circadian clock. A simple mean would be terrible at this.

Step 1: Exponential Decay Weighting

Recent sessions are more predictive than old ones. Last Tuesday’s pattern matters more than three weeks ago. So instead of a plain average, I use exponentially decaying weights.

Given intervals \(I_0, I_1, \ldots, I_{n-1}\) between consecutive sessions (most recent first), the weighted interval is:

\[\bar{I}_w = \frac{\displaystyle\sum_{k=0}^{n-1} I_k \cdot \alpha^k}{\displaystyle\sum_{k=0}^{n-1} \alpha^k}\]

where \(\alpha = 0.85\) is the decay factor. Each older interval contributes 15% less weight than the one before it.

In code this looks like:

const weightedInterval = intervals.reduce((sum, val, idx) => 
  sum + val * Math.pow(0.85, idx), 0
) / intervals.reduce((sum, _, idx) => 
  sum + Math.pow(0.85, idx), 0
);

The choice of 0.85 was empirical, aggressive enough to weight recency but not so aggressive that a single outlier session dominates everything.

Step 2: Consistency Scoring

Not all predictions are created equal. If someone goes at 7:15 AM every single morning without fail, that prediction should carry high confidence. If they go at random times, confidence should be low.

I calculate this using variance of the intervals:

\[\sigma^2 = \frac{1}{n}\sum_{k=0}^{n-1}(I_k - \bar{I})^2\]

Then the consistency score \(C\) normalizes this against the mean:

\[C = \max\!\left(0,\; 1 - \frac{\sigma}{\bar{I}}\right)\]

\(C \in [0, 1]\) where 1 is perfectly consistent, 0 is chaotic.

This score drives the confidence emoji in the UI:

  • \(C > 0.8\) → 🎯 High confidence
  • \(C > 0.6\) → 📊 Medium confidence
  • \(C \leq 0.6\) → 🔮 Low confidence (still showing a prediction, but appropriately humble about it)

Step 3: Day-of-Week Pattern Detection

Humans are deeply habitual, and those habits often align to day of week rhythms. Your body on Monday morning after a consistent work week is different from your body on Saturday after a late night.

For each day of week \(d \in \{0, \ldots, 6\}\) I collect all session times (in minutes since midnight) and compute the average:

\[\mu_d = \frac{1}{|S_d|} \sum_{t \in S_d} t\]

Then day-level consistency:

\[C_d = \max\!\left(0,\; 1 - \frac{\sigma_d}{60}\right)\]

where 60 minutes is the normalization window. If \(C_d > 0.7\) for the predicted day, the algorithm snaps the predicted time to \(\mu_d\)

Step 4: Time-of-Day Preference Fallback

If the day-of-week pattern isn’t strong enough (fewer than 2 data points for that day, or low consistency), the algorithm falls back to overall time-of-day preference. Sessions get bucketed:

flowchart LR
    A[Session Time] --> B{Hour?}
    B -->|5–12| C[Morning 🌅]
    B -->|12–17| D[Afternoon ☀️]
    B -->|17–22| E[Evening 🌆]
    B -->|22–5| F[Night 🌙]

The dominant bucket wins, and the average time within that bucket becomes the predicted time component.

The Full Decision Tree

flowchart TD
    A[Last Session] --> B[Compute Weighted Interval]
    B --> C[Predicted Next = Last + Weighted Interval]
    C --> D{Day-of-week data\nfor predicted day?}
    D -->|≥2 sessions + C_d > 0.7| E[Snap to avg time\nfor that weekday]
    D -->|No strong pattern| F[Find dominant\ntime-of-day bucket]
    F --> G[Use avg time\nwithin that bucket]
    E --> H{Predicted time\nin the past?}
    G --> H
    H -->|Yes| I[Roll forward\nby weighted interval]
    H -->|No| J[Return prediction\nwith confidence emoji]
    I --> J

Why Not Just Use a Model?

Fair question(didn’t think about till last minute i guess). I could’ve thrown a Gaussian process or LSTM at this. But the dataset is tiny, most users have tens to hundreds of sessions, not thousands. Overfitting would be a real problem. And explainability matters: if the app tells you “tomorrow at 8 AM 🎯,” you should be able to trust that it’s based on real patterns, not a black box. (Still get it wrong at times comes of my chaotic pattern :/ )

The math here is transparent, interpretable, and works on sparse data. I think it could be seen as a limitation but I would like to think of it and say that this is a feature.


How Health Variables Actually Affect Things

Let me break down what the science says about each tracked variable and how the app uses it.

Fiber:

Fiber is probably the single biggest lever for stool consistency. Soluble fiber (oats, apples, legumes) absorbs water and forms a gel, softening stool. Insoluble fiber (whole grains, vegetables) adds bulk and speeds transit.

The app tracks fiber intake (Low/Medium/High/Great) and correlates it with stool type distribution. The correlation label in analytics:

const fiberCorrelationLabel = fiberHeavyDays && smoothDays
  ? "Higher-fiber days trend toward Type 3-4 results."
  : "More logs are needed for a reliable fiber correlation.";

Simple, but over weeks of data, this becomes genuinely actionable.

Stress:

Your enteric nervous system the “second brain” contains over 100 million neurons and communicates bidirectionally with your actual brain via the vagus nerve. This is why anxiety manifests as stomach knots, and why IBS is so strongly correlated with mental health.

The app watches for high-stress days correlating with high-urgency sessions:

graph LR
    A[High Stress Days ≥3] --> C{Correlation?}
    B[High Urgency Sessions ≥2] --> C
    C -->|Yes| D[Insight: Stress\nmay impact digestion]

Sleep:

Poor sleep slows gut motility. The intestinal muscles that move food along (peristalsis) are partially regulated by your circadian rhythm. Break that rhythm with chronic poor sleep and things slow down or get unpredictable.

The app flags 4+ poor sleep days in a week as a warning.

Caffeine:

Coffee increases colon activity within minutes of consumption. Helpful for constipation. But high chronic caffeine intake can lead to loose stools and dehydration which then causes constipation. The irony is real.

High caffeine days + loose stool pattern → the app tells you.

Alcohol:

Even moderate alcohol alters gut bacteria diversity, damages the intestinal lining, and speeds transit (hello, Type 6–7). The app correlates alcohol intake against irregular stool patterns (Types ≤2 or ≥6).

The Correlation Matrix (Conceptual)

graph TB
    subgraph Inputs
        F[Fiber]
        W[Water]
        S[Sleep]
        ST[Stress]
        C[Caffeine]
        A[Alcohol]
        E[Exercise]
    end
    subgraph Outputs
        BT[Stool Type]
        U[Urgency]
        D[Duration]
        P[Pain]
    end
    F -->|improves| BT
    W -->|softens| BT
    S -->|regulates| U
    ST -->|spikes| U
    C -->|stimulates| BT
    C -->|loosens| BT
    A -->|disrupts| BT
    E -->|improves| U
    E -->|regularizes| D

So what did I learn?

Besides all that cool information dump (pun intended) here are some more takeaways.

1. Local-first is underrated

No auth system, no API, no server costs, no data breach risk. The database is on the your device. Import/export as JSON. It’s fast, it’s private, it just works.

2. Sparse data is the real challenge (maybe i suck at math)

Most ML resources assume you have millions of rows. Real users? Maybe 50 sessions over a few months. The prediction algorithm had to work on 3 sessions minimum and get progressively better not need 500 before doing anything useful. Maybe I need to get a deal with o’reilly and get me a book deal with the title “Design for sparse data first”

Design for Sparse Data

3. The Bristol Scale is actually genius

It’s a simple visual classification that captures a complex physiological signal (transit time) without requiring any lab work. Type 4 isn’t just aesthetically ideal — it indicates roughly 12–72 hours of colonic transit, which is the healthy range. Types 1–2 and 6–7 indicate transit that’s too slow or too fast. Brilliant in its simplicity.

4. Gut health is everything

I started this as a novelty project. Three months in, I realized the gut is deeply connected to sleep quality, mental health, immune function, and even mood regulation (95% of serotonin is produced in the gut). Tracking bowel patterns isn’t niche it’s a window into systemic health.

5. People will track what’s easy

The Quick Log feature (one tap → preset stool type) was the most important UX decision. If logging takes 30 seconds, people do it. If it takes 2 minutes, they don’t. The data quality downstream is entirely dependent on how frictionless the input is.


The Road Ahead: What’s next for bowels?

Here’s where I get a little ambitious.

Right now, the app tracks one system gut health. But the data model is already capturing inputs that affect every system in the body: sleep, stress, exercise, mood, hydration, substances. The sessions table could easily accommodate new session types.

graph TD
    Current[Bowel Sessions + Urine Sessions]
    NearFuture[Sleep Sessions + Workout Sessions + Mood Check-ins]
    FurtherOut[Heart Rate + Nutrition + Cycle Tracking + Medication]

    Current --> NearFuture
    NearFuture --> FurtherOut
    NearFuture --> P[Unified Prediction Engine]
    Current --> P
    FurtherOut --> P
    P --> I[Cross-system Insights]
    I --> D[Doctor-ready Reports]

The prediction algorithm today says “you’ll probably need to go at 8 AM tomorrow.” In a year, it could say “your gut patterns suggest you slept poorly last night and your mood check in confirms it.”

The gut-brain axis is real. Sleep affects gut motility. Stress affects urgency. Exercise affects regularity. Once you’re tracking all of these in one place with a unified timeline, the correlations you can surface become genuinely powerful.

Potential Feature Trajectory

Phase 2 — Richer correlations:

  • Meal logging with food tagging (detect trigger foods automatically)
  • Exercise sessions correlated with gut regularity
  • Menstrual cycle integration (strong gut motility connection)

Phase 3 — Smart patterns:

  • ML model trained on user’s own data once dataset is large enough
  • Anomaly detection (sudden pattern shifts = flag for medical review)
  • Longitudinal trend reports (monthly, quarterly)

Phase 4 — Ecosystem:

  • Export structured data in HL7 FHIR format for healthcare providers
  • Shared family health profiles
  • Optional, opt-in aggregated research contribution (privacy-preserving)

My vision for it is a single app that knows your body better than you do not through surveillance, but through consistent, private, local-first tracking. Your phone has been a health device since the accelerometer was added. We’re just finally starting to use it like one. (might sell your data to meta if i can’t make a living of this, so now you’ll get to see pharmaceutical ads lmao)


The Numbers That Matter

After building and using the app myself for exactly 44 days, a few things stood out:

  • 3 sessions minimum before any prediction is shown below that, there’s not enough signal
  • 21 sessions is the lookback window enough history without making very old data too influential
  • 0.85 decay factor roughly halves the weight of a session every ~5 sessions back
  • 0.7 day-consistency threshold the point where a day-of-week pattern is reliable enough to trust
  • 7-day insight window short enough to be actionable, long enough to catch patterns

These numbers aren’t arbitrary they came from testing the algorithm against my own data and watching where predictions felt right vs. wrong. And thanks to all the beautiful and kind people that were willing to test this app out and give feedback on it.


Closing Thoughts

Building this app was a weird experience. I started thinking it was a joke project and ended up learning more about gastrointestinal physiology than I ever expected. I also ended up with a genuinely useful personal health tool. I use it every single day.

The taboo around talking about gut health is real, but it’s also counterproductive. Your bowel patterns are a vital sign. They change when you’re sick, stressed, malnourished, dehydrated, or overmedicated. They stabilize when you’re sleeping well, eating fiber, staying hydrated, and managing stress.

Tracking them even imperfectly gives you data that decades of medical research has validated as clinically meaningful.

The poop jokes will always be there.

Start logging.

If you have read this all the way through and got here first I do one to say you one committed mother fucker with a well of attention span and also Thank You, Idk if i will be adding all those features i talked about soon or maybe one day in the future, and i don’t even know if it still has any active users that I don’t know about but hope you enjoy it and stay safe.


App source: github.com/Dawit-Sh/Bowels
Stack: React Native · Expo · SQLite · TypeScript

Previous nauseating & lives