Brain by LFI

Personal Media Library

Keep your photos clean

This tool scans your photo library for explicit content and moves anything flagged into a private GCS vault. Anything safe stays in your main library. If the filter gets it wrong, you can put a photo back with one click. Sign in with Google to use the app in production.

Filter strength
—
System
—
Recent activity
—

Console

Set how strict the filter should be, scan your library, and review what's been flagged.

What this does

Use the Photos tab to scan your library. The system looks at each image and moves anything explicit to a private vault. Use the Filter tab to set how aggressive it should be. Check Health if something seems off.

Recent activity

    Nothing has happened yet.

    How strict should the filter be?

    These settings affect future scans. Already-flagged photos aren't re-checked.

    What to flag

    Storage & access settings

    Where the photos live and where the flagged ones go. Edit these here and they're written to .env at the repo root. Restart the server to fully pick them up — the Restart button below uses launchctl kickstart on the merged-app job.

    Heads up: this app is running in Cloud Run, where env vars are managed via gcloud run services update, not by writing .env. The Health tab has copy-runnable gcloud commands for each value.

    Photos scoring at or above this go to the vault. Lower = stricter.

    Where am I, and where else can I go?

    Two copies of this app exist: Production on Cloud Run (cleaner only, public-cloud storage) and Local dev on your Mac (cleaner + PKL Utilities, local SSD + Neon DB). The card below pings each, tells you which is currently reachable, and gives you a one-click way to switch.

    Production You're here
    https://brain-api.lfiq.app/
    Checking…
    Local dev You're here
    http://localhost:8000/
    Checking…

    Local dev isn't running. Browsers can't directly start apps on your Mac (locked down for security), but the easy path is one double-click:

    ⬇ Download starter → Save → double-click it → Terminal opens, server boots, browser pops to localhost.
    Or paste a one-liner in Terminal yourself
    First time cp /Volumes/satopkm/justinsato/Projects/ACTIVE/02-pkm.cleaner.engine/utils/launchd/com.justinsato.pkl.console.plist ~/Library/LaunchAgents/ && launchctl load ~/Library/LaunchAgents/com.justinsato.pkl.console.plist
    Already installed launchctl load ~/Library/LaunchAgents/com.justinsato.pkl.console.plist

    Once loaded, the server auto-starts on every Mac login. After it boots (~3s), click Re-check.

    Scan your library

    Quick scan only checks photos that haven't been classified yet (or were classified at a different threshold). Full re-scan ignores cached results and re-runs every image. Both record a score per photo so you can sort and filter them later.

    Score distribution

    How explicit each photo looks to the model. The dashed line is your current threshold — everything to the right gets quarantined. Use this to pick a threshold that catches what you want without sweeping in too many false positives.

    Loading…

    Live activity

      Start a scan to see photos being processed in real time.

      Your library

      Safe photos that stayed in the main library. Each shows the model's score.

      Loading…

      Private vault

      Photos the filter flagged. If a photo was flagged by mistake, click "Restore" to move it back to your main library.

      Load the vault to view flagged photos.

      Is everything working?

      Each component below is checked live. Green means it's working. Red means it isn't — and the row will tell you what's wrong and what to do about it.

      Checking…

      Documents · PKL

      Your library at a glance

      Same Brain session as Media — where your files live, how they got there, and what needs your attention. On your Mac this uses the SSD-mounted PKL; in production (GCS + Neon) the same controls apply to the cloud mirror. Drop files into _Inbox/ or run routers here when you do not want to wait for the nightly job.

      System
      —
      Inbox
      —
      Files indexed
      —
      Properties
      —
      Last nightly run
      —

      Console

      Overview, inbox, triage, pipelines, and search — same auth and shell as Media.

      Alerts

      Loading…

      Last nightly run

      Loading…

      Recent file moves

      Loading…

      Queued for routing

      Files waiting in _Inbox/. The nightly router classifies these into the right portfolio and property folder. Stale items (over 7 days) are shown in red.

      Portfolios

      Source of truth is public.properties.portfolio. File counts are from the portfolio:<name> tags in file_registry. No folder means no files have landed there yet.

      Loading…

      Add a property to the database

      Use this for properties that exist on disk but aren't in the database yet. Once added, the auto-router will recognize them.

      Run a stage now

      Each stage runs in the background. The output appears below as it streams. Safe to leave the page — jobs continue and you can check Last nightly run in the Overview tab afterward.

      Sort the inbox = move new files to property/client folders. Update file index = push file metadata to the database. Refresh property pages = regenerate _README.md in each property folder. Tidy up = delete stray .DS_Store files and empty folders.

      Output

      No job running.
      
                  

      Portfolio reorganization

      Cross-checks every Portfolios/<old>/<property>/ folder against public.properties. Properties that match a DB entry move into their canonical portfolio. Properties not in the database are left alone. Always preview first.

      System health

      Each component below is checked live. Green means it's working. Red means there's a problem — and the row will tell you what's wrong and what to do.

      Checking…

      Files that didn't auto-classify

      The router put these in _Inbox/_Triage/ because it couldn't tell where they belong. Pick a portfolio + property and the file will move to Portfolios/<portfolio>/<property>/_Documents/. Every move is logged to the manifest so you can reverse it from the History tab.

      Loading…

      Move history (manifest)

      Every file or folder move ever made. The reverse button moves something back to where it came from — useful for undoing a bad route.

      Loading…

      Search the file index

      Search by filename, path, or tag. Looks at every file the nightly indexer has seen (about — files).

      Type something and press Search.

      Brain — guide

      What this is

      Brain is your unified personal data toolbox by Left Field Investments. Two halves run in one app:

      • Media — runs in the cloud against your private photo storage. Scans the library for explicit content, moves anything flagged into a private vault bucket, lets you restore false positives.
      • Documents — on your Mac it uses the SSD-mounted PKL and Neon; on Cloud Run (with PKL_GCS_BUCKET and NEON_DSN) the same tab reads the PKL mirror in GCS.

      Brain is one of five apps in the BRICK family — see the B·R·I·C·K pill strip top-right (or press ⌘K) to switch to Runner, Intel, Cockpit, or Knowledge.

      The Documents tab appears when PKL_UTILS_ENABLED=1 locally, or on Cloud Run when PKL_GCS_BUCKET is set (the app turns on the utils router automatically there). With NEON_DSN set on Cloud Run, triage and search run against the GCS mirror; the Run tab stays local-only.

      Media — what each Console tab does

      Overview
      Recent activity feed. Things that happened during scans, restores, and config changes.
      Filter
      Strictness preset and what kinds of content to flag. Saved locally to your browser, not on the server.
      Settings
      Bucket names, threshold, GCP project. Locally these write to .env; on Cloud Run they're read-only and you get copy-runnable gcloud commands instead.
      Health
      Live check of every component (model, library bucket, vault). Each failed row ships copy-paste fix commands for both Cloud Run and local.
      Photos
      Run a Quick scan or Full re-scan. Watch live activity stream. Browse the library; load the vault to view flagged photos and restore false positives.

      Documents — what each tab does

      Overview
      Alerts, last nightly run summary, recent file moves.
      Inbox
      What's queued in _Inbox/ waiting for the auto-router. Stale items (over 7 days) shown in red.
      Portfolios
      Source-of-truth list from public.properties. File counts come from the portfolio:<name> tags in file_registry. Form below adds new properties to the DB.
      Triage
      Files the auto-router couldn't classify. Pick portfolio + property and route them by hand.
      Run
      Manual triggers for the nightly stages (autoroute, sync, render, maintain) or the full nightly. Plus the Portfolio reorg tool for cross-checking disk vs DB.
      History
      Every file/folder move ever made. The Reverse button on a row moves it back to where it came from.
      Health / Search
      Live system check + free-text search across file_registry.

      Local vs Production — when to use which

      On brain-api.lfiq.app you get Media only. On localhost:8000 you get both. The Settings tab → "Where am I" card detects the other one and gives you a button to switch. If local isn't running, the same card lets you download a .command launcher that boots the local server in one double-click.

      Once the launchd job is loaded, your local server auto-starts at every Mac login. No daily ritual.

      Action feedback

      Every triggered action — Quick scan, Full re-scan, Cancel, Unlock vault, Restore, Save filter, Run nightly, Route triage, Reverse manifest, Add property, Reorg, Open in Finder, Search — shows a busy bar at the top of the page while the request is in flight, and a toast at the bottom-right when it finishes (or fails). You should never wonder whether a click did anything.

      Where things live

      Production photo storage
      Google Cloud Storage buckets configured via PML_GCS_BUCKET and NSFW_GCS_BUCKET.
      Local SSD
      /Volumes/satopkm/Personal_Knowledge_Library/ — the Personal Knowledge Library root.
      Database
      Neon Postgres (host ep-tiny-lab-akrddwgy-pooler.c-3.us-west-2.aws.neon.tech, db neondb). DSN lives in .env at the repo root, never on Cloud Run.
      Code
      /Volumes/satopkm/justinsato/Projects/ACTIVE/02-pkm.cleaner.engine/
      Logs (local)
      /tmp/pkl_console.{out,err} for the always-on launchd server.
      Brain by Left Field Investments. Built on FastAPI on Cloud Run, served from your Mac for the local half, theme by Zenith Wellness.