Inspiration
Mental health support often feels out of reach due to cost, privacy concerns, or sheer accessibility. While journaling is a proven therapeutic technique, standard digital notebooks lack depth, and full AI chatbots can sometimes feel ungrounded or insensitive during mental crises.We were inspired to build MindFlow AI to bridge this gap: an AI-powered, privacy-first mental wellness companion that turns daily self-reflection into actionable insights. Our goal was to create a safe space where users can log their thoughts, understand their underlying emotional patterns, receive personalized coping mechanisms, and instantly access crisis resources when struggling—all without worrying about their sensitive data being misused.
What it does
MindFlow AI blends private journaling with local machine learning to support emotional wellbeing:Private Journaling & Emotion Analysis: Text entries are encrypted at rest using Fernet encryption. The engine breaks down entries into multi-dimensional metrics, analyzing mood, stress, energy, burnout risk, and motivation levels.Reflective Chat Companion: Powered by Ollama running qwen2.5:3b, offering empathetic reflection with a deterministic fallback mechanism if the local LLM is offline.Contextual Coping Engine: Uses a LinUCB Contextual Bandit algorithm to recommend real-time coping strategies. The model learns over time based on user feedback to balance exploration and exploitation.Semantic Memory: Utilizes vector embeddings to search past journal entries via cosine similarity, helping users connect present feelings to past experiences.Safety & Crisis Screening: A multi-layered screening system detects severe distress signals (e.g., hopelessness, suicidal ideation) and immediately surfaces country-aware crisis resources without logging sensitive user triggers.
How we built it
MindFlow AI is built on a modern, asynchronous microservices-friendly architecture:Frontend: Built with Next.js 14 (App Router), React 18, and TypeScript, styled using Tailwind CSS. State management is handled via Zustand, and analytics charts are rendered with Recharts.Backend: A high-performance FastAPI service written in Python 3.11, using SQLAlchemy 2.0 (async) with SQLite/PostgreSQL and Pydantic v2 for data serialization.AI & Machine Learning Infrastructure:LLM: Hosted via Ollama using qwen2.5:3b.Embeddings & Vector Index: BAAI/bge-small-en-v1.5 model via sentence-transformers paired with a CPU-based FAISS vector store.Reinforcement Learning: A pure-Python implementation of the LinUCB algorithm.DevOps & Security: Full orchestration via Docker Compose and Nginx reverse proxy, with JWT authentication (HS256) and Fernet encryption for journal data.
Challenges we ran into
Ensuring High Safety with Low Latency: Balancing immediate safety screening with low-latency user experience was critical. We designed a fast lexical/regex layer for instant distress signal recognition before passing text through deeper AI pipelines.Offline Resilience & Degradation: Running LLMs locally via Ollama can lead to resource bottlenecks on modest hardware. We built a deterministic fallback mock system to ensure the app remains fully functional even if the LLM service drops.Pure-Python Matrix Operations: To keep container sizes small and dependencies lean, we wrote the LinUCB matrix operations without heavy linear algebra libraries, requiring careful vectorization and state serialization.
Accomplishments that we're proud of
Built an End-to-End Local AI Architecture: Successfully deployed a fully local, privacy-first pipeline integrating an LLM (qwen2.5:3b), sentence embeddings (BAAI/bge-small-en-v1.5), and a FAISS vector index operating seamlessly on standard CPU hardware.Implemented Lightweight Contextual RL: Engineered a pure-Python LinUCB contextual bandit algorithm from scratch without external heavy dependencies like NumPy, enabling real-time, adaptive coping strategy recommendations with low computational overhead.Designed a High-Recall Safety Engine: Created a fast, non-judgmental distress screening mechanism that detects crisis signals and routes users to country-aware emergency resources without logging sensitive user triggers or compromising privacy.Built Graceful Degradation & Resilience: Developed a robust fallback layer that automatically switches to deterministic mock responses if the local LLM becomes unavailable, ensuring uninterrupted app functionality.Complete Product Lifecycle Integration: Took the project from concept to a production-ready repository featuring a modern Next.js 14 frontend, FastAPI backend, Docker orchestration, and high test coverage across core AI and safety services.
What we learned
Safety First in Mental Health Tech: Screening for crisis signals must prioritize recall over precision while maintaining empathetic, non-judgmental messaging. Contextual Reinforcement Learning: Contextual bandits offer an incredibly lightweight yet powerful way to deliver real-time personalization without needing vast training datasets.Layered Clean Architecture: Separating domain logic from infrastructure (FastAPI, FAISS, Ollama) made debugging and writing unit tests exponentially faster.
What's next for MindFlow AI
On-Device Local Model Optimization: Quantize and adapt smaller local LLMs (such as LLaMA 3.2 1B/3B or Phi-3) directly in-browser using WebGPU, enabling 100% offline, zero-latency chat responses and emotion tracking.Multimodal Wellness Tracking: Expand input modalities beyond text to include voice tone analysis, daily sleep metrics, and wearable health data (e.g., HRV and physical activity) for richer wellness insights.LLM-Assisted Asymmetric Safety Verification: Upgrade the emergency screening framework with a secondary LLM classifier that can escalate risk detection while strictly enforcing safety guardrails to prevent false negatives.Expanded Crisis Resource Database: Partner with international mental health organizations to expand country-aware emergency helplines and localized support directories globally.Clinical Report Export: Allow users to export anonymized, encrypted summary reports (such as mood timelines, burnout indicators, and coping trends) to share with licensed therapists or medical professionals.
Built With
- alembic
- bcrypt
- compose
- css
- docker
- faiss
- fastapi
- fernet
- linucb
- next.js
- ollama
- postgresql
- pyjwt
- python
- qwen2.5
- react
- recharts
- sentence-transformers
- sqlalchemy
- sqlite
- tailwind
- typescript
- zustand

Log in or sign up for Devpost to join the conversation.