Skip to content

Latest commit

 

History

History
418 lines (308 loc) · 12.4 KB

README.md

File metadata and controls

418 lines (308 loc) · 12.4 KB

IsotopeAI logo

IsotopeAI

A study app you run on your own device.

Version Docs

Animated docs · Dashboard · Install · Sync & backup · Admin · Database · Android APK

IsotopeAI landing page screenshot

It includes:

  • Focus timer
  • Tasks and subjects
  • Study sessions and stats
  • Habits, exams, tests, and mock tests
  • Optional Supabase login, backup, restore, and community features

Start here:

Pick Your Device

One-line installers pull the latest version from the main branch and set up the isotope command for you.

Android with Termux

Install Termux from F-Droid or GitHub, not the old Play Store app.

bash <(curl -fsSL https://raw.githubusercontent.com/Suydev/isotope-code/main/install-termux.sh)

Linux and macOS

bash <(curl -fsSL https://raw.githubusercontent.com/Suydev/isotope-code/main/install.sh)

Windows (PowerShell)

irm https://raw.githubusercontent.com/Suydev/isotope-code/main/install.ps1 | iex

Manual install (any OS)

git clone https://github.com/Suydev/isotope-code.git
cd isotope-code
bash setup.sh          # Windows: .\install.ps1 or setup.bat
isotope start

After install, update anytime with:

isotope update

You can also update from inside the app: when a newer build is detected an Update now pill appears at the bottom-right. It works without admin mode as long as the browser is on the same machine as the server (loopback); LAN and remote browsers are refused and should use the command above.

isotope update runs git pull. If you have uncommitted local changes it will stash them — the in-app button warns you and names the file count first. Recover stashed work with git stash pop.

Open:

http://127.0.0.1:3000

What Setup Does

Setup checks for:

  • Node.js 18 or newer
  • npm
  • Git
  • .env
  • required scripts

It then installs the isotope command.

Useful Commands

The same isotope command works everywhere: Linux, macOS, Termux (bash CLI, bin/isotope) and Windows (PowerShell bin/isotope.ps1 or CMD bin/isotope.bat).

isotope start              # start the app
isotope stop               # stop the app
isotope restart            # restart the app
isotope open               # open in browser
isotope update             # update from GitHub (main branch by default)
isotope status             # show status
isotope doctor             # find problems
isotope logs               # show logs
isotope version            # print installed version
isotope repair             # repair install
isotope setup              # re-run setup
isotope reinstall-widgets  # Android Termux widget shortcuts

isotope update tracks the main branch by default. Set ISOTOPE_BRANCH to override, e.g. to follow a different branch:

ISOTOPE_BRANCH=my-branch isotope update

Supabase Setup

The app works best with your own Supabase project.

You need Supabase for:

  • login
  • sync
  • cloud backup
  • restore on a new device
  • avatars
  • groups and community features

Steps:

  1. Create a free project at https://supabase.com
  2. Open SQL Editor.
  3. Paste and run isotope-complete.sql.
  4. Create these Storage buckets if they do not already exist:
    • avatars
    • user-content
    • notes
  5. Copy your Project URL and anon key.
  6. Put them in .env.

Upgrading an existing project? isotope-complete.sql is safe to re-run, but if your project predates the leaderboard RLS change, also run leaderboard-rls-fix.sql. The old policy blocked public SELECT on user_stats_summary and daily_user_stats, which makes the leaderboard render empty. Fresh installs do not need it.

Moving between Supabase projects? From the isotope-apk repo, run ./switch.sh clone --ref <new-ref> --source-ref <old-ref> --pat <PAT> to provision the new project, migrate the 009-026 patches, then back up data (accounts, groups, study sessions, avatars, user-content) and restore it into the target in one pass — the leaderboard/heartbeat cache keys are ref-aware, so the moved app keeps its quota-saving TTL (daily/weekly/monthly boundaries) without reconfiguration. See docs/switch.md in the isotope-apk repo for the single-token and cross-account variants. The shipped APK's bundled backend is iwckbhehmescrqjicbrz.supabase.co (do not reset that project without re-running switch.sh clone or backup.sh restore).

Example:

SUPABASE_URL=https://your-project-ref.supabase.co
SUPABASE_ANON_KEY=your-anon-public-key
PORT=3000
ENABLE_ADMIN_MODE=false

Do not put a service-role key in the browser.

Do not commit .env.

Setup Env Rules

  • .env is the preferred runtime env file.
  • If .env is missing and yeh.env exists, setup copies yeh.env to .env.
  • If ISOTOPE_ENV_FILE is set, setup reads that file, copies it to .env, and uses the copied values.
  • Existing SUPABASE_URL, SUPABASE_ANON_KEY, and ENABLE_ADMIN_MODE values are preserved.
  • If ENABLE_ADMIN_MODE is missing, setup writes ENABLE_ADMIN_MODE=false.

Safe Cloud Backup

The app now uses one backup system.

Main backup:

{userId}/backups/latest.json

Backup history:

{userId}/backups/history/{timestamp}-{hash}.json

Cloud mirror:

{userId}/cloud-snapshot/latest.json

Old folders are still read for safety:

{userId}/imports/latest.json
{userId}/exports/latest.json
{userId}/cloud-snapshot/latest.json

Important rule:

If this device is empty and cloud has a richer backup, upload is blocked. The app must restore cloud data first.

Blocked code:

BLOCKED_EMPTY_OVERWRITE

Local Backup & Restore (backup.sh)

For full project backups (schema + auth + storage + all users), a standalone CLI is provided:

./backup.sh backup           # create encrypted backup (sha256 sidecar + auto-verify)
./backup.sh restore <file>   # restore with pre-flight integrity check
./backup.sh verify <file>    # verify tables, row counts, auth, storage
./backup.sh info <file>      # describe ONE backup file (it takes an argument)
./backup.sh ui               # web console on 127.0.0.1:8000
./backup.sh status           # progress + ETA of the detached backup job
./backup.sh stop             # kill the detached job

ui, status and stop manage long backups that run detached. Note that info takes a backup file as its argument — there is no bare ./backup.sh info that lists local backups.

See the sync & backup guide for key precedence, scheduling, and safety notes.

Keys are resolved from CLI flags (--supabase-url/--anon-key/--service-key/--pat) > environment variables > .backup_env (gitignored) > .env. .backup_env holds the keeper project credentials (separate from your working project in .env) so cloud backups never hit your live app DB.

If .backup_env does not exist, keys fall back to .env. .env only has to carry SUPABASE_URL and SUPABASE_ANON_KEY; SUPABASE_SERVICE_ROLE_KEY and SUPABASE_ACCESS_TOKEN are the two that actually authorise a backup, so without them a backup can only fall back to remote-fetches and will be slow or incomplete. Create .backup_env (chmod 600) before the first real backup.

Admin Mode

Admin mode is optional.

Use it only on your own machine.

ENABLE_ADMIN_MODE=true
ADMIN_SECRET=<long-random-secret>
ADMIN_EMAIL=<your-email@example.com>

Add SUPABASE_SERVICE_ROLE_KEY only in your private .env when you need admin repair tools.

Open:

http://127.0.0.1:3000/__admin

Useful admin pages:

  • /__admin/verify
  • /__admin/sync
  • /__admin/storage
  • /__admin/roles
  • /__admin/patch

Backup Repair Commands

Dry-run first:

node scripts/repair-user-backup.mjs --user <user-id> --dry-run

Apply only after the dry-run looks safe:

node scripts/repair-user-backup.mjs --user <user-id> --apply

Check backups:

node scripts/validate-backup-files.mjs --user <user-id>

Preview cleanup:

node scripts/validate-storage-cleanup.mjs --user <user-id> --dry-run

Troubleshooting

Problem Try this
App does not open isotope start then open http://127.0.0.1:3000
Port is busy isotope stop or set PORT=3001 in .env
Login fails Check SUPABASE_URL and SUPABASE_ANON_KEY
Sync is blocked Restore the cloud backup first
Storage permission error Re-run isotope-complete.sql
Android widget is missing isotope reinstall-widgets
Update failed isotope doctor, then isotope repair
App blank / React doesn't load offline Clear browser caches: caches.keys().then(keys => Promise.all(keys.map(k => caches.delete(k)))).then(() => location.reload()) — the PWA shell now falls back to its precache for first-visit assets

Runtime Login Bridge And Cache Troubleshooting

Do not test browser globals in the Node REPL. Node has no window, so typeof window.__isoLogin is not a valid Node check.

Use the browser console on http://127.0.0.1:3000/auth:

typeof window.__isoLogin
typeof window.__isoUp

Both should return "function".

Use the Node smoke test when a browser is not available:

npm run test:auth-bridge

To prove the configured Supabase project can perform the Storage-backed sync path end to end:

npm run test:supabase-sync

If a stale PWA or browser cache is serving old runtime files, clear runtime caches from the browser console:

caches.keys().then(keys => Promise.all(keys.map(k => caches.delete(k)))).then(() => location.reload())

If the top-right cloud sync button says Authentication required, the browser is not holding a valid Supabase session even if the app shell still looks logged in. Sign out, sign in again through /auth, then run:

typeof window.__isoGetValidJwt

For Contributors

Before changing sync, backup, auth, or SQL:

node --check server.mjs
node --check server/backup-manager.mjs
node --check public/sync/backup-normalizer.js
node --check public/sync/local-data-adapter.js
node scripts/validate-backup-files.mjs --user <user-id>
node scripts/repair-user-backup.mjs --user <user-id> --dry-run
npm run assets:compare

Rules:

  • Do not commit .env.
  • Do not expose service-role keys to the frontend.
  • Do not weaken RLS to hide a bug.
  • Do not let empty local data overwrite rich cloud data.
  • Do not replace compiled assets from the live site unless the asset report proves the same chunk graph is available.
  • Keep docs simple and true.

License

MIT. See LICENSE.