🌿 Serenity: The Anonymous, Culturally-Adaptive Reflection Engine

💡 Inspiration

"Privacy is not a feature; it is the foundation of mental health."

Fresh off a 2nd Place win at the Peerbridge Hackathon, we realized we had tapped into a deep, unmet need. Users loved the anonymity, but we knew we could push the "Privacy" and "Culture" aspects even further.

We identified three critical gaps that inspired Serenity's architecture:

  1. The Privacy Barrier (The Nord Principle): Vulnerable groups (closeted youth, domestic violence survivors) often avoid therapy apps because of persistent profiles. Inspired by Nord Security's mission, we wanted to build a "VPN for your thoughts"—a secure tunnel where identity is never exposed.
  2. The "Clinical" Disconnect: Most apps treat users like patients to be diagnosed () rather than humans to be heard. They ask "What is wrong with you?" instead of "How are you?"
  3. The Cultural Blind Spot: Standard AI models are trained on Western datasets. We needed an engine that understands that in some cultures, "healing" implies family harmony, not just self-priority.

We built a "Digital Sanctuary"—a place where you can reflect without records.

⚙️ How We Built It

Serenity is a privacy-first Single Page Application (SPA) using the MERN Stack (MongoDB, Express, React, Node.js), powered by Google Gemini 1.5 Flash.

1. The Zero-Login Architecture (Nord Security Track)

Instead of standard authentication, we implemented an Ephemeral Session Protocol inspired by privacy-first tools like Incogni.

  • When a user visits, we generate a cryptographically secure random Session ID () stored only in the browser's Local Storage.
  • The Result: If the user clears their browser cache (), the cryptographic link is severed. The data remains in the database as orphaned, unreadable shards, effectively destroying the history. You own your identity.

2. The Culturally-Aware AI Engine

We utilized Google Gemini 1.5 Flash for its high reasoning capability. We built a Dynamic Context Injection System.

  • Based on the user's toggle (), we inject specific system instructions:
  • If , the model prioritizes communal harmony, duty, and listening.
  • If , the model prioritizes agency, boundaries, and action.

3. The Crisis Guardrail (Deterministic Safety)

We needed a rigorous safety net. If a user says "I want to end it," the AI cannot hallucinate advice; it must intervene.

  • Solution: We built a hybrid Deterministic Middleware. We run a fast, local Regex/NLP scan for high-probability trigger keywords before the request hits Gemini. If a threat is detected (), the API call is aborted immediately, and the Blue Support Interface is rendered. This reduced safety latency to .

4. The "Drift" Algorithm

To visualize emotional progress without "gamifying" it, we calculated Emotional Drift. We define the drift over a period as the variance in energy levels () and mental clarity ():

This allows us to plot a non-judgmental "weather map" of the user's resilience on the Calendar dashboard.

🚧 Challenges We Faced

The "Safety vs. Latency" Dilemma

Balancing real-time reflection with rigorous safety checks was our biggest engineering hurdle. Sending every message to a secondary LLM for safety checking introduced too much latency ().

  • Success: Moving the safety logic to a lightweight middleware layer allowed us to keep the app feeling "instant" while maintaining a strict zero-tolerance policy for self-harm content.

The Prompt Engineering Paradox

Getting the AI to sound "empathetic" without sounding "patronizing" was difficult. Early versions of the "Eastern" tone sounded too passive, and the "Western" tone sounded too aggressive.

  • Success: We used Few-Shot Prompting, feeding Gemini examples of "good" vs. "bad" reflections for each cultural persona. This stabilized the tone significantly.

🧠 What We Learned

  1. Validation is Momentum: Winning 2nd Place at Peerbridge taught us that our hypothesis was correct: people crave anonymity.
  2. Middleware Power: We gained deep appreciation for Express middleware. It is not just for routing; it is the perfect place for safety logic that keeps the AI model pure and focused.
  3. The Responsibility of AI: Building Serenity taught us that when you build for mental health, you are not just a developer; you are a steward of safety.

🚀 What's Next for Serenity

  • Client-Side Encryption: Implementing a "Vault" architecture where the encryption key lives only in the user's URL hash (Nord-style zero-knowledge architecture).
  • PWA Support: Making Serenity a downloadable mobile app for offline journaling.
  • Multilingual Expansion: Adding support for more regional languages and dialects to deepen the cultural connection.

Built with 💜 by Shrey Vijay.

Built With

Share this project:

Updates