Lueur is an AI companion app where Luna tends to your emotional garden. Built with Flutter, Django REST Framework, and Groq's openai/gpt-oss-20b for warm, near-instant replies in English and Arabic — with built-in crisis-language detection to keep sensitive moments away from the AI and pointed at real people who can help.
// Headers "Authorization": "Bearer <firebase_id_token>" // Request body (user_id is NOT sent — derived server-side) { "emoji": "😔", "thoughts": "I feel very overwhelmed with everything lately", "history": [] // optional } // Response (user_id derived from Firebase token) { "id": 42, "user_id": "7", // server-set, not client input "emoji": "😔", "thoughts": "I feel very overwhelmed...", "ai_response": "aw no, that's a lot to carry 💜 what's weighing on you most right now?", "created_at": "2026-04-02T19:00:00Z", "crisis_flagged": false }
Firebase-authenticated REST API — all endpoints require a Bearer token. Identity is derived server-side from the verified Firebase token. /api/v1/ is the current path prefix; the unprefixed /api/ routes still work temporarily for app versions that haven't migrated yet.
user/assistant roles and role/content keys are accepted, and the oldest messages are trimmed past 12,000 characters — or a context_flag to soften her tone right after an exercise. Luna signals the end of a chat with [SESSION_END] in her reply, which also updates her short note about you for next time. Crisis language (English & Arabic) is detected before any AI call and short-circuits to a caring message with real help and crisis_flagged: true. If Luna can't reply right now, you get an honest fallback line with "fallback": true and id: 0 — and nothing is saved.id returns a plain 404, never leaking whether the entry exists for someone else.{"confirm": true} in the body — missing or false returns 400 without deleting anything. Rate-limited to 5/minute per user given how destructive it is.reported_text is snapshotted standalone, so the report stays valid even if the original entry is later edited or deleted. Reviewed by staff in Django admin.full_name, phone_number, bio, date_of_birth, gender. Firebase identity fields are read-only./api/v1/auth/verify/ for existing clients.0 on an unsaved fallback replyEvery layer chosen for speed, reliability, and developer experience.
Copy-paste ready code for Flutter, Python, and cURL.
final token = await FirebaseAuth.instance .currentUser!.getIdToken(); final response = await dio.post( 'https://web-production-f8628 .up.railway.app /api/v1/companion/generate/', options: Options(headers: { 'Authorization': 'Bearer $token', }), data: { 'emoji': emojiPath, 'thoughts': controller.text, 'history': conversationHistory, }, ); final entry = MoodEntryModel .fromJson(response.data); // check entry.aiResponse for [SESSION_END] // if response.data['fallback'] == true: nothing was // saved (id is 0) — let the user resend
final token = await FirebaseAuth.instance .currentUser!.getIdToken(); final response = await dio.get( 'https://web-production-f8628 .up.railway.app /api/v1/companion/history/', options: Options(headers: { 'Authorization': 'Bearer $token', }), ); final List entries = (response.data as List) .map((json) => MoodEntryModel.fromJson(json) ).toList();
import requests BASE = "https://web-production-f8628 .up.railway.app" HEADERS = {"Authorization": "Bearer <firebase_id_token>"} # Generate response (with conversation history) res = requests.post( f"{BASE}/api/v1/companion/generate/", headers=HEADERS, json={ "emoji": "😔", "thoughts": "I feel overwhelmed", "history": [], } ) entry = res.json() print(entry["ai_response"])
# Generate AI response curl -X POST \ https://web-production-f8628 .up.railway.app /api/v1/companion/generate/ \ -H "Authorization: Bearer <firebase_id_token>" \ -H "Content-Type: application/json" \ -d '{"emoji":"😔","thoughts":"I feel tired"}' # Get full history curl \ -H "Authorization: Bearer <firebase_id_token>" \ https://web-production-f8628 .up.railway.app /api/v1/companion/history/
# Log a breathing exercise curl -X POST \ https://web-production-f8628 .up.railway.app /api/v1/companion/activity/ \ -H "Authorization: Bearer <firebase_id_token>" \ -H "Content-Type: application/json" \ -d '{"entry_type":"breathing","payload":{"duration_seconds":90}}' # Log a sudoku session curl -X POST \ https://web-production-f8628 .up.railway.app /api/v1/companion/activity/ \ -H "Authorization: Bearer <firebase_id_token>" \ -H "Content-Type: application/json" \ -d '{"entry_type":"sudoku","payload":{"solved":true,"duration_seconds":240,"difficulty":"medium"}}' // Response (201) { "id": 51, "user_id": "7", "entry_type": "sudoku", "payload": { "solved": true, "duration_seconds": 240, "difficulty": "medium" }, "created_at": "2026-08-25T19:00:00Z" }
# Delete one entry (owned by the authenticated user) curl -X DELETE \ https://web-production-f8628 .up.railway.app /api/v1/companion/entries/51/delete/ \ -H "Authorization: Bearer <firebase_id_token>" # 204 No Content on success, 404 if not yours / doesn't exist # Delete every entry for the authenticated user curl -X DELETE \ https://web-production-f8628 .up.railway.app /api/v1/companion/entries/delete-all/ \ -H "Authorization: Bearer <firebase_id_token>" \ -H "Content-Type: application/json" \ -d '{"confirm": true}' // Response (200) { "deleted_count": 12 }
# Flag a Luna response for moderation review curl -X POST \ https://web-production-f8628 .up.railway.app /api/v1/companion/report/ \ -H "Authorization: Bearer <firebase_id_token>" \ -H "Content-Type: application/json" \ -d '{"reported_text":"...","reason":"offensive_harmful"}' // Response (201) { "detail": "Report submitted." }
final token = await FirebaseAuth.instance .currentUser!.getIdToken(); final response = await dio.get( 'https://web-production-f8628 .up.railway.app /api/v1/companion/weekly-letter/', options: Options(headers: { 'Authorization': 'Bearer $token', }), ); // Response { "letter": "Hey friend, ...", "stats": { "entry_count": 5, "dominant_emoji": "😔", "streak": 5, "week_start": "2026-03-29", "week_end": "2026-04-05" } }
Fully documented · Firebase Auth · Live on Railway · Flutter-first