Live on Railway · Flutter · Groq powered

Grow through
every feeling

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.

10
Endpoints
<1s
Response time
REST
Standard
🔐
Firebase Auth required
POST /api/v1/companion/generate/
200 OK
// 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
}
// endpoints

Ten clean endpoints.
Infinite emotional support.

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.

POST
/api/v1/companion/generate/
Send an emoji + thoughts and get a warm, casual reply from Luna. Pass optional conversation history for multi-turn context — only 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.
Body: emoji, thoughts Optional: history[], context_flag Auth: Bearer token Returns: JournalEntry (+entry_type/payload) Fallback: id 0 + fallback: true, not saved Content-Type: application/json
🤖 AI Powered
GET
/api/v1/companion/history/
Retrieve journal entries for the authenticated user, ordered by most recent first — a mix of mood chats and logged activities (breathing, sudoku, drawing, letter reads). Each entry includes entry_type and payload alongside emoji, thoughts, Luna's AI response, and timestamp.
Auth: Bearer token Returns: JournalEntry (+entry_type/payload) array Ordered: newest first
📔 Journal
POST
/api/v1/companion/activity/
Log a completed activity — breathing exercise, sudoku, drawing, or weekly letter read — to the authenticated user's journal. No AI call and no crisis check; payload shape is validated per entry_type.
Body: entry_type, payload Auth: Bearer token Returns: JournalEntry (+entry_type/payload) Content-Type: application/json
🧩 Activity
DELETE
/api/v1/companion/entries/<id>/delete/
Deletes a single journal entry owned by the authenticated user. Ownership is checked in the same query as the lookup — a wrong or another user's id returns a plain 404, never leaking whether the entry exists for someone else.
Auth: Bearer token Scoped: request.user only Irreversible
🗑️ Danger
DELETE
/api/v1/companion/entries/delete-all/
Permanently deletes every journal entry owned by the authenticated user — and clears what Luna remembers about them (memory note and cached weekly letter). Requires {"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.
Body: confirm Auth: Bearer token Returns: deleted_count Irreversible
🗑️ Danger
POST
/api/v1/companion/report/
Flag an offensive, inaccurate, or otherwise problematic Luna response for moderation review — no need to leave the app. 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.
Body: reported_text, reason Optional: user_message, comment Auth: Bearer token Content-Type: application/json
🚩 Moderation
GET
/api/v1/accounts/me/
Get or update the authenticated user's profile. PATCH accepts full_name, phone_number, bio, date_of_birth, gender. Firebase identity fields are read-only.
Auth: Bearer token Returns: user profile PATCH supported
👤 Profile
DELETE
/api/v1/accounts/delete-account/
Permanently deletes the authenticated user's Firebase identity, journal entries, and local account. Firebase deletion is attempted first; if it fails nothing else is deleted and a 502 is returned. Users who can't open the app can request the same deletion by email — see the Privacy Policy.
Auth: Bearer token Irreversible Cascades: JournalEntry (+entry_type/payload)
🗑️ Danger
POST
/api/v1/accounts/verify/
Verifies a Firebase ID token and returns the linked Django user, creating it on first sight. Called right after Firebase sign-in/sign-up. Also reachable at /api/v1/auth/verify/ for existing clients.
Body: firebase_token Returns: flat user JSON Public — no Bearer token yet
🔑 Identity
GET
/api/v1/companion/weekly-letter/
A short, warm note from Luna about the authenticated user's last 7 days — a couple of things they shared and some encouragement for the week ahead, never a mood analysis, and nothing heavy brought up. Requires at least 2 entries in the past week. Returns the 2–3 paragraph note plus stats (dominant emoji, streak).
Auth: Bearer token Returns: letter + stats Min: 2 entries / week
💌 Weekly
// response schema

JournalEntry model

JournalEntry application/json
idintegerUnique identifier, auto-incremented — 0 on an unsaved fallback reply
user_idstringInternal user PK — derived from Firebase token server-side, never accepted from the client
entry_typestringOne of mood_chat, breathing, sudoku, drawing, letter_read — defaults to mood_chat
emojistringMood emoji selected by user (e.g. 😔 😊 😰) — unused for non-mood_chat entries
thoughtsstringUser's written thoughts and feelings — unused for non-mood_chat entries
ai_responsestringLuna's AI-generated reply — unused for non-mood_chat entries
payloadobjectPer-type extra data: breathing {duration_seconds}, sudoku {solved, duration_seconds, difficulty}, drawing {thumbnail_url}, letter_read {} — unused ({}) for mood_chat
created_atdatetimeISO 8601 timestamp of when entry was created
crisis_flaggedbooleanTrue if the entry's thoughts matched crisis-language detection — Groq was never called for this entry
fallbackbooleanOnly present (as true) on generate/ responses where Luna couldn't reply — nothing was saved and id is 0; let the user resend
// request lifecycle

How it works

😔
Pick mood
User selects an emoji
✍️
Write thoughts
Share what's on your mind
🌐
POST request
Send Bearer token + emoji, thoughts + optional history
🤖
GROQ AI
gpt-oss-20b processes it
💜
Luna responds
Warm response returned + saved
// built with

Production-ready stack.

Every layer chosen for speed, reliability, and developer experience.

💙
Flutter
Cross-platform mobile app powering Lueur's plant-growth UI, Firebase Auth sign-in, and real-time Luna conversations.
🐍
Django REST Framework
Battle-tested Python API framework with automatic serialization, browsable API, and clean URL routing.
⚡
GROQ — gpt-oss-20b
Ultra-fast LLM inference using GROQ's LPU chip. 10–20× faster than traditional GPU inference.
🚂
Railway Deployment
Auto-deploy from GitHub with environment variables, zero-config HTTPS, and custom domain support.
📖
OpenAPI 3.0 Docs
Auto-generated Swagger UI + ReDoc documentation with live request testing and schema download.
🔒
Firebase Auth
Every endpoint is protected. Flutter clients authenticate via Firebase; the backend verifies ID tokens and derives identity server-side.
💾
Persistent Storage
Every mood entry is saved to the database. Full journal history with timestamps and unique IDs. Fallback lines ("Luna can't reply right now") are never saved.
🛟
Crisis Detection
Journal text is checked for crisis language in English and Arabic (slang, dialect, and spelling variants included) before it ever reaches Groq. Matches short-circuit to a caring message pointing to findahelpline.com and local emergency numbers.
🧠
Cross-Session Memory
When a chat ends, Luna updates a short note — people, plans, things you enjoy — building on the last one (max ~600 characters), so future chats can pick up the thread. Deleting all entries clears it.
// code examples

Integrate in minutes.

Copy-paste ready code for Flutter, Python, and cURL.

Flutter / Dart — generate
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
Flutter / Dart — history
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();
Python — requests
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"])
cURL
# 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/
cURL — activity
# 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"
}
cURL — delete entries
# 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 }
cURL — report content
# 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." }
Flutter / Dart — weekly letter
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"
  }
}

Ready to build with
Lueur API?

Fully documented · Firebase Auth · Live on Railway · Flutter-first

Base URL: https://web-production-f8628.up.railway.app