The Recovery Sobriety Subsystem is an integrated module in Warborn OS designed to assist users in managing behavioral recovery. Rather than serving as a static quote display, it acts as an active behavioral intervention engine and recovery capital compiler. It tracks real-time sobriety durations, aggregates financial and temporal capital reclaimed, registers relapse events with cognitive trigger notes, and delivers timed, randomized psychological pattern-interrupt overlays.
Behavioral habits and addictive cycles are largely driven by automatic, sub-conscious execution loops. When a trigger occurs, the brain immediately defaults to the automated action path before the prefrontal cortex can assess the decision. Static tracking widgets only display cumulative stats after the fact; they fail to interrupt the decision-making process at the point of action.
To create a system that actively helps break automated loops, we needed to:
The system consists of a PostgreSQL schema storing active recovery stats and relapse logs, a FastAPI router exposing CRUD operations for logs, and a Next.js front-end containing the cockpit tracking layout and the dynamic pattern-interrupt overlay.
graph TD
Client[Next.js Client] -->|Fetch stats/logs| API[FastAPI Gateway]
API -->|Read/Write| DB[(PostgreSQL Database)]
Client -->|Auto Rotate 7s| Interrupter[Cognitive Interrupter]
Interrupter -->|Read Library| JSON[interventions.json]
models/recovery.py)SobrietyTracker: Stores start date, daily cost rate, target metrics, and currency configurations.RelapseLog: Stores timestamps, pre-relapse mood values (1 to 5), trigger categories, and freeform text descriptions.components/recovery-intervention.tsx)The interrupter reads from a JSON library containing 102 unique prompts across Stoicism, Neuroscience, Atomic Habits, and Mindfulness. It cycles these prompts every 7 seconds utilizing a smooth 700ms slide-and-fade animation. To prevent cognitive fatigue and guarantee freshness, it implements a smart category rotation check:
// Space out categories so consecutive prompts never share the same source type
const lastFifteenShown = useRef<string[]>([]);
const getNextIntervention = () => {
const filtered = library.filter(item => !lastFifteenShown.current.includes(item.id));
const selection = filtered.length > 0 ? filtered : library;
const picked = selection[Math.floor(Math.random() * selection.length)];
lastFifteenShown.current.push(picked.id);
if (lastFifteenShown.current.length > 15) lastFifteenShown.current.shift();
return picked;
};
$, ₹, £) prevents layout shifts and improves initial dashboard loading.