Skip to content

Structure & Architecture

Math Mantra is an Android app organized with clear separation of concerns, strong accessibility, and content-driven gameplay sourced from localized Excel files.

  • Presentation layer: Fragments/UI and feature orchestration
  • Domain layer: Use cases, models, repository interfaces
  • Data layer: Excel-backed content loader and in-memory cache
  • Core utilities: TTS, dialogs, grading, accessibility helpers
  • DI: Hilt modules for wiring repositories and use cases
  • Startup: Splash preload + background caching

Repository Layout

  • App code: app/src/main/java/com/zendalona/zmantra/
  • Assets: app/src/main/assets/
  • Questions Excel: assets/questions/{lang}.xlsx (e.g., en.xlsx, ml.xlsx, etc.)
  • User guide HTML: assets/userguide/{lang}.html
  • Resources: app/src/main/res/

Presentation Layer

Domain Layer

Note: Question loading currently uses BaseGameFragment + ExcelQuestionLoader + QuestionCache directly. QuestionRepository/LoadQuestionsUseCase exists for future alignment with a repository abstraction.

Data Layer

Dependency Injection (Hilt)

Startup Flow

  • SplashScreen.kt
  • Shows welcome GIF via Glide.
  • If accessibility enabled, periodically announces โ€œLoading questionsโ€.
  • Preloads current-difficulty questions via QuestionCache.preloadCurrentDifficultyModes.
  • Navigates to MainActivity on completion.
  • Background-preloads other difficulties afterward.

Accessibility & TTS

Localization & Difficulty

  • Localization
  • LocaleHelper.kt manages language.
  • Excel per language in assets/questions/{lang}.xlsx.
  • User guide per language in assets/userguide/{lang}.html.

  • Difficulty

  • core/Enum/Diffculty.kt โ†’ object Difficulty { SIMPLE=1, EASY=2, MEDIUM=3, HARD=4, CHALLENGING=5 }
  • DifficultyPreferences.kt persists selection.
  • Excel filtering uses difficulty strings ("1".."5").

Adding a New Game Mode

  1. Create fragment under presentation/features/game/<mode>/<Mode>Fragment.kt extending BaseGameFragment.
  2. Implement:
  3. override fun getModeName() = "<mode>" (must match Excel Mode column).
  4. override fun onQuestionsLoaded(questions: List<GameQuestion>) to render and handle logic.
  5. Use handleAnswerSubmission(...) for validation, and DialogUtils to show results/retry/correct-answer dialogs.
  6. Provide optional GIF via getGifImageView() and getGifResource().
  7. Add navigation from GameFragment.
  8. Add content rows into assets/questions/{lang}.xlsx with correct Mode and Difficulty.
  9. Verify splash preloading logs and cache hits.

Assets & Resources

  • Excel questions: app/src/main/assets/questions/{lang}.xlsx
  • User guide HTML: app/src/main/assets/userguide/{lang}.html
  • Drawables/GIFs: app/src/main/res/drawable*

Key Dependencies

  • Hilt: DI
  • Apache POI: Excel parsing
  • exp4j: Expression evaluation
  • Glide: GIF loading
  • AndroidX: Fragments, Lifecycle, Preferences