A gentle, empathetic AI companion named Mira that chats with users about their feelings. Built with Flask and the Gemini API.
- Warm, non-judgmental responses with a safety note for crisis situations
- Clean, calming UI with chat history
- Typing indicator ("Mira is thinking…")
- Simple mood detection on each input
- Maintains the last 10 messages for context
- Backend: Flask (Python)
- Frontend: HTML, CSS, JS (vanilla)
- AI: Google Gemini via
google-genai
- Clone this repository and move into the folder.
- Create a virtual environment (optional but recommended).
- Install dependencies:
pip install -r requirements.txt
- Set your environment variables (at minimum, your Gemini API key). You can put these in a
.envfile in the project root (auto-loaded):Or set them manually:GOOGLE_API_KEY=YOUR_API_KEY GEMINI_MODEL=gemini-2.5-flash FLASK_SECRET_KEY=change-me
- On macOS/Linux:
export GOOGLE_API_KEY=YOUR_API_KEY export GEMINI_MODEL=gemini-2.5-flash export FLASK_SECRET_KEY=change-me
- On Windows (PowerShell):
setx GOOGLE_API_KEY "YOUR_API_KEY" setx GEMINI_MODEL "gemini-2.5-flash" setx FLASK_SECRET_KEY "change-me"
- On macOS/Linux:
python app.pyVisit http://localhost:5000 in your browser.
- Render/Replit: Configure a Python web service, set
GOOGLE_API_KEY(and optionalGEMINI_MODEL,FLASK_SECRET_KEY) in environment. Set start command topython app.py. - The app binds to
0.0.0.0and respects thePORTenvironment variable when present.
- Mira is supportive and not a medical professional. For crisis situations, encourage contacting a trusted person or local helpline.
- The code uses the
google-genaiPython SDK. Ensure your API key has access to the selected Gemini model.