Skip to content

priyanshuthakare/System-OS

Repository files navigation

STABILITY OS v1

A behavioral regulation operating system that replaces chaos with stability

License: MIT React Vite Capacitor


๐Ÿ“– Table of Contents


๐ŸŽฏ Overview

STABILITY OS is not a productivity tracker, habit streak app, or mood logger. It's a daily operating system that detects your mental-behavioral state at any given time and delivers the appropriate environment, task sequence, or protocol to maintain stability.

The app is designed to intercept behavioral failure points โ€” especially the vulnerable 4โ€“7 PM transition window โ€” with pre-programmed environment responses that replace oscillation (chaos โ†’ guilt โ†’ spike โ†’ collapse) with a stable execution loop.

What This App IS:

  • โœ… A state-aware daily execution engine
  • โœ… A rule compliance tracker (4 core rules)
  • โœ… An urge interruption protocol
  • โœ… A failure containment and re-entry system
  • โœ… A weekly self-calibration loop
  • โœ… An identity reinforcement layer (execution count, not streaks)

What This App IS NOT:

  • โŒ Not a streak counter (streaks create shame on failure)
  • โŒ Not a dopamine reward system (no badges, confetti, or points)
  • โŒ Not a notification spammer (the system is calm and firm)
  • โŒ Not a mood tracker (only execution count matters)

๐Ÿง  Core Principle

Environment > State > Action > Identity

Most behavioral failures happen not from lack of motivation but from unstructured transitions. STABILITY OS controls the environment to create stable behavioral loops.

The Two Loops:

OLD LOOP (Chaos):

Fatigue โ†’ Bed โ†’ Screen โ†’ Relapse โ†’ Guilt โ†’ Night spike โ†’ Sleep late

NEW LOOP (Stability):

Fatigue โ†’ Movement โ†’ Business โ†’ Controlled reward โ†’ Sleep early โ†’ Stable morning

โœจ Key Features

๐Ÿ• 5-State Time Machine

The app runs on a time-based state machine. You're always in exactly ONE of five states:

  1. Morning Activation (8:15โ€“9:00 AM) - Boot sequence with checklist
  2. External Demand (9:00 AMโ€“4:00 PM) - College/work hours, minimal interference
  3. Vulnerable Transition (4:00โ€“5:00 PM) - 6-step mandatory reset sequence
  4. Controlled Output (5:00โ€“9:45 PM) - Deep work + controlled reward windows
  5. Shutdown Protocol (9:45 PM+) - Hard close, wind-down mode

๐Ÿ”’ Smart Lock System

  • Social media locked until morning checklist complete
  • Social media locked during 4 PM reset sequence
  • Adult content blocked at network level (DNS filtering)
  • All features locked during shutdown mode

๐Ÿ“Š Offline-First Sync Engine

  • Uses Dexie (IndexedDB) for local-first data storage
  • Syncs with Supabase backend when online
  • Zero-latency UI - works completely offline
  • Background sync on reconnection

๐Ÿšจ Behavioral Protocols

  • Urge Overlay: 3-step interruption protocol when urges hit
  • Failure Recovery: Containment system with 24h cooldown
  • Sleep Mode: Enforced shutdown with limited functionality

๐Ÿ“ฑ Cross-Platform

  • Web application (React + Vite)
  • Android app (Capacitor)
  • iOS ready (requires Xcode setup)

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           React UI Layer                    โ”‚
โ”‚  (Views, Components, Overlays)              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚       State Management (Zustand)            โ”‚
โ”‚  - App State (tabs, overlays, modes)        โ”‚
โ”‚  - Auth State (user, profile, onboarding)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    Business Logic Layer                     โ”‚
โ”‚  - TimeEngine (state detection)             โ”‚
โ”‚  - SyncEngine (data synchronization)        โ”‚
โ”‚  - NotificationEngine (local notifications) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Data Layer                          โ”‚
โ”‚  - Dexie (IndexedDB - offline storage)      โ”‚
โ”‚  - Supabase (PostgreSQL - cloud backend)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Getting Started

Prerequisites

Ensure you have the following installed:

  • Node.js (v18 or higher) - Download
  • npm or yarn (comes with Node.js)
  • Git - Download

For mobile development:

  • Android Studio (for Android) - Download
  • Xcode (for iOS, macOS only) - Download

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/stability-os.git
cd stability-os
  1. Install dependencies:
npm install

Environment Setup

  1. Create environment file:
# Copy the example environment file
cp .env.example .env.local
  1. Configure Supabase:

You need a Supabase project for backend functionality. Get your credentials at supabase.com:

# .env.local
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
  1. Database Setup:

The app uses the following Supabase tables:

  • users - User authentication data
  • user_profiles - Extended user profile information
  • time_blocks - Daily execution blocks and checklists
  • rule_violations - Compliance tracking
  • urge_logs - Urge protocol tracking
  • failure_logs - Failure recovery tracking
  • weekly_closures - Weekly review data

See Database Schema Documentation for complete schema (if available)

Running the App

Development server (web):

npm run dev

Open http://localhost:5173 in your browser.

Preview production build:

npm run build
npm run preview

๐Ÿ“ฆ Building for Production

Build for web:

npm run build

The production files will be in the dist/ directory.


๐Ÿ“ฑ Mobile Development

This project uses Capacitor to deploy to iOS and Android.

Android Setup

  1. Build the web app:
npm run build
  1. Sync with Capacitor:
npx cap sync android
  1. Open in Android Studio:
npx cap open android
  1. Run on device/emulator from Android Studio

iOS Setup

  1. Build the web app:
npm run build
  1. Sync with Capacitor:
npx cap sync ios
  1. Open in Xcode:
npx cap open ios
  1. Run on device/simulator from Xcode

Installing Capacitor (if needed)

# Run the provided batch script (Windows)
install_cap.bat

# Or manually install
npm install @capacitor/core @capacitor/cli
npx cap init
npx cap add android
npx cap add ios

๐Ÿ“‚ Project Structure

stability-os/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/          # React components
โ”‚   โ”‚   โ”œโ”€โ”€ layout/         # PhoneFrame and layout components
โ”‚   โ”‚   โ”œโ”€โ”€ logic/          # TimeEngine, business logic components
โ”‚   โ”‚   โ”œโ”€โ”€ ui/             # Reusable UI components
โ”‚   โ”‚   โ””โ”€โ”€ views/          # Full-screen views (Home, Auth, Settings, etc.)
โ”‚   โ”œโ”€โ”€ hooks/              # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useNotifications.js
โ”‚   โ”‚   โ””โ”€โ”€ useSyncEngine.js
โ”‚   โ”œโ”€โ”€ lib/                # Utilities and libraries
โ”‚   โ”‚   โ””โ”€โ”€ db.js           # Dexie database configuration
โ”‚   โ”œโ”€โ”€ store/              # Zustand state management
โ”‚   โ”‚   โ”œโ”€โ”€ useAppStore.js  # App-level state
โ”‚   โ”‚   โ””โ”€โ”€ useAuthStore.js # Authentication state
โ”‚   โ”œโ”€โ”€ App.jsx             # Root application component
โ”‚   โ”œโ”€โ”€ main.jsx            # Application entry point
โ”‚   โ””โ”€โ”€ index.css           # Global styles (Tailwind)
โ”œโ”€โ”€ android/                # Android Capacitor project
โ”œโ”€โ”€ dist/                   # Production build output
โ”œโ”€โ”€ public/                 # Static assets
โ”œโ”€โ”€ capacitor.config.json   # Capacitor configuration
โ”œโ”€โ”€ vite.config.js          # Vite configuration
โ”œโ”€โ”€ tailwind.config.js      # Tailwind CSS configuration
โ”œโ”€โ”€ package.json            # Dependencies and scripts
โ””โ”€โ”€ README.md               # This file

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 18.3 - UI library
  • Vite 6.0 - Build tool and dev server
  • Tailwind CSS 3.4 - Utility-first CSS framework
  • Lucide React - Icon library

State Management

  • Zustand 5.0 - Lightweight state management
  • Dexie 4.3 - IndexedDB wrapper for offline storage
  • dexie-react-hooks - React hooks for Dexie

Backend & Sync

  • Supabase - PostgreSQL backend, authentication, real-time sync
  • @supabase/supabase-js - JavaScript client

Mobile

  • Capacitor 8.1 - Cross-platform native runtime
  • @capacitor/android - Android platform
  • @capacitor/local-notifications - Native notifications

Dev Tools

  • ESLint - JavaScript linting
  • PostCSS - CSS processing
  • Autoprefixer - CSS vendor prefixes

๐ŸŽฎ How It Works

State Detection

The TimeEngine component runs continuously and detects which of the 5 states you're in based on device time:

// Simplified logic
if (time >= 8:15 && time < 9:00) โ†’ STATE 1: Morning Activation
if (time >= 9:00 && time < 16:00) โ†’ STATE 2: External Demand
if (time >= 16:00 && time < 17:00) โ†’ STATE 3: Vulnerable Transition
if (time >= 17:00 && time < 21:45) โ†’ STATE 4: Controlled Output
if (time >= 21:45) โ†’ STATE 5: Shutdown Protocol

Lock Logic

Certain actions are locked until conditions are met:

  • Morning: Social media locked until 5/5 checklist items complete
  • 4 PM Reset: Social media locked until all 6 steps complete (including 30-min business block)
  • Shutdown: All features except wind-down checklist locked

Offline-First Sync

  1. First login: App syncs data from Supabase โ†’ Dexie
  2. Subsequent logins: App loads from Dexie immediately (instant UI)
  3. Background sync: Syncs with Supabase silently in background
  4. Offline mode: App works fully offline, queues changes for next sync

Behavioral Protocols

Urge Protocol (when user hits "I'm feeling an urge"):

  1. Acknowledge the urge (no shame)
  2. 5-minute timer + physical reset (water, pushups, walk)
  3. Re-orient to current block task

Failure Recovery (after a rule violation):

  1. 24-hour cooldown period
  2. Reflection journal entry
  3. No shame messaging - just data logging
  4. Return to normal execution next day

๐Ÿค Contributing

We welcome contributions! STABILITY OS is built to help people create stable behavioral loops, and your input can make it better.

How to Contribute

  1. Fork the repository

  2. Create a feature branch:

    git checkout -b feature/your-feature-name
  3. Make your changes:

    • Follow existing code style
    • Add comments for complex logic
    • Test thoroughly
  4. Commit your changes:

    git commit -m "feat: add your feature description"

    Use conventional commits:

    • feat: - New feature
    • fix: - Bug fix
    • docs: - Documentation changes
    • style: - Code style changes (formatting, etc.)
    • refactor: - Code refactoring
    • test: - Adding or updating tests
    • chore: - Maintenance tasks
  5. Push to your fork:

    git push origin feature/your-feature-name
  6. Open a Pull Request:

    • Describe what you changed and why
    • Reference any related issues
    • Include screenshots for UI changes

Development Guidelines

  • Code Style: Follow the existing patterns in the codebase
  • Component Structure: Use functional components with hooks
  • State Management: Use Zustand stores for shared state
  • Styling: Use Tailwind CSS utility classes
  • Comments: Add @intent comments for complex components (see existing examples)
  • Testing: Test on both web and mobile (if possible)

Areas We Need Help

  • ๐ŸŽจ UI/UX Design: Improving the interface while maintaining the "calm and firm" aesthetic
  • ๐Ÿ“ฑ iOS Testing: We need iOS testers and developers
  • ๐ŸŒ Localization: Translating the app to other languages
  • ๐Ÿ“š Documentation: Improving docs, tutorials, setup guides
  • ๐Ÿ› Bug Fixes: Check the Issues page
  • โœจ New Features: Propose new protocols or state detection improvements

Code of Conduct

  • Be respectful and constructive
  • Focus on the problem, not the person
  • Assume good intent
  • This app is about stability, not perfection - bring that energy to your contributions

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright ยฉ 2026 Priyanshu Thakare


๐Ÿ™ Acknowledgments

  • Built with the principle: Environment > State > Action > Identity
  • Inspired by behavioral psychology and systems thinking
  • Designed for people who want to replace chaos with stable execution

๐Ÿ“ž Support


Built to replace oscillation with stability.

โญ Star this repo if it helps you build stable behavioral loops!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages