
MindFlow
Mood Journal · CBT · AI Coach
MindFlow is a mental wellness app that combines mood journaling, CBT (cognitive behavioral therapy) programs, and an AI mental coach. It pairs a SwiftUI iOS app with a FastAPI + PostgreSQL backend, where the AI coach streams tokens in real time over SSE and reinjects long-term memories extracted from prior conversations into the system prompt to keep context. Mood data is correlated with HealthKit steps, sleep, and heart rate, and the product ships with three home-screen widgets, StoreKit 2 subscriptions, calendar reminders, and Notion export.
Mood-tracking apps tend to stay shallow diaries, while professional CBT coaching is expensive and hard to access. MindFlow links everyday mood logging to multi-week CBT programs and an AI coach so anyone can care for their mental health consistently.
App preview
What it does
AI Mental Coach (SSE streaming)
Chat in real time with an OpenAI-powered coach. The backend streams tokens as text/event-stream and iOS consumes them via a for-await async stream so replies type out live. It applies per-personality system prompts (warm, professional, cheerful, calm), uses CBT reframing, and surfaces crisis hotline guidance when self-harm or suicide signals are detected.
AI Coach Long-term Memory
When a conversation ends, an LLM extracts key facts worth remembering and stores them (capped at 50 per user), then reinjects recent memories into the next session's system prompt as a user profile for personalized replies. The extract-store-inject pipeline carries context across sessions.
Mood Logging & HealthKit Correlation
Log moods with intensity (1-5) and activity tags, then analyze trends. It reads HealthKit steps, sleep, and heart rate to surface correlations with emotions, and an LLM analyzes mood data to generate activity-correlation insights and recommendations as JSON.
Multi-week CBT Programs
Offers multi-week (e.g., 8-session) CBT programs built from techniques like thought records, reframing, behavioral activation, exposure, mindfulness, and core-belief work. Per-session content is seeded on the server, with some CBT content generated via Google Gemini.
Journaling, Reports & Notion Export
Write gratitude, reflection, and goal journals and receive weekly/monthly trend reports and insights aggregated from mood data. Journals can be exported to Notion pages via the Notion API (OAuth).
Routines, Achievement Badges & Breathing
Build custom wellness routines to manage habits, while an achievement rules engine awards badges and toasts on milestones for motivation. Grounding tools like 4-7-8 breathing provide immediate calm in anxious moments.
Three Home Widgets & Calendar Reminders
Refresh Quick Mood, Today's Mood, and Weekly Chart widgets through App Group shared storage. EventKit lets users schedule mood-logging and CBT reminders as calendar alerts.
Subscription, Usage Limits & Apple Sign-In
Supports StoreKit 2 subscriptions and Sign in with Apple, with the backend verifying App Store JWS transactions. The free tier caps coach messages and journals, unlocked to unlimited on premium.
How it's built
iOS Core
Apple Frameworks
Backend
AI / LLM
Auth & Security
Integrations & Infra
A full-stack split between a SwiftUI client and a FastAPI backend, with the iOS side following protocol-first Clean Architecture and the server layering router, service, and model. The AI coach uses OpenAI streaming plus a long-term memory pipeline, while CBT content is generated with Google Gemini — a purpose-specific LLM split.
- 1
App/backend separation: a SwiftUI iOS client (641 unit tests) and a FastAPI backend (526 tests) are deployed independently and communicate over REST and SSE.
- 2
Protocol-first Clean Architecture: every external dependency (API, storage, HealthKit) is abstracted behind a protocol and injected via init, so mocks swap in and ViewModels are unit-tested in isolation.
- 3
SSE token streaming: the backend emits `data: <chunk>` chunks and a `[DONE]` terminator via StreamingResponse (text/event-stream), and iOS consumes them as an async stream for a live typing effect.
- 4
AI coach long-term memory pipeline: an LLM extracts and stores memories from conversations (capped at 50 per user), then injects recent memories into the next session's system prompt to maintain context across sessions.
- 5
Purpose-specific LLM split: coach chat, mood analysis, and memory extraction run on OpenAI (gpt-4o), while CBT content generation runs on Google Gemini (gemini-2.5-flash), matching each task to a provider.
- 6
Widget/app separation with App Groups: a WidgetKit extension shares mood data with the main app through App Group storage (`group.com.junsoft.mindflow`) to keep three home-screen widgets up to date.
- 7
Subscription verification + usage gating: the backend verifies StoreKit 2 transaction JWS, and a usage limiter enforces free-tier caps on coach messages and journals before premium unlocks them to unlimited.
641 (@Test)
iOS unit tests
526
Backend tests
52
API endpoints
12
Backend routers
3
Home widgets
13
Supported locales



