Building a Privacy-First AI Companion with Next.js, FastAPI and Ollama Developer Hassan Faryad has released MindMirror, an open-source AI companion for emotional reflection that runs entirely on local hardware via Ollama, eliminating the need for paid cloud AI APIs. Built with Next.js, FastAPI, and PostgreSQL, the app offers journaling, voice input, and CBT-style reflection pipelines while ensuring user data remains private on their own machine. Most AI applications send your conversations to a cloud LLM. I wanted to experiment with a different approach: What if an AI companion could run entirely on your own machine? That idea led me to build MindMirror — an open-source AI companion for emotional reflection that supports local LLMs through Ollama, removing the requirement for paid AI APIs. GitHub: https://github.com/HASSANFARYAD/MindMirror https://github.com/HASSANFARYAD/MindMirror Live Demo: https://mindmirror-neon-tau.vercel.app/ https://mindmirror-neon-tau.vercel.app/ What is MindMirror? MindMirror combines journaling with AI-powered reflection. Users can write about what is on their mind and explore: 🧠 Emotional patterns 🔍 Cognitive distortions 💭 Guided reflections 📊 Emotional trends over time 📈 Growth insights 🎙️ Voice journaling 🔔 Check-in reminders The goal is not to replace therapy or pretend that AI can do that. The goal is to create a structured and private space for reflection. Why Local AI? Privacy was one of the main reasons behind this project. Many AI applications rely entirely on cloud APIs, which means user conversations are sent to third-party services. With Ollama, MindMirror can run models locally. This means users can experiment with AI while keeping their journal data on their own machine. This approach combines: Local LLMs Open source User privacy Full control over data Technology Stack MindMirror is built using: Frontend Next.js React TypeScript Backend FastAPI Python Database PostgreSQL AI Components Ollama Whisper Hugging Face models Deployment Docker PWA support System Architecture The application follows a simple architecture: User ↓ Next.js Frontend ↓ FastAPI Backend ↓ AI Service Layer ↓ Ollama ↓ Local LLM ↓ Reflection & Analysis For voice journaling: Voice Input ↓ Whisper ↓ Text ↓ AI Analysis ↓ Journal Entry The Reflection Pipeline The conversation flow is inspired by CBT-style reflection patterns. The process is roughly: Detect → Validate → Examine → Ground → Next Step Detect Identify emotions, themes, and thought patterns. Validate Acknowledge feelings without judgment. Examine Explore assumptions and possible cognitive distortions. Ground Focus on practical perspectives and context. Next Step Suggest small actions or reflections. This structure helps create more useful interactions than simple question-answer chat systems. Running MindMirror Locally Clone the repository: git clone https://github.com/HASSANFARYAD/MindMirror.git https://github.com/HASSANFARYAD/MindMirror.git cd MindMirror Start the application: docker compose up Install Ollama: ollama pull llama3 After setup, the AI can run locally without requiring paid APIs. What I Learned Building MindMirror taught me several things: Local LLMs are becoming practical for real applications. Privacy can be a product feature, not just a technical detail. Prompt design matters more than expected. Voice input creates a more natural journaling experience. Full-stack AI applications require careful orchestration between frontend, backend, models, and storage. Future Improvements Some ideas I am exploring: Better emotional trend visualization Support for additional local models Memory systems More advanced voice interactions Plugin ecosystem Open Source MindMirror is fully open source. If you are interested in: Local AI Ollama Open source projects Privacy-first applications AI companions Full-stack AI systems Feel free to explore the code, fork the project, open issues, or contribute. I would appreciate feedback from developers building local AI and privacy-focused applications.