Inspiration

I'm going through a hard time right now, and I'm lucky to have supportive friends and family around me. Not everyone is. I've talked to a lot of people online who told me the people close to them can't fully understand what they're feeling, and that it isn't anyone's fault. Life is busy, and everyone has their own life to live.

Many of them have nobody to bring their troubles to, and at some point people get tired of hearing the same thing over and over. Most of us also don't want half the world knowing what we're dealing with and would like to keep it as private as possible while receiving help.

So I built Haven to be a temporary place to talk, a free companion that runs locally on your own device. I hope it helps someone get through a rough night. It does not replace a therapist. Because the chat runs on your computer, nothing you write goes to a cloud service unless you say yes and see exactly what would be sent. The code is open source, so anyone can check that for themselves or run their own copy.

You can try it out here: https://haven-882c1.web.app/

What it does

Haven is a companion for stress and tough times.

Chat

Chat runs entirely on your computer, and you choose how it replies. Just listen is the default. It answers in two to four sentences that reflect back what you said, gives no advice, and asks a question only every other reply, so it doesn't feel like an interview. Help me think asks what you've already tried, then offers at most one idea from a set of 92 short self-help cards. If you write something like "what should I do", it switches to Help for that one reply.

Haven keeps a running summary of what you've talked about, what you've tried and what helped. Come back after a few days and it knows how long it's been, and it can ask how something turned out once you've written first. Now and then it offers to remember a fact, like "Remember: exam on Friday?", and keeps it only if you press Keep.

Journal and About me

The journal is a board of sticky notes. Click an empty spot or press New note, rate how you feel from 1 to 10, write, and pick a paper colour. The colour never stands for your mood. You can open any note and edit it in place. About me holds short facts you want Haven to know, such as what you study or who you live with, and Chat uses both.

Insights

Insights looks back over your last 7 or 30 days. Every journal note and chat from that time shows up as a plain card, and you pick which ones to include. Haven then points out your hardest and lightest days, the themes that keep coming back, and a few small things to try. This part uses the cloud model, so you see a preview of what will be sent first. The result isn't saved.

Write a message

Write a message helps you put something hard into words, like telling a friend you're struggling. You say who it's for and what you want to get across, and you get a draft you can edit.

Small steps

Small steps builds a four-week plan of everyday things to try, two or three per week. Each one comes with what it is, why it might help you, a concrete first step, and how often to do it. You can make the plan privately or with the cloud.

In cloud mode, Haven reads your notes first and asks you three to five questions about your situation. It always adds two of its own: what you'd rather not do or be reminded of, and how much time you have in a normal week. That keeps the plan away from anything tied to what's hurting you. Private mode writes the whole plan on your computer. Either way, the ideas come from a library of 49 based on published guidance, and the plan never mentions medication or therapy or sets goals, streaks or reminders.

At the end of each plan, a Read more list links to up to five general pages from public health and university sites about what the plan was written for. I opened and read all 21 pages on the list before adding them. Haven picks the links on your device from that fixed list. It doesn't scrape the web or copy any article text, and nothing opens until you click.

When someone is in danger

If someone writes about hurting themselves, anywhere in the app, no AI sees it and nothing is saved. Haven shows a calm support screen with crisis lines for 200+ countries and territories. Separately, if your own mood ratings have been low for a while, a simple rule in the code (the AI isn't involved) adds a gentle note suggesting you talk to someone.

Your data and settings

Everything you write stays in your browser. You can download a backup, restore it, or delete everything in one click. In Settings you can switch to dark mode and choose from three text sizes and five fonts. The first time you open Haven, a short page explains what it is and isn't, and walks you through turning on Chrome's on-device AI.

How I built it

Haven is a Next.js web app with no server of its own. Chats, notes and settings live in your browser, in IndexedDB and localStorage.

All the AI goes through Firebase AI Logic, using two models. Chat, memory and private Small steps use Gemini Nano, which runs inside Chrome on your computer. Insights, Write a message and cloud Small steps use a cloud Gemini model. Firebase AI Logic has a mode that falls back to the cloud automatically when the on-device model isn't available. I left it off, because it would send your words away without asking. Each model is locked to one mode, and if your computer can't run Gemini Nano, Haven asks first: "Send this message to the cloud instead?" Firebase App Check stops other sites from using the project's quota. Firebase Remote Config lets me turn off every cloud feature at once, or update the crisis line list without a new release.

Anything headed for the cloud goes through what I call the privacy shield first. Haven looks for names, places, emails and phone numbers, using pattern matching plus the on-device model when it's available, and swaps each one for a placeholder like [PERSON_1]. A preview shows your original text next to the masked version. You can tap anything to hide or show it, and nothing goes until you press Send. The reply comes back with the placeholders, and Haven puts the real names back on your computer. The request does pass through Google, which handles the masked text under its own terms. Haven itself keeps no copy. When a feature needs two cloud requests, the second sends a short summary instead of your notes, so your notes leave your computer once.

Gemini Nano is small and only sees one prompt at a time, so Haven rebuilds its memory into every prompt: the instructions, your About me notes, the running summary, your last few messages and the new one, all kept under a word budget. I kept the rules short and repeated the important ones right before the reply, because the small model follows them better that way. It still wrote too much and kept calling people "honey", so ordinary code trims replies afterwards. Private Small steps was too big for one request. Haven breaks it into a chain of small jobs: summarise your notes a piece at a time, combine the summaries, then write the plan one week at a time, with each week knowing what came before.

The crisis check is ordinary code with about 55 patterns, and it runs before any model is called. A script collected the crisis lines from public lists, and Haven shows each one with its source and date. Each of the 49 plan ideas links to the published page it came from and was checked against that page a second time.

There are 432 automated tests. Some check that no AI is called on crisis text, that unticked notes never end up in a cloud request, and that every colour pair is readable in light and dark mode. I also wrote scripts that drive Chrome through each page in light mode, dark mode and at phone width. The code is open source under Apache-2.0. I made the design decisions and built it with Claude Code.

Challenges I ran into

The on-device model has very little memory, so I had to split big jobs into short ones. Keeping personal details out of cloud requests took a masking step, a preview, and sending a short summary so your notes only go out once. The 49 plan ideas come from published guidance such as the NHS and university counselling pages, but when three checkers reopened every page, only 11 of 53 ideas held up as I'd first written them. I rewrote most and dropped a few. The interface also felt too busy for someone who is hurting, so I stripped it back several times.

Accomplishments that I'm proud of

Chat, the journal and About me stay on your device, and when something can go to the cloud, you see exactly what would be sent first. Small steps can write a full four-week plan without the cloud at all, using a small model that runs on your computer. The interface is also a lot quieter than where I started.

What I learned

A small model does better when you ask it for one thing at a time. Crisis detection should be ordinary code that runs before any model gets involved. And research I'm told is solid still needs checking. For privacy, people shouldn't have to take my word for it, which is why there are previews and the code is open.

What's next for Haven

The plan ideas haven't been reviewed by a clinician, and Haven is not medical care. I still need to try the private mode on a real Gemini Nano setup to see how the plans read.

The Read more list is a small first version of something I'd like to build properly. It would be a much bigger library of reading, matched to what you're going through and offered in Chat as well as Small steps. A clinician would review every page before it shipped, and the links would be re-checked on a schedule so they don't go stale. I'd add short motivational quotes only from public domain or properly credited sources. Haven would still run without a server, so the links would stay a fixed list that code picks from, with no scraping while you use the app.

Whether or not Haven wins anything here, I want to bring it to Android and iOS, with the model running on the phone wherever the phone can handle it. That's where it could reach the most people, since they wouldn't need a computer to use it. Prize money would go toward higher cloud limits for people whose devices can't run a local model, and toward having a clinician review the plan ideas.

Another plan will be to add a voice section to make it such that it allows the user to speak to the application instead of just typing it out where it might be more difficult to express themselves.

Code: https://github.com/owjd03/haven

Try it out: https://haven-882c1.web.app/

Built With

  • chrome-prompt-api
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-remote-config
  • gemini-api
  • gemini-nano
  • hybrid-ai
  • indexeddb
  • next.js
  • on-device-ai
  • react
  • tailwindcss
  • typescript
  • vitest
Share this project:

Updates

Submission history