docs/architecture/persistence.mdDescribe the Persistence layer, responsible for storing and retrieving application data.
This layer:
No business logic should reside here.
⚠️ Persistence only records states computed by the Domain.
%%{init: {"class": {"hideEmptyMembersBox": true}} }%%
classDiagram
namespace Persistence {
class WordRepository
class SentenceRepository
class ExerciseRepository
class ChapterRepository
class SrsRepository
class SettingsRepository
}
class SQLiteDatabase
WordRepository --> SQLiteDatabase
SentenceRepository --> SQLiteDatabase
ExerciseRepository --> SQLiteDatabase
ChapterRepository --> SQLiteDatabase
SrsRepository --> SQLiteDatabase
SettingsRepository --> SQLiteDatabase
A repository represents a business concept used by the application, not necessarily a single SQL table.
Each repository:
WordRepositorySentenceRepositoryExerciseRepositoryWordRepository, SentenceRepository, and SrsRepository,ChapterRepositorySrsRepositorypersists:
👉 For the MVP, SRSState, SRSConfig, and SentenceState are intentionally grouped here (may be split later).
SettingsRepositoryglobal application parameters, e.g.:
Mapping between SQLite and the Domain is confined to Persistence.
Two possible implementations:
Row classes if complexity grows.In all cases:
Map<String, dynamic> leaves the Persistence layer,All technical optimisations are exclusively managed within this layer, including:
These optimisations can evolve without impacting:
Map<String, dynamic> outside PersistenceMethods must be:
❌ getAllWordsFromTable()
✔ getDueWords(chapterId)
StatsRepository.SrsRepository.Everything related to “how it is stored” or “how it is fast” belongs to Persistence, and to Persistence alone.