Title: "I Built an AI Mom to Help with My Anxiety, and It's the Most Human Thing I've Ever Coded"
Description: "The story of Comfort Companion , an AI comfort companion built for a hackathon. A journey into Next.js, Genkit, and the quest for digital empathy."
tags: nextjs, react, ai, google, webdev
The Spark: A 2 AM Thought
It was 2 AM, and my mind was a whirlwind. You know those nights? When a small worry balloons into a full-blown anxiety fest. I was scrolling through my phone, looking for a distraction, but everything felt loud, demanding, and utterly unhelpful. My friends were asleep, and I didn't want to burden my family with yet another late-night spiral.
I just wanted someone to say, "It's okay, sweetheart. Let's talk it through." I craved the unconditional, non-judgmental comfort of a mother. And in that moment of quiet desperation, an idea sparked: What if I could build that? What if I could use technology not for distraction, but for genuine, gentle comfort?
That's how Comfort Companion was born—an AI companion designed to be a warm hug for your heart, a safe space for your thoughts, available anytime you need it.
How I Built It: A Stack for Empathy
Building something that feels human requires a carefully chosen stack. I didn't want a cold, robotic chatbot. I wanted something warm, responsive, and reliable.
- Framework: Next.js 15 (App Router) was a clear choice. The performance, Server Components, and overall developer experience are top-notch. It allowed me to build a fast, server-first application that feels snappy and modern.
- AI Orchestration: This was the heart of the project. I used Google's Genkit, a powerful open-source framework for building production-ready AI apps. Genkit allowed me to structure my AI logic into clean, testable "flows."
- The Brain: The AI itself is powered by Google's Gemini Pro model. Its ability to handle nuanced, context-aware conversation was perfect for creating the empathetic, motherly personality I envisioned.
- UI & Styling: I used ShadCN UI and Tailwind CSS. ShadCN provides beautifully designed, accessible components that I could easily customize. Tailwind's utility-first approach gave me the fine-grained control needed to craft the app's calming, gentle aesthetic. Every color, from the soft lavender to the creamy background, was chosen to create a tranquil environment.
- Hosting: The app is deployed on Firebase App Hosting, which made the process incredibly smooth and scalable.
The real innovation, however, was in the AI architecture. I didn't just want a simple prompt-and-response loop. I built a system of interconnected flows:
-
empatheticResponseFlow: This is the core conversational engine. Crucially, it takes the entire conversation history as context. This allows Comfort Companion to remember what you've talked about, providing deeply relevant support instead of generic, disconnected replies. -
personalizedSelfCareFlow: This is where Comfort Companion becomes more than just a listener. It uses a custom AI Tool that I built to connect to a "database" of self-care suggestions. The AI autonomously detects the user's emotion (like "stressed" or "lonely") and then uses the tool to retrieve tailored, actionable advice.
Challenges I Faced: The Rocky Road to a Gentle AI
Building something so personal wasn't without its hurdles.
1. The "Forgetful Friend" Problem: My first prototype was frustratingly forgetful. You'd mention feeling anxious, and in the next message, it would act like it had no idea. It felt disjointed and impersonal.
- The Fix: This led me to dive deep into managing conversation history. The breakthrough was creating a session-based memory system, passing an array of past messages back to the Gemini model with every new request. Suddenly, the AI could say, "You mentioned you were feeling overwhelmed earlier, how are you doing with that now?" It was a game-changer.
2. Finding the Right Tone: Writing a prompt that generates a "warm, motherly tone" is harder than it sounds. Early versions sounded either too clinical or bizarrely cheerful.
- The Fix: I spent hours refining the system prompt, adding specific instructions about using endearments ("sweetheart," "my dear"), acknowledging feelings before offering advice, and using gentle closings. It was a process of iteration and "prompt whispering" to find the perfect voice.
3. Making it Proactive, Not Annoying: I wanted the AI to feel proactive, like a real mom checking in. My first thought was to use notifications, but that felt intrusive.
- The Fix: I settled on a more subtle approach. The app detects the user's local time and offers a time-appropriate greeting when a new chat starts. A gentle "Good morning, I hope you slept well" feels infinitely more caring than a random push notification. It’s proactive, but respectful of the user's space.
What I Learned: More Than Just Code
This project taught me so much. On a technical level, I deepened my understanding of Next.js Server Actions and the power of Genkit for structuring complex AI interactions.
But on a personal level, I learned that technology doesn't have to be cold. We can intentionally design it to be a force for good, for comfort, and for connection. Building MindMother was, in a way, a form of self-care for me. In creating a tool to soothe my own anxieties, I built something I hope can bring a moment of peace to others.
Comfort Companion is my testament to the idea that the most powerful applications are the ones that meet a deeply human need. And sometimes, what we need most is just a quiet place to be heard, understood, and told that everything is going to be okay.
Thank you for reading and for considering my project.
Built With
- firebase-app-hosting
- google-gemini-pro
- google-genkit
- lucide-react
- next.js
- npm
- react
- shadcn-ui
- tailwind-css
- typescript

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