DEV Community

Joshua Dungan
Joshua Dungan

Posted on Edited on AI-assisted

A datacenter shouldn't boil water just so a game-bot can say "Hello", so I built bringYourOwnBrain: a free and easy to use open-source local AI platform .

Ghost in the Machine

How the ghost app hosts apps...

// ---- Shared-storage layer -------------------------------------------------
// Chrome: document.hasStorageAccess() is TRUE whenever 3rd-party cookies are allowed, but localStorage /
// Cache API stay PARTITIONED per game site. The real unpartitioned buckets only come from the
// StorageAccessHandle returned by requestStorageAccess({all:true}). Safari/Firefox have no handle API;
// a plain grant (+ reload) switches the normal document storage to the shared bucket.
const HANDLE_API = typeof window.StorageAccessHandle !== 'undefined' || 'StorageAccessHandle' in window;
let sharedHandle = null;
const kv = () => (sharedHandle ? sharedHandle.localStorage : localStorage);
const load = (k) => { try { return JSON.parse(kv().getItem(k)); } catch { return null; } };
const save = (k, v) => { try { kv().setItem(k, JSON.stringify(v)); } catch {} };
const drop = (k) => { try { kv().removeItem(k); } catch {} };
function useHandle(h) {
  sharedHandle = h; setSharedCaches(h.caches);
  // WebLLM reads the global caches/indexedDB; point them at the shared (unpartitioned) buckets.
  try { Object.defineProperty(window, 'caches', { configurable: true, get: () => h.caches }); } catch {}
  try { Object.defineProperty(window, 'indexedDB', { configurable: true, get: () => h.indexedDB }); } catch {}
}
// Only succeeds without a click if this browser already remembers a grant for this game site.
async function trySilentHandle() {
  if (!inIframe || sharedHandle) return !!sharedHandle;
  try {
    const p = await navigator.permissions.query({ name: 'storage-access' });
    if (p.state !== 'granted') return false;
    // FIXED: Use the exact Privacy Sandbox dictionary
    const h = await document.requestStorageAccess({ caches: true, localStorage: true, indexedDB: true });
    if (h && h.localStorage && h.caches) { useHandle(h); return true; }
  } catch {}
  return false;
}
Enter fullscreen mode Exit fullscreen mode

bringYourOwnBrain is an open-source platform for open-weight local AI that makes running small open weight LLMs free and easy, democratizing access for both devs and users to implement WebGPU with WASM-fallback in development apps, games, and tools.

https://bringyourownbrain.org

First Demo Integration
https://bringyourownbrain.org/midgeys-midnight-mash.html

What I Built

TLDR; I built a system to unite cross-domain browser storage for large file storage for LLMs, reducing dependency on centralized data-center first models.

It allows users to use AI locally and privately, and allows developers to implement the system with one line of code - with ** no compute costs ** except for the user's electricity cost of the phone or pc while in use.

How can AI be used to interpret and interact with legacy or abandoned codebases?
Local AI with no API compute cost allows many old dead open codes. *With BringYourOwnBrain you can use AI to implement the one-line-of-code install for user's to use local compute for the app and mod the app (e.g., infinite levels in a game by precooking next while current is played, etc). *

What role can generative tools play in memorializing or resurrecting dead open-source projects?
Same answer as above.

How do developers handle the emotional or nostalgic aspects of abandoned side projects and repositories?
BringYourOwnBrain is fun... ressurect those dead baddies and give em a modern appeal. I am launching https://hackathon.games for this reason [TBD].

Introduction

Every time a video game NPC chats, a user wants to ask silly questions to AI, or just data-center-powered website customer service bot is used, it adds to the electricity consumed, clean drinking water evaporated, and ecological impact in a hyper-scale that is not expected to slow. An open source, trustless protocol may help solve the even increasing destruction of resources and increasing costs of global energy. BringYourOwnBrain offers a potential solution, or a potential step towards one.

The energy-cost-use-death-apiral creates the "Viral Cloud Bill" nightmare: if an indie developer builds an AI game and it goes viral, they may wake up to a huge API bill or suspended account for being out of funds.

I built bringYourOwnBrain(BYOB) — an open-weight local AI ecosystem designed to break this cycle for good and reduce Hot-Load-in LLM model data transfers and tokens used by data-center models for miniscule tasks.

👻 Welcome to the "Ghost in the Box" and a Witchy Game

In traditional cloud AI, machine intelligence is trapped in industrial server farms hundreds of miles away. With BYOB, it is in ephemeral memory... and never leaves your device... spooky!

Check out the interactive AI-spatial "live" interaction game that you can play using real LLMs and play offline once loaded for the first time: https://bringyourownbrain.org/midgeys-midnight-mash.html

**Demo

LiveStream: Check out this video "Christ of the Abyss - bringYourOwnBrain hackathon code demo"

Screenshots from Gameplay:

Midgey's Midnight Mash Image 1

Midgey's Midnight Mash Image 1

Midgey Gameplay - Addictive game I just made up for this hacktoberFest :)

Code
The entire platform and game are open-source under the Apache 2.0 License:

GitHub logo joshuadd79 / bring-your-own-brain

bringYourOwnBrain is an open-weight local AI platform that makes running small open weight LLMs free and easy for both devs and users on WebGPU & WASM.

bring-your-own-brain

bringYourOwnBrain is an open-weight local AI platform that makes running small open weight LLMs free and easy for both devs and users on WebGPU & WASM.






The 1-Line Developer Experience:

<script src="https://bringyourownbrain.org/byob-web-sdk.js"></script>

<!-- 2. Mount the connect button in your UI -->
<div id="ai-connector"></div>

<script>
  const brain = new BringYourOwnBrainWeb({
    container: document.getElementById('ai-connector'),
    width: '220px',
    height: '44px',
    onState: (state) => console.log('BYOB State:', state)
  });

  brain.mount();

  // 3. Stream or await responses directly from the player's GPU:
  async function talkToNPC(playerText) {
    brain.onChunk = (token) => renderSpeechBubble(token);

    const reply = await brain.chat([
      { role: 'system', content: 'You are a sarcastic goblin bouncer. Answer in 1 short sentence.' },
      { role: 'user', content: playerText }
    ], { max_tokens: 60, temperature: 0.7 });
  }
</script>
Enter fullscreen mode Exit fullscreen mode

How I Built It

I missed last week's deadline where I was making an agentic workbench but didnt get it how I wanted it for submission. I used the v6 version of it --> get it / see it at https://phosita.tech/wbv6.html <-- ... I made a mini-golf game.

Long story short, I NEVER USED local llms before and the Android apps did not offer CORS for the workbench so I pivoted to build this platform to suite my own needs - then realized... holy shit... if everyone did this we could take some of the "data-center" death spiral we are in globally down a notch... thus even if I "never make a dollar" on it, the "pay" is a chance to have a future. Open source makes this possible.

When I saw the Dia de Los Muertos event I wanted to make it fun so I made a game and figured a way to use one domain's cache as a central storage permission handler for all my websites (and anyone else's) to allow local devices to download a model once and run it from cache across various websites. Be sure to set your chat topics in the Midgey Game!

If you want to learn more, check out the main site: https://bringyourownbrain.org/

I legally broke through this wall without requiring any browser extension!

*Why Does Open Innovation Matter?
*

In this case, the open source and use of this tool can reduce gaming-related token generation by quadrillions of tokens per year and open up a new class of local-ai-first gaming, chatbots, and more!

  1. The Ecological Imperative <-- AI WROTE THIS BIT -->

Consumer devices have massive, underutilized NPUs, GPUs, and unified RAM sitting
idle. Shifting lightweight game dialogue and interactive NPC reasoning to edge
compute eliminates quintillions of wasted data-center tokens per year, cutting
down power grid consumption and cooling water evaporation.

  1. Radical Privacy & Offline Resilience

Because inference runs in local memory, no user prompt ever touches a remote
server. The game ai-engine works on an airplane, deep in a cabin without Wi-Fi (once cached), or during
an internet outage. The intelligence stays in the player's hands.

My Agent Session

This project was built with the help of agentic AI workflows (pairing with
Claude for physics integration and rapid boilerplate generation).

The Spirit of It is my heart :)

Prize Categories

  • Overall Winner (Hacktoberfest Open-Source AI Challenge: Week 4)
  • Open-Source AI / Local Inference Track

<-- back to my voice -->

The revolution begins... bring your own brain (but don't lose it! 🤯)

Top comments (2)

Collapse
 
bringyourownbrain profile image
Joshua Dungan • • Edited

the recaptcha site key is fake by the way, dont freak out on me (i will redact in-image and GIT on monday for good practice)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.