feat: set up Flutter project with drift database, Riverpod providers, and LLM service layer
- Configure dependencies: drift 2.32.x, flutter_riverpod 3.3.1, fl_chart 1.2.x, flutter_local_notifications 21.x, local_auth 3.x, and supporting packages - Drop riverpod_generator (incompatible analyzer version with drift_dev 2.32.x); convert all providers to manual Riverpod 3.x API using Notifier<T> and typed families - Define drift schema: MoodEntries, Activities, EntryActivities, Tags, EntryTags, LlmInsights, UserSettings with four DAOs (mood, activity, insight, settings) - Add LLM service abstraction (LlmService) and MediaPipe implementation - Fix SettingsDao.delete → deleteByKey to avoid shadowing drift's inherited delete method
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
// ─── Mood Entries ────────────────────────────────────────────────────────────
|
||||
|
||||
class MoodEntries extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
DateTimeColumn get timestamp => dateTime()();
|
||||
IntColumn get moodLevel => integer()(); // 1–5
|
||||
TextColumn get note => text().nullable()();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
}
|
||||
|
||||
// ─── Activities ──────────────────────────────────────────────────────────────
|
||||
|
||||
class Activities extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get name => text().withLength(min: 1, max: 50)();
|
||||
IntColumn get iconCodepoint => integer()(); // Icons codepoint value
|
||||
TextColumn get colourHex =>
|
||||
text().withLength(min: 7, max: 7)(); // e.g. #FF5733
|
||||
BoolColumn get isCustom => boolean().withDefault(const Constant(false))();
|
||||
IntColumn get sortOrder => integer().withDefault(const Constant(0))();
|
||||
}
|
||||
|
||||
// ─── Entry ↔ Activity (many-to-many) ─────────────────────────────────────────
|
||||
|
||||
class EntryActivities extends Table {
|
||||
IntColumn get entryId => integer().references(MoodEntries, #id)();
|
||||
IntColumn get activityId => integer().references(Activities, #id)();
|
||||
|
||||
@override
|
||||
Set<Column> get primaryKey => {entryId, activityId};
|
||||
}
|
||||
|
||||
// ─── Tags ────────────────────────────────────────────────────────────────────
|
||||
|
||||
class Tags extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get name => text().withLength(min: 1, max: 30)();
|
||||
TextColumn get colourHex => text().withLength(min: 7, max: 7)();
|
||||
}
|
||||
|
||||
// ─── Entry ↔ Tag (many-to-many) ───────────────────────────────────────────────
|
||||
|
||||
class EntryTags extends Table {
|
||||
IntColumn get entryId => integer().references(MoodEntries, #id)();
|
||||
IntColumn get tagId => integer().references(Tags, #id)();
|
||||
|
||||
@override
|
||||
Set<Column> get primaryKey => {entryId, tagId};
|
||||
}
|
||||
|
||||
// ─── LLM Insight Cache ───────────────────────────────────────────────────────
|
||||
|
||||
class LlmInsights extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get type => text()(); // 'weekly' | 'monthly' | 'query'
|
||||
TextColumn get promptHash => text()(); // SHA256 of the prompt — cache key
|
||||
TextColumn get responseText => text()();
|
||||
DateTimeColumn get generatedAt =>
|
||||
dateTime().withDefault(currentDateAndTime)();
|
||||
DateTimeColumn get rangeStart => dateTime().nullable()();
|
||||
DateTimeColumn get rangeEnd => dateTime().nullable()();
|
||||
}
|
||||
|
||||
// ─── Settings ────────────────────────────────────────────────────────────────
|
||||
|
||||
class UserSettings extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get key => text().withLength(min: 1, max: 50).unique()();
|
||||
TextColumn get value => text()();
|
||||
}
|
||||
Reference in New Issue
Block a user