Tahmid Jawad Shafi data engineering, home
← All projects
analytics · case study

Nittoo

Turns everyday purchases into container lifespans, true daily costs and calibrated run-out windows.

RoleDesigned and shipped
TeamSolo
Period2026-09 – 2026-11
Statuscompleted
DataSynthetic (metrics)
StackTypeScript · React · Supabase · PostgreSQL · Python · Pydantic · DuckDB · dbt · Vitest · Playwright

TL;DR

A personal consumables tracker and forecasting app that turns everyday purchases into container lifespans, true daily costs, and calibrated run-out windows. Source: README.md:5 @ b0fb0fb.

Context & motivation

Modelling pack sizes only per product distorted lifespans when people bought different bottle sizes. Nittoo forecasts run-out from size-normalised consumption rates learned from each user’s completed cycles, shows a calibrated P10–P90 window once enough history exists, and shows “First cycle • Learning” instead of a guessed number for first-time items. Source: README.md:104–107, 178 @ b0fb0fb.

My contribution

  • Built the React + Supabase app: container-level tracking, run-out forecasting and restock reminders, with Row-Level Security tenant isolation verified in CI.
  • Built the Forecast Lab: a Pydantic + JSON Schema export contract, a seeded household simulator, idempotent DuckDB ingestion with a rejects quarantine table, and a dbt warehouse.
  • Backtested forecasts with rolling-origin evaluation and exported calibrated interval quantiles and parity fixtures back into the app.

How I used AI tools

Implementation by an AI coding agent (Google Antigravity). I set the scope, approved every plan, ran the checks, and accepted only work that passed automated gates.

Key decisions

  1. Ship rate_mean (rule_only)

    Alternatives
    rate_mean (rule_plus_rate_outlier), the mechanical winner
    Why
    The extra gain was small, degraded under noise and elasticity, and shipping the simpler model avoided porting an unreliable detector.
    Trade-off
    Gives up that small extra gain (95% CI documented in the backtest report).
    source: README.md:177 @ b0fb0fb
  2. Per-purchase pack-size overrides with rate normalisation

    Alternatives
    Pack sizes modelled only on products
    Why
    Modelling pack sizes only on products distorted lifespans when users bought different bottle sizes.
    Trade-off
    Rate normalisation assumes consumption pace does not scale with container size; if larger bottles are used noticeably faster, lifespan can be overestimated.
    source: README.md:178, 108 @ b0fb0fb
  3. Move data-quality checks (zero-day, outlier, referential) into dbt intermediate models with singular and warning SQL tests

    Why
    Keeps raw ingestion fast while surfacing auditable quality metrics.
    source: README.md:175 @ b0fb0fb

Challenges

Problem: Early manual schema edits drifted from schema.sql.
Approach: Consolidated them into ordered, idempotent migrations and reset a local Supabase in CI.
Outcome: Environment drift was eliminated.
source: README.md:173 @ b0fb0fb
Problem: The app’s JSON export added per-purchase pack size (v1.1.0).
Approach: The Pydantic + JSON Schema contract test failed in CI.
Outcome: The contract update had to ship together with the export change.
source: README.md:174 @ b0fb0fb
Problem: Unexpected false positives in the MAD outlier detector.
Approach: Diagnosing them uncovered an initialisation bug in the simulator.
Outcome: Fixed, with the regression test test_product_default_size_matches_first_purchase.
source: README.md:176 @ b0fb0fb
Problem: demo_export.json diverged between midnight and 06:00 in UTC+6, because remaining days used the wall-clock “today”.
Approach: Pass an explicit asOfDate.
Outcome: A cross-timezone determinism test was added.
source: README.md:181 @ b0fb0fb

Results

4.53 daysOverall holdout forecast error (MAE), size-normalised rate forecast shipped in the app vs the app’s original average-duration baseline, synthetic data (baseline 17.42 days)verified 2026-11 · source: README.md:89–93 @ b0fb0fb · rate_mean (rule_only) vs baseline (none)
4.88 daysForecast error (MAE) after pack-size changes, size-normalised rate forecast shipped in the app vs the app’s original average-duration baseline, synthetic data (baseline 21.59 days)verified 2026-11 · source: README.md:89–93 @ b0fb0fb · rate_mean (rule_only) vs baseline (none)
83.7%P10–P90 run-out window coverage on holdout, size-normalised rate forecast shipped in the app, synthetic data (nominal 80%; mean width 12.8 days)verified 2026-11 · source: README.md:95 @ b0fb0fb · rate_mean (rule_only)

Limitations & next steps

Data sources