Lumina is an AI-powered journaling companion. This package is its Dart backend, built on Genkit and served over HTTP with shelf. It pairs with a Flutter client.
- Mood analysis —
analyzeMoodFlowreads a journal entry and returns a mood label plus a confidence score, using a Gemini prompt defined in prompts/analyzeMood.prompt. - Journaling coach —
journalCoachFlowgenerates a single open-ended reflection question for an entry, streaming the response back to the client token-by-token. It calls thegetRecentEntriestool to pull the user's journal history for context (see prompts/journalCoach.prompt). - Persistence — journal entries are stored locally in SQLite via Drift (lib/database.dart).
- HTTP middleware — request logging, API-key auth, and CORS are layered
onto the Genkit flows via shelf
Pipelinein bin/lumina_backend.dart.
bin/lumina_backend.dart Server entrypoint: defines flows, tools, middleware, and routes
lib/database.dart Drift schema (JournalEntries table) and DAO
prompts/ Dotprompt templates used by the Genkit flows
test/ Unit tests
Requires the Dart SDK (^3.11.5). Install dependencies:
dart pub get
Set the environment variables the server needs before running:
export GEMINI_API_KEY=your-gemini-api-key # get one at https://aistudio.google.com/apikey
export LUMINA_API_KEY=any-shared-secret # required by clients as the x-api-key header
dart run bin/lumina_backend.dart
The server listens on 0.0.0.0:3400 and exposes:
POST /analyzeMoodPOST /journalCoach
Both routes require an x-api-key header matching LUMINA_API_KEY, and read
the caller's identity from an x-user-id header (defaulting to
anonymous).
Regenerate Drift/Schemantic generated code after changing table or schema definitions:
dart run build_runner build --delete-conflicting-outputs
Run tests:
dart test
