Letterlock
Your private details stay private. AI still does the work.
Inspiration
AI is becoming part of everyday life. People use it to write, learn, research, solve problems, and make decisions. But as AI becomes more powerful, an important question remains:
Can we benefit from AI without exposing our personal information?
Privacy is becoming a major barrier to trust in AI.
According to Auth0's Customer Identity Trends Report 2025, among respondents who said they would not use AI agents, 44% identified not trusting AI agents with their personal data as a reason. The same report found that 60% of consumers were concerned about AI's impact on the privacy and security of their digital identities.
The concern is also significant in India. PwC's Voice of the Consumer Survey 2024, which included 1,000 Indian consumers, found that 86% were concerned about how AI development could infringe on their personal and data privacy.
Even people already using generative AI remain uncomfortable with the risks. Cisco's 2024 Consumer Privacy Survey found that 84% of generative AI users were concerned about information they entered into AI tools becoming public. Yet 30% said they had entered personal or confidential information, including financial and health details.
These findings reveal a contradiction: people want the benefits of AI, but they are uncomfortable with what sharing their information might mean for their privacy.
Names, addresses, financial records, health information, account numbers, and private conversations are not ordinary text. People should not have to expose these details just to get help from an AI tool.
We wanted to explore a different approach.
What if AI could understand and help with personal situations without receiving the user's original private information?
That question inspired Letterlock.
We are building a privacy-first approach to AI where sensitive information is detected and protected on the user's device, the user reviews exactly what will be shared, and the cloud AI receives only sanitized content.
Letter writing is our first use case, but the bigger idea goes beyond letters.
We believe privacy should be built into the way people use AI, not left to promises, disclaimers, or settings.
What it does
Letterlock is a privacy-first AI application that helps users write letters about sensitive situations, such as a withheld rental deposit, a denied insurance claim, or a medical bill dispute.
It is a Chrome web app built using Firebase AI Logic hybrid inference.
The key idea is simple: your device redacts, you approve, and the cloud writes.
Your device finds private information. Gemini Nano in Chrome detects sensitive information locally. We also use deterministic rules for phone numbers, emails, and account numbers. Names, addresses, amounts, dates, and IDs are replaced with placeholders such as
{{Person A}}and{{Address 1}}.You review exactly what will leave your device. A review screen displays the original story alongside the sanitized version. You can correct missed detections, add sensitive details, or remove incorrect detections. Nothing is sent until you approve.
The cloud AI works with placeholders only. Gemini Flash Lite, through Firebase AI Logic, receives the approved sanitized text. It does not receive the original values.
Your device restores the original details. Once the AI returns the letter, Letterlock checks that every expected placeholder is still present. Only after validation does the device replace the placeholders with the original values.
You can see where inference happened. A runtime badge shows whether each step ran locally or in the cloud, based on information reported by the SDK rather than hard-coded labels.
The goal is to make the privacy boundary visible and understandable to the user.
How we built it
We built Letterlock around a strict separation between local processing and cloud processing.
Hybrid inference: We use on-device inference for sensitive information detection and cloud inference for letter generation. Each inference call explicitly sets its mode. Detection is configured as on-device only and cannot silently fall back to the cloud.
Local model readiness: The application stays locked until the local model is ready. We do not rely only on the browser's availability flag. The status turns green only after the model successfully creates a session and answers a test prompt.
A compiler-enforced privacy boundary: The cloud drafting function accepts only an
ApprovedOutboundTexttype. This type is created by the redaction module after user approval and a pre-send check. Raw story text cannot be passed directly to the cloud drafting function.Structured validation: We use Zod to validate model outputs. Every detected value must also correspond to an actual position in the original story, preventing invalid detection results from being accepted.
Two layers of safety checks: Before sending, we check that the sanitized text does not contain any original sensitive values. After receiving the AI response, we reject output that is missing or has altered placeholders.
Firebase App Check: We use Firebase App Check with reCAPTCHA to help protect the Firebase AI Logic backend from unauthorized clients.
No application-side persistence: The original story and placeholder map remain in tab memory. Letterlock does not save them to a database or application storage.
Technology stack:
- React 18
- TypeScript
- Tailwind CSS
- Vite
- Gemini Nano through Chrome's on-device AI capabilities
- Gemini Flash Lite through Firebase AI Logic
- Firebase App Check
- Firebase Hosting
The project is open source under the MIT License.
Challenges we ran into
Building a privacy-first AI application introduced challenges beyond simply connecting an AI model to a user interface.
Preventing silent cloud fallback: Hybrid inference can fall back to the cloud when a local model is unavailable. For sensitive information detection, that would defeat our entire purpose. We explicitly configured detection for on-device inference only and made the application wait for the local model instead.
Making on-device AI accessible: Chrome's on-device model requires a recent browser, specific settings, and a large model download. We created an in-app setup guide with before-and-after screenshots to help users configure it.
Handling missed detections: Gemini Nano sometimes missed names introduced naturally in sentences, such as "My name is Priya Sharma" or "Mr Rao." We added deterministic rules for these cases and made the review screen an essential part of the privacy process.
Protecting placeholders: Cloud models can sometimes remove, rewrite, or modify placeholders. We built validation that rejects a generated letter unless every expected placeholder survives.
Making privacy claims we can prove: Drafting still happens in the cloud, so we had to be precise about what leaves the device. We do not claim that all processing happens locally. Instead, we ensure that the original sensitive values are removed before the approved text is sent.
Accomplishments we're proud of
- Built a complete privacy-first AI workflow, from entering a story to receiving a generated letter with the original details restored locally.
- Made the privacy boundary enforceable through TypeScript types and validation checks instead of relying only on promises.
- Added a review screen so users can inspect and approve exactly what is shared with the cloud.
- Configured sensitive information detection to run on-device only, with no cloud fallback.
- Added pre-send leak detection and post-generation placeholder validation.
- Built a local/cloud status badge based on runtime information.
- Created an onboarding experience that guides users through enabling Chrome's on-device AI model.
- Made the project open source so others can inspect how the privacy workflow is implemented.
Most importantly, users can inspect the drafting request in Chrome's Network tab and verify that it contains placeholders rather than their original names and addresses.
What we learned
Building Letterlock changed how we think about privacy in AI applications.
Privacy cannot depend only on trust. It needs to be part of the architecture.
We learned that:
- On-device AI can reduce the amount of sensitive information sent to cloud services.
- Small on-device models are not perfect, so user review and deterministic validation are essential.
- Privacy claims should be verifiable, not just written in a product description.
- Users should have control over what information leaves their device.
- Hybrid AI can combine the capabilities of cloud models with the privacy advantages of local processing.
We also learned that being transparent about what happens locally and what happens in the cloud makes a product more trustworthy.
What's next for Letterlock
Letterlock is our first step toward a broader privacy-first AI approach.
Our next goals include:
- More languages: Improve on-device sensitive information detection across more languages.
- Better local detection: Test and improve detection accuracy using real-world examples with consenting users.
- More use cases: Extend the same privacy architecture to other sensitive writing and document workflows.
- Local templates: Add legal and dispute letter templates that work with tokenized information.
- Mobile support: Explore Android and iOS implementations using the same hybrid privacy approach.
- Open-source development: Make it easier for other developers to inspect, learn from, and build on our privacy architecture.
Our long-term vision is to make privacy-preserving AI easier to build and use.
Try it
Live demo: https://letterlock-fc6f1.firebaseapp.com/
Source code (MIT License): https://github.com/khanolkarsujal/Letterlock
Requirements: Desktop Google Chrome with on-device AI support enabled. Allow approximately 22 GB of free space for the local model download. The application includes a step-by-step setup guide.
Letterlock drafts letters. It is not legal advice.
Research sources
Built With
- chrome-built-in-ai
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- gemini-flash-lite
- gemini-nano
- makepdf
- pnpm
- prompt-api
- react
- react-router
- recaptcha
- tailwindcss
- typescript
- vite
- vitest
- zod