When we set out to build ContxtAI, we had one non-negotiable principle: No Cloud Databases. Your AI context often contains your most sensitive data—proprietary source code, database schemas, API keys, and personal writing preferences. Storing this on a remote server was out of the question.
The Architecture of Local-First
To achieve this, we decided to build ContxtAI exclusively as a browser extension leveraging the Plasmo Framework. This allowed us to keep the entire engine running securely within the boundaries of your local machine.
Here is how the architecture breaks down:
1. IndexedDB Storage Layer
We use IndexedDB to store "Context Bundles" persistently in your browser. This means that if you switch laptops, you will need to export and import your bundles—a minor friction trade-off we gladly accept in exchange for guaranteeing zero server telemetry.
2. The Context Extraction Engine
One of the hardest parts of managing AI memory is writing the rules in the first place. We built an auto-distillation engine that runs a background prompt against your active ChatGPT DOM. It analyzes the conversation, extracts the rules you implicitly set, and formats them into JSON—all happening instantly without ever hitting an external API.
3. The Local Privacy Scrubber
Before any context is injected into an AI chat window, it passes through our Local Privacy Scrubber. Using advanced Regex and entropy scanning in JavaScript, ContxtAI detects AWS keys, passwords, and tokens. It masks them as [MASKED_SECRET] before they ever touch the network tab.
DOM Injection Magic
Injecting text into modern React applications (like ChatGPT and Claude) is surprisingly difficult. Simply setting textarea.value no longer works because React's virtual DOM overwrites it.
We spent weeks reverse-engineering the exact event dispatching logic required to trick ProseMirror and React into accepting our programmatic text injections. The result is a seamless "Inject Context" button that drops 3,000 tokens of architecture rules into a chatbox in 0.1 seconds.
Building local-first is hard, but we believe it is the only correct way to build tools for the AI era.