Architecture pattern
All use cases follow this pattern:operator fun invoke() allows calling the use case as a function:
Quran use cases
Located inQuranUseCases.kt, these handle Quran reading, navigation, and bookmarks.
GetSurahListUseCase
Retrieves the list of all 114 surahs.GetSurahWithAyahsUseCase
Fetches a complete surah with all its ayahs and optional translation.GetAyahsByJuzUseCase
Retrieves all ayahs in a specific juz.GetAyahsByPageUseCase
Retrieves ayahs for a specific Quran page (mushaf page numbering).SearchQuranUseCase
Searches Quran text in Arabic or translation.Bookmark use cases
View bookmark use cases
View bookmark use cases
Reading progress use cases
View reading progress use cases
View reading progress use cases
QuranUseCases wrapper
All Quran use cases are grouped in a data class for easy injection:Khatam use cases
Located inKhatamUseCases.kt, these manage Quran completion goals and progress tracking.
CreateKhatamUseCase
Creates a new Quran reading plan.GetActiveKhatamUseCase / ObserveActiveKhatamUseCase
Retrieves the currently active khatam (one-time or reactive).MarkAyahsReadUseCase
Marks specific ayahs as read in a khatam.GetJuzProgressUseCase
Calculates progress across all 30 juz for a khatam.Status management use cases
View status management use cases
View status management use cases
Observation use cases
View observation use cases
View observation use cases
KhatamUseCases wrapper
Asma ul Husna use cases
Located inAsmaUlHusnaUseCases.kt, these provide access to the 99 names of Allah.
Prophet use cases
Located inProphetUseCases.kt, these provide information about prophets.
Use case injection pattern
In Hilt modules, use cases are typically grouped and provided together:Best practices
Single responsibility
Single responsibility
Each use case should do one thing. Don’t combine multiple repository calls in one use case unless they represent a single business operation.Good:Bad:
Use Flow for reactive data
Use Flow for reactive data
For data that changes over time, return Bad:(Note: Both patterns exist in the codebase for one-time vs. reactive needs)
Flow instead of suspend functions.Good:Keep use cases thin
Keep use cases thin
Use cases should primarily delegate to repositories. Complex business logic should be in the repository implementation or domain models.Good:Bad (calculation in use case):