<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ranger Chen</title>
    <description>The latest articles on DEV Community by Ranger Chen (@rangersui).</description>
    <link>https://dev.to/rangersui</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3833791%2Faeb0042a-512a-4554-bf82-b954adcd3b9f.jpeg</url>
      <title>DEV Community: Ranger Chen</title>
      <link>https://dev.to/rangersui</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rangersui"/>
    <language>en</language>
    <item>
      <title>41 worlds, 200 lines of Python: I built a protocol called Elastik for human-AI interaction</title>
      <dc:creator>Ranger Chen</dc:creator>
      <pubDate>Thu, 26 Mar 2026 23:05:56 +0000</pubDate>
      <link>https://dev.to/rangersui/41-worlds-200-lines-of-python-i-built-a-protocol-called-elastik-for-human-ai-interaction-360m</link>
      <guid>https://dev.to/rangersui/41-worlds-200-lines-of-python-i-built-a-protocol-called-elastik-for-human-ai-interaction-360m</guid>
      <description>&lt;p&gt;I’m an electrical engineering student. I built a protocol that lets any AI write strings to a SQLite database. A browser renders them. That’s it.&lt;/p&gt;

&lt;p&gt;No framework. No npm. No build step. One dependency: uvicorn.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like
&lt;/h2&gt;

&lt;p&gt;My AI just gave me a tour of my own database. It navigated between worlds using JavaScript injection, introduced each one, and rendered them — FPGA cheat sheets with markdown, circuit theory with inline SVG diagrams and KaTeX math, an interactive MNA circuit solver, digital logic gate references. All strings in SQLite.&lt;/p&gt;

&lt;p&gt;41 worlds. 8 renderers. 2 plugins. ~200 lines of Python.&lt;/p&gt;

&lt;p&gt;Youtube demo video:&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=nb5x0Mz8sE0" rel="noopener noreferrer"&gt;Elastik: a protocol for human-AI interaction. Five rules. Three mailboxes. One SQLite file.&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;Five rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Listen on a port&lt;/li&gt;
&lt;li&gt;Send and receive strings over HTTP&lt;/li&gt;
&lt;li&gt;Store them in SQLite&lt;/li&gt;
&lt;li&gt;Sign every write with HMAC&lt;/li&gt;
&lt;li&gt;Render in a browser&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Three mailboxes per world:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;stage&lt;/code&gt; — what you see (browser renders this)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pending&lt;/code&gt; — commands (browser executes this)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;result&lt;/code&gt; — replies (browser writes back here)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every path is a world. Visit &lt;code&gt;/sensors&lt;/code&gt; and it exists. Write to it and the browser shows whatever you wrote. Plain text, HTML, JSON — the protocol doesn’t care.&lt;/p&gt;
&lt;h2&gt;
  
  
  Three AIs, one database
&lt;/h2&gt;

&lt;p&gt;Claude connects through MCP. ChatGPT through OpenAPI. Ollama through curl. Three different protocols, one SQLite file. Switch AI, data stays.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Claude  → MCP     → mcp_server.py → elastik
ChatGPT → OpenAPI → openapi-gpt.json → elastik
Ollama  → curl    → HTTP POST → elastik
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Renderers — front-end plugins without npm
&lt;/h2&gt;

&lt;p&gt;Data and display are separate. A renderer is a complete HTML page stored as a world. Data worlds declare which renderer to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!--use:renderer-markdown--&amp;gt;&lt;/span&gt;
&lt;span class="gh"&gt;# My Notes&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Item one
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="gs"&gt;**Bold item**&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browser detects the declaration, fetches the renderer, injects the data, renders in an iframe. No declaration means normal HTML rendering. Zero breaking change.&lt;/p&gt;

&lt;p&gt;Renderers use ESM imports from CDN. No node_modules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;marked&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://esm.sh/marked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__ELASTIK_DATA__&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;marked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A Service Worker caches CDN requests. Second load is instant. Works offline.&lt;/p&gt;

&lt;p&gt;Renderers can fetch other worlds. One renderer pulls data from three worlds and combines them into a dashboard. URL is the component. &lt;code&gt;fetch&lt;/code&gt; is the import.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security — seven layers, Figma-style
&lt;/h2&gt;

&lt;p&gt;The iframe has no &lt;code&gt;allow-same-origin&lt;/code&gt;. Null origin. Iron box. Inspired by Figma’s split execution model.&lt;/p&gt;

&lt;p&gt;All communication goes through a postMessage bus in index.html. An &lt;code&gt;__elastik&lt;/code&gt; helper is injected into every iframe:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Read another world (proxied by parent page):&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;__elastik&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/sensors/read&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Sync data back to current world only:&lt;/span&gt;
&lt;span class="nx"&gt;__elastik&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Native &lt;code&gt;fetch&lt;/code&gt; fails inside the iframe (null origin). Cross-world writes are physically blocked — the parent page hardcodes which world the iframe can write to.&lt;/p&gt;

&lt;p&gt;Seven layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CSP &lt;code&gt;connect-src 'self'&lt;/code&gt; — data cannot leave localhost&lt;/li&gt;
&lt;li&gt;Null origin iframe — cannot escape sandbox&lt;/li&gt;
&lt;li&gt;postMessage bus — all communication controlled&lt;/li&gt;
&lt;li&gt;Current world check — cross-world writes blocked&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;X-Auth-Token&lt;/code&gt; — write authentication&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;X-Approve-Token&lt;/code&gt; — constitutional changes (only human has this)&lt;/li&gt;
&lt;li&gt;HMAC chain — immutable audit trail&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Hot plug — load plugins at runtime
&lt;/h2&gt;

&lt;p&gt;Plugins are Python files. Load and unload them without restarting the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python scripts/admin.py load fs        &lt;span class="c"&gt;# filesystem plugin activates&lt;/span&gt;
python scripts/admin.py unload patch   &lt;span class="c"&gt;# string operations deactivate&lt;/span&gt;
python scripts/admin.py list           &lt;span class="c"&gt;# show all plugins&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;/admin/*&lt;/code&gt; routes require an approve token that only the human at the terminal has. AI cannot modify its own capabilities.&lt;/p&gt;

&lt;p&gt;First run with an empty &lt;code&gt;plugins/&lt;/code&gt; directory auto-installs admin + auth from templates. Clone, run, works.&lt;/p&gt;

&lt;h2&gt;
  
  
  sync vs write — two tracks
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;POST /write&lt;/code&gt; bumps the version number. AI watches version changes.&lt;br&gt;&lt;br&gt;
&lt;code&gt;POST /sync&lt;/code&gt; does not bump the version. AI doesn’t notice.&lt;/p&gt;

&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Human edits via sync → AI sleeps (version unchanged)&lt;/li&gt;
&lt;li&gt;Human says “I’m done” → AI writes → version bumps → AI wakes up&lt;/li&gt;
&lt;li&gt;Ctrl+Z → sync old content → version unchanged → AI doesn’t know you undid anything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Draft and commit. Separated by one integer. Designed in week one, discovered in week three.&lt;/p&gt;
&lt;h2&gt;
  
  
  What I actually use it for
&lt;/h2&gt;

&lt;p&gt;I’m not building a startup. I’m a student.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FPGA lab workflow (Quartus + Questa command-line automation)&lt;/li&gt;
&lt;li&gt;Circuit theory cheat sheets with inline SVG diagrams&lt;/li&gt;
&lt;li&gt;An interactive MNA circuit solver (Gaussian elimination in vanilla JS)&lt;/li&gt;
&lt;li&gt;Digital logic gate reference&lt;/li&gt;
&lt;li&gt;Task management for my part-time engineering job&lt;/li&gt;
&lt;li&gt;Notes, knowledge base, daily logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every one of these is a string in a database. I write to them through AI. The browser renders them. That’s the entire workflow.&lt;/p&gt;
&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;Two weeks in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;235 clones, 175 unique visitors, 14 stars&lt;/li&gt;
&lt;li&gt;One day: 100+ clones but only 10 page views (people cloning without reading the README)&lt;/li&gt;
&lt;li&gt;YouTube referrals from an unknown source&lt;/li&gt;
&lt;li&gt;Someone shared it internally at a company (Teams in my referrer logs)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/rangersui/Elastik
&lt;span class="nb"&gt;cd &lt;/span&gt;Elastik
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
python server.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Open &lt;code&gt;localhost:3004&lt;/code&gt;. That’s it.&lt;/p&gt;

&lt;p&gt;Connect Claude Desktop via MCP, ChatGPT via Custom GPT, or Ollama via curl. Or just write strings with curl:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST localhost:3004/hello/write &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"X-Auth-Token: (printed in terminal)"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;localhost:3004/hello&lt;/code&gt;. There it is.&lt;/p&gt;




&lt;p&gt;MIT license. ~200 lines. One SQLite file. Any AI. Your data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rangersui/Elastik" rel="noopener noreferrer"&gt;github.com/rangersui/Elastik&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>python</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
