Refleva - AI-Powered Mental Health Journaling Platform

Inspiration

Mental health challenges affect millions of people worldwide, yet barriers like cost, stigma, and limited access to professional care prevent many from seeking help. I noticed that traditional journaling apps lack intelligent analysis and personalized insights that could help users understand their emotional patterns. Additionally, there's a significant gap between self-reflection tools and professional therapy, which would be extremely useful to merge.

What it does

Refleva solves this by combining the therapeutic benefits of journaling with AI technology to provide:

  • Accessible mental health support for individuals who may not have access to counseling services
  • Personalized emotional insights through AI analysis of journal entries, helping users recognize patterns in their mental state
  • Bridging the gap between self-reflection and professional care by enabling secure sharing with therapists
  • Gamified wellness tracking that makes mental health management engaging and sustainable through habits, tasks, and achievement systems

Features

Journaling

Multiple Entry Types: Users can create different types of journal entries to capture various aspects of their mental state:

  • Events: Record significant moments and experiences
  • Reflections: Deep dive into understandings about self
  • Core Memories: Preserve important positive experiences
  • Rants: Safe space for venting frustration and negative emotions

AI-Powered Mood Detection: Every journal entry is automatically analyzed using Hugging Face's Llama 3.2 to detect emotional state, classifying entries into different mood categories.

Automatic Tag Generation: Extracts 4-6 relevant tags from each entry, capturing themes, emotions, and topics. These tags enable powerful search and pattern recognition, helping users discover connections across their journaling history.

Interactive 3D Mood Room

Visual Emotional Representation: A unique 3D room visualization built with Three.js that dynamically reflects the user's current mood through:

  • Color-coded lighting that changes based on emotional state
  • Customizable themes
  • Progressive room decoration unlocked through achievements
  • Immersive environment that makes emotional awareness tangible and engaging

Gamification Elements: Room objects and decorations are unlocked as users earn badges, creating motivation for consistent journaling and habit completion.

AI Chat Coach

Context-Aware Conversations: An intelligent AI assistant powered by Llama 3.3 that:

  • Accesses relevant journal entries based on conversation context
  • Provides personalized coaching and reflection prompts
  • References past experiences to offer meaningful support

Intelligent Topic Extraction: The system automatically identifies and tracks discussion topics from chat conversations, enabling users and therapists to understand recurring themes and concerns.

Habits & Task Management

Long-Term Habit Tracking: Users can create and manage habits that support their mental wellness journey, with progress tracking over extended periods.

Daily Task System: Daily tasks automatically reset each day, helping users build consistent routines.

Streak Tracking: The system tracks consecutive days of task completion and journaling, providing motivation through streak counters.

Therapist Integration

Secure Sharing System: Users can securely connect with their therapists to selectively share journal entries and insights.

Therapist Dashboard: Dedicated portal for mental health professionals featuring:

  • Client management interface
  • AI-powered topic analysis that summarizes client concerns from chat and emotional patterns
  • Access to shared journal entries and insights

Analytics & Insights

Profile Statistics: Comprehensive tracking of:

  • Total entries by type
  • Task completion rates
  • Journaling streaks
  • Overall engagement metrics

Mood History: Visual representation of emotional patterns over time, helping users identify trends and triggers.

Badge System: Achievement system that rewards milestones like:

  • Consistent journaling (7-day, 30-day streaks)
  • Habit completion
  • Task completion achievements

Goal Setting: Users can set and track goals with different time horizons, providing structure for long-term mental wellness objectives.

User Experience

Modern, Responsive Design: Clean, intuitive interface built with Tailwind CSS that works seamlessly across devices.

Privacy-First Architecture:

  • RLS ensures complete data isolation
  • Secure OAuth authentication via Supabase
  • Users maintain full control over what data is shared with therapists

How we built it

Frontend: I built the application using Next.js 14 with TypeScript and the App Router, with the UI styled in Tailwind CSS.

3D Visualization: The mood room is created in Blender and rendered with Three.js and React Three Fiber.

AI Integration: Integrated Hugging Face's API to leverage multiple AI models:

  • Llama 3.3 70B Instruct for the conversational AI coach and complex analysis
  • Llama 3.2 3B Instruct for fast mood classification and tag extraction

Database & Authentication: Supabase SQL schema. Implemented Row Level Security (RLS) policies for privacy.

State Management: Zustand for managing application state efficiently across the application.

API Architecture: Next.js API routes that handle AI processing server-side, while client-side operations use the Supabase SDK.

Challenges I ran into

AI Context Management: One of the biggest challenges was making the AI chat coach context-aware. I needed to find relevant journal entries based on conversation topics, not just keywords. I solved this by restructuring the user query to a sample output and extracting key tags from there. Using those themes, I used semantic search using embeddings and tag matching, and used the resulting journals as context for an RAG pipeline.

3D Performance: Creating a responsive 3D mood room that updates in real-time while maintaining smooth performance was challenging. I had to implement dynamic object visibility toggling based on badge counts, and carefully managing state updates.

Database Schema Complexity: Designing a schema that supports journal entries, habits, tasks, therapist connections, badges, and analytics while maintaining data integrity required careful planning. I used Supabase triggers to automatically update statistics and create user profiles on signup.

AI APIs: I couldn't use standard models like ChatGPT or Claude APIs because of cost. As a result, searching for free alternatives which could perform well was quite difficult. Eventually, I ended up using Llama 3.2 and used smaller, faster models (3B) for simple tasks like mood detection and larger models (70B) only for complex conversations and analysis.

State Synchronization: Keeping the UI in sync with database changes across multiple views required careful state management. I implemented a centralized store with automatic data loading and refresh mechanisms.

Accomplishments that we're proud of

Complete Productionized Application: This is a fully functional productionized application with authentication, database, AI integration, and 3D visualization all working seamlessly together.

3D Room Visualization: The interactive mood room is a unique feature that I'm quite proud of. At first, I was worried that the browser wouldn't be able to render this, as I saw in previous Three.js projects I worked on, so I had to optimize the assets to have low vertex counts, and it ended up working quite well.

Intelligent AI Integration: The AI chat coach that references past journal entries is sophisticated for the limited budget I was working with and provides effective support.

What I learned

AI Model Selection: I learned how to effectively test various models and determine which model is best for my use case, which is crucial for building efficient AI applications.

3D Web Development: Working with Three.js and React Three Fiber taught me further about 3D rendering optimization in web browsers.

Database Design: Designing a schema for this application required careful consideration of relationships, triggers, and security. There were many different related tables and creating all of this at once was quite difficult but rewarding to complete.

State Management: This was my first time using Zustand for state management and it showed me how to efficiently manage complex application state without over-engineering.

What's next for Refleva

Enhanced AI Capabilities: I plan to add more sophisticated AI features, including:

  • Predictive mood analysis to help users anticipate difficult periods
  • Personalized coping recommendations based on past successful strategies
  • Utilizing habit completion data for context in the pipeline

Advanced Analytics: Expanding the analytics dashboard with:

  • Detailed mood trend visualization
  • Correlation analysis between habits and mood
  • Expanding the dashboard for the user side as well (not just therapist portal)

Therapist Tools Enhancement: Building more tools for therapists:

  • Automated session preparation summaries
  • Growth tracking for clients

Room Customization: Offer further room customizations:

  • Uploading custom posters for room
  • Offering various object types for users to choose between
  • Making room feel more lively

Integration Ecosystem: Building integrations with:

  • Calendar apps
  • Fitness trackers
  • Meditation apps

Built With

Share this project:

Updates