An AI-powered emotional analysis chatbot that understands what's really behind your words.
Chat naturally. Get empathetic replies. See your emotional patterns visualized in real time.
Behind Your Words is a full-stack emotional wellness app that combines:
- π€ Gemini AI β empathetic, context-aware conversational replies
- π§ HuggingFace NLP β real-time sentiment & emotion detection on every message
- π Live Dashboard β pie charts, trend lines, and emotional insights
- π Privacy-first β raw messages are never stored. Only daily aggregated summaries.
- π PDF Reports β download your emotional journey as a beautifully formatted report
| Feature | Description |
|---|---|
| π¬ Smart Chat | Gemini-powered empathetic replies with strict emotional focus |
| π Emotion Detection | Detects joy, sadness, anger, fear, love, surprise per message |
| π Sentiment Tracking | Positive / Neutral / Negative classification in real time |
| ποΈ Dashboard Panel | Slide-in panel with pie chart + trend line chart |
| π Date Range Filter | View emotional history across any date range |
| π Daily Comparison | "You're X% happier than yesterday" motivational messages |
| π PDF Export | Download full emotional report with all historical data |
| π Auth | Smart login β auto-detects new vs existing users |
| π Guest Mode | Chat & see session stats without signing in |
| π API Key Rotation | Auto-rotates through 13 Gemini keys to maximize uptime |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND (React + Vite) β
β ββββββββββββ ββββββββββββββββ βββββββββββββββββββββββββ β
β β ChatPage β β DashboardPanelβ β LoginModal β β
β ββββββ¬ββββββ ββββββββ¬ββββββββ ββββββββββββ¬βββββββββββββ β
β β β β β
β ββββββΌββββββββββββββββΌβββββββββββββββββββββββΌβββββββββββββ β
β β Zustand Store + Axios API Service β β
β ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ
β HTTP
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ
β BACKEND (FastAPI) β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ β
β β /chat β β /save-daily β β /report (PDF) β β
β ββββββββ¬βββββββ ββββββββ¬ββββββββ ββββββββββ¬ββββββββββββ β
β β β β β
β ββββββββΌβββββββ ββββββββΌββββββββββββββββββββΌββββββββββββ β
β β NLP Service β β Supabase Service Client β β
β β + Chatbot β β (bypasses RLS for backend ops) β β
β β Service β βββββββββββββββββββββββββββββββββββββββββ β
β ββββββββ¬βββββββ β
βββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EXTERNAL SERVICES β
β Google Gemini API β HuggingFace Models β Supabase DB β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.11+
- Node.js 18+
- A Supabase project
- A Google AI Studio API key
git clone https://github.com/yourusername/behind-your-words.git
cd behind-your-wordscd backend
pip install -r requirements.txt
cp .env.example .env
# Fill in your keys in .envbackend/.env
GEMINI_API_KEY=your_gemini_key_here
GEMINI_API_KEYS_EXTRA=key2,key3,key4 # optional β for key rotation
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your_anon_key
SUPABASE_SERVICE_KEY=your_service_role_keycd frontend
npm install
cp .env.example .env
# Fill in your Supabase keysfrontend/.env
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your_anon_key
VITE_API_BASE_URL=http://localhost:8000Run this in your Supabase SQL Editor:
CREATE TABLE daily_emotions (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE,
date date NOT NULL,
happy_percent numeric(5,2) DEFAULT 0,
sad_percent numeric(5,2) DEFAULT 0,
neutral_percent numeric(5,2) DEFAULT 0,
top_emotions jsonb DEFAULT '[]',
UNIQUE(user_id, date)
);
ALTER TABLE daily_emotions ENABLE ROW LEVEL SECURITY;# Windows β just double-click or run:
start.bat
# Manual:
# Terminal 1
cd backend && python -m uvicorn app.main:app --reload --port 8000
# Terminal 2
cd frontend && npm run devOpen http://localhost:5173 π
User types a message
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β FastAPI /chat endpoint β
β β
β βββββββββββββββββββ ββββββββββββββ β
β β Gemini AI β β NLP Models β β
β β (reply) β β (emotion + β β
β β β β sentiment) β β
β ββββββββββ¬βββββββββ βββββββ¬βββββββ β
β ββββββββββ¬βββββββββ β
β βΌ β
β { reply, sentiment, emotion } β
βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
Frontend stores in Zustand (in-memory)
β
βΌ
Dashboard reads from same store β live charts
β
βΌ
On dashboard open β saves to Supabase daily_emotions
β
βΌ
PDF report fetches from Supabase β full history
behind-your-words/
βββ π backend/
β βββ app/
β β βββ api/ # chat, auth, analysis routes
β β βββ services/ # chatbot (Gemini) + nlp (HuggingFace)
β β βββ schemas/ # Pydantic models
β β βββ core/ # config (env vars)
β β βββ db/ # Supabase client
β βββ tests/ # pytest + Hypothesis property tests
β βββ requirements.txt
β
βββ βοΈ frontend/
β βββ src/
β βββ components/ # ChatWindow, DashboardPanel, LoginModal, Navbar
β βββ pages/ # ChatPage
β βββ services/ # api.js, supabaseClient.js
β βββ store/ # Zustand chatStore
β βββ utils/ # formatters.js
β
βββ π start.bat # One-click launcher (Windows)
# Backend β property-based tests with Hypothesis
cd backend
pytest tests/ -v
# Frontend β Vitest + Testing Library
cd frontend
npm testTest coverage includes:
- Property 1: NLP always returns valid classifications
- Property 2: Daily percentages are bounded [0, 100]
- Property 3: Upsert idempotency (one row per user per day)
- Property 4 & 5: Comparison message correctness
- Property 6: PDF contains required fields
- Property 7: Chat response schema completeness
- β Raw chat messages are never stored in any database
- β Only daily aggregated summaries (percentages + emotion counts) are saved
- β Row Level Security (RLS) on Supabase β users can only access their own data
- β JWT authentication on all protected endpoints
- β All secrets loaded from environment variables β nothing hardcoded
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Tailwind CSS, Recharts, Zustand, Axios |
| Backend | FastAPI, Python 3.11, Uvicorn |
| AI / NLP | Google Gemini 2.5 Flash, HuggingFace Transformers |
| Database | Supabase (PostgreSQL + Auth) |
| ReportLab | |
| Testing | pytest, Hypothesis, Vitest, fast-check |
MIT Β© 2026 Behind Your Words