How massamagro/f1-trivia2 works
Project type and purpose
• This is an Android mobile application implementing a trivia-style game about Formula 1.
• It follows a layered architecture (MVVM + Repository pattern), pulls data from external REST APIs (F1 data and Wikipedia), transforms and caches it locally, and presents quizzes to the user with a leaderboard.
File structure
• Top-level module “app” (Android application with Gradle Kotlin DSL).
• Under app/src/main/java/com/vozmediano/f1trivia:
• data layer:
– network/api: Retrofit service interfaces (F1Service, WikiService)
– network/model: DTOs for API responses
– local: Room database (Database classes, DAOs, Entities, Converters)
– repository implementations that coordinate network ↔ local ↔ domain mapping
• domain layer:
– Repository interfaces (F1CircuitRepository, WikiRepository, etc.)
– Domain models (Quiz model and F1 data models)
– Use-case classes encapsulating business rules (e.g. WhoWonAtCircuitAndSeasonUseCase)
• ui layer:
– Activities and ViewModels organized by feature (login, main menu, game, leaderboard, settings)
– Adapters (ScoreboardAdapter)
– Theme and utility classes
• Tests: androidTest and unit test directories
README
• Confirms: trivia game, automatic question generation based on rules, uses open F1 API, leaderboard tracks consecutive correct answers.
Main components
a. UI layer
• Activities & Fragments
• ViewModels
b. Domain layer
• Use Cases
• Domain Models
• Repository Interfaces
c. Data layer
• Repository Implementations
• Network Module (Retrofit + DTOs)
• Local Module (Room DB, DAOs, Entities, Converters)
d. External services
• Ergast F1 API (or other free F1 data API)
• Wikipedia API
e. Android system
• Application class (F1TriviaApplication)
• Jetpack components (LiveData / Coroutine scope)
Relationships and data flows
• UI → ViewModel (user actions & state observations)
• ViewModel → Use Cases (invoke business logic)
• Use Cases → Repository Interface (abstract data access)
• Repository Impl → Network & Local modules
• Check local cache via DAOs
• Fetch fresh data via Retrofit services if needed
• DTOs ↔ Entities ↔ Domain models using Mappers
• Persist Entities in Room database
• External APIs ↔ Repository Impl
• Data flows back up to UI via LiveData or StateFlow
Architectural patterns & design principles
• MVVM (Separation of concerns, testable ViewModel)
• Repository pattern (abstract data sources)
• Use-case driven domain layer (single responsibility, clear business rules)
• Layered architecture (Presentation → Domain → Data)
• Network caching strategy with Room and Retrofit
Detailed elements
• Application startup: F1TriviaApplication initializes DI (if any)
• Repository implementations coordinating Room DAOs and Retrofit services
• Use cases representing each trivia rule/query
• UI screens (Activities) per feature: Login, Main Menu, Game, Leaderboard, Settings
• Data transformation via mappers
• Caching strategy (query local first, then API)