Inspiration
1 in 4 people have a mental health condition. 75% never get help — not because care doesn't exist, but because getting screened creates a permanent record that can affect your insurance, your job, your life.
I kept thinking: what if getting help left absolutely no trace?
What I Built
MindSafe is a privacy-first mental health screening dApp on Midnight.
An adaptive AI clinician asks dynamic questions — not static forms — and
adjusts based on your responses the way a real clinician would. The entire
conversation lives only in browser memory. No server. No database. No
localStorage. When the session ends, everything is gone.
At the end of the screening, a zero-knowledge proof is minted on the Midnight blockchain recording only the outcome — MILD, MODERATE, or SEVERE — and a cryptographic hash. Never the conversation. Never your identity.
$$\text{proof} = \text{ZK}(\text{score}) \rightarrow {\text{category}, \text{hash}}$$
The result is something that didn't exist before: a verifiable mental health screening that you can optionally share with a therapist or insurer, without revealing a single word you said.
What I Learned
Midnight's privacy model rewires how you think about data. In normal development, you design around what you store. On Midnight, you design around what you disclose — and only that. Writing the Compact contract made me realize how much unnecessary data most health apps collect simply because nobody asked "do we actually need this?"
ZK proof generation (~60–120 seconds per transaction) also taught me that real cryptographic privacy has a cost — and that cost has to be designed around, not hidden from the user.
Challenges
- Compact learning curve — almost no examples existed for health or AI use cases. Circuit errors gave one-line messages with multi-hour root causes.
- Witness wiring — getting the private
severityScorewitness to flow correctly from TypeScript into the ZK circuit without disclosure required deep SDK debugging. - Proof server latency — the Docker proof server takes 60–120s per proof. The 1AM wallet confirms the transaction, but the indexer subscription sometimes never resolves, leaving the UI stuck on "minting." I built graceful fallbacks, but it remains the biggest UX gap.
- SDK gaps —
midnight-jsv4 has breaking changes from earlier versions with limited migration guidance. I ended up reading source code and MCP tool outputs to find the correct patterns.
Built With
- 1am-wallet
- compact-(midnight-zk-language)
- docker
- gemini-api-(gemini-2.5-flash)
- midnight-js-sdk
- midnight-network
- react
- typescript
- vite
- wasm
- wsl2
Log in or sign up for Devpost to join the conversation.