End-to-end recipe for running the new v3 conversational stack on your laptop. After the cleanup of the legacy MITRA v2 pipeline, this is the only supported development flow.
| Tool | Version | Notes |
|---|---|---|
| Python | 3.11+ | for the FastAPI backend |
| Node.js | 22.13.0 or 24+ | for the Vite frontend; Node 23 is intentionally blocked |
| Docker | 24+ | for Redis + Qdrant locally |
| Supabase project | — | with the v3 schema applied (see step 2) |
Open the Supabase SQL editor on your project and run the entire
scripts/migrations/v3_schema.sql file. This creates 8
tables (users, user_semantic_profiles, user_procedural_profiles,
user_longitudinal_trajectory, sessions, audit_logs,
crisis_templates, static_fallback_templates) and the RLS policies
and increment_session_count helper RPC.
You said you've already run this — keep it idempotent: the SQL uses
IF NOT EXISTS/DROP POLICY IF EXISTSso reruns are safe.
Optional seed scripts (run once per environment from the repository root):
python -m scripts.migrations.seed_fallback_templates
python -m scripts.migrations.seed_crisis_templates # writes pending rows; approve via admin APIdocker run -d --name mha-redis -p 6379:6379 redis:7-alpine \
redis-server --notify-keyspace-events Ex
docker run -d --name mha-qdrant -p 6333:6333 qdrant/qdrant:latestThen provision the v3 Qdrant collections:
python -m venv .venv && source .venv/bin/activate
pip install -r chatbotAgent/requirements.txt
python -m scripts.migrations.init_qdrantcd chatbotAgent
cp .env.example .env
# Fill secrets in .env:
# SUPABASE_SERVICE_KEY, SUPABASE_JWT_SECRET, SECRET_KEY,
# AZURE_OPENAI_API_KEY, GROQ_API_KEY, GEMINI_API_KEY, REDIS_URL.
#
# Fill non-secret runtime values in config.yaml:
# supabase.url, providers.azure_openai.endpoint, qdrant.url.
# Local config.yaml keeps auth.skip_auth=true for development without login.
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000Smoke checks (a new terminal):
curl http://127.0.0.1:8000/health
# → {"status":"healthy","service":"MindMitra Chatbot Agent","version":"3.0.0"}
curl http://127.0.0.1:8000/
# → lists /docs, /health, and POST /chatcp .env.production.example .env.local
# Set:
# VITE_SUPABASE_URL=...
# VITE_SUPABASE_PUBLISHABLE_KEY=...
npm install
npm run dev # http://localhost:8080The Vite dev server now proxies backend routes like /chat, /onboarding,
/transcribe, /me, and /speech to http://127.0.0.1:8000, so an ngrok
front-end tunnel can reach the local backend through the same public origin.
Leave VITE_BACKEND_URL unset for that mode. If you prefer to point the app
at a separate backend tunnel, set VITE_BACKEND_URL to that public URL.
- Open
http://localhost:8080and sign in (Supabase magic link). - Open the chat page. The status should settle to "here when you are".
- Type "I had a rough day" and hit send.
You should see:
- Browser console: no failed
POST /chatrequest. - Backend logs:
POST /chat turn pipeline complete ... - Chat bubble receives a single assistant reply quickly.
- In Supabase, a row appears in
audit_logs(event_type =turn_completed) and inchat_messages(legacy persistence kept for the sidebar).
| Symptom | Likely cause | Fix |
|---|---|---|
Chat returns 401 |
SUPABASE_JWT_SECRET mismatch |
Copy the project's JWT secret from Supabase → backend .env, or set auth.skip_auth: true in config.yaml locally |
Chat returns 503 |
app.mha_v3_enabled=false |
Set it back to true in config.yaml |
confirmed never arrives, only chunks |
Safety gate retried + failed → check Groq key | Verify GROQ_API_KEY and providers.groq.safety_model |
Couldn't reach the chat service toast on first send |
HTTP request failed | Confirm backend is up on VITE_BACKEND_URL and CORS allows the frontend origin |
Backend log: Redis keyspace notifications appear disabled |
Redis launched without --notify-keyspace-events Ex |
Restart Redis with the flag |
| Onboarding never advances past turn 1 | The frontend's onboarding screen is not in this codebase yet | Use the API: POST /onboarding { turn: 1 } to bootstrap |
cd chatbotAgent
pytest tests -q -m "not integration" # unit + contract suite
RUN_INTEGRATION=1 pytest tests -q # adds Qdrant/Supabase smokeFrontend lint/build:
npm run lint
npm run build- Backend: push to Railway. Put secrets/platform values from
chatbotAgent/.env.examplein Railway env, and keep non-secret behavior inchatbotAgent/config.yaml. TheDockerfilealready runsuvicorn app.main:appon$PORT. - Frontend: push to Vercel. Set every
VITE_*variable from.env.production.example. Make sureVITE_BACKEND_URLpoints at the Railway HTTPS URL.
That's it.