Skip to content

Database Service

The DatabaseService is the heart of Nokken's data persistence layer, providing a structured interface to the SQLite database.

Key Responsibilities

  • Managing the SQLite database schema and versioning
  • Providing CRUD operations for all entity types
  • Abstracting database operations from the rest of the application
  • Handling error management through a custom DatabaseException class

Interactions with Other Services

  • Feature modules: All feature modules interact with the database service to store and retrieve data
  • State providers: Riverpod state providers use the database service to fetch data
  • ValidationService: Database operations use validation to ensure data integrity

Database Schema

The database consists of several tables:

  • medications: Stores medication information
  • taken_medications: Records which medications have been taken
  • bloodwork: Stores lab results and appointment information
  • mood_entries: Stores daily mood and wellness metrics