How ash1ik/quiz-app works
1. Project shape
- This is a single-module Android app (app/) built with Kotlin, Jetpack Compose, ViewModel/LiveData, Retrofit, and Navigation Component.
- The repository follows the standard Android split between UI, state management, networking, resources, and tests.
2. App entry point
- MainActivity.kt is the host activity and likely bootstraps the Compose UI tree.
- From there, the app’s runtime is driven entirely by Compose screens rather than XML-based views.
3. UI / presentation layer
- screen/ contains the main user-facing flows:
- StartScreen for beginning the quiz
- QuizScreen for answering questions
- ResultScreen for the final score/outcome
- This is a screen-based architecture, with each screen responsible for rendering state and sending user actions upward.
4. Navigation boundary
- route/Routes.kt centralizes route names and screen destinations.
- Navigation is a clear boundary between the three quiz phases: start → quiz → result.
5. State management
- viewmodel/QuizViewModel.kt is the app’s core orchestration layer.
- The README explicitly calls out LiveData + ViewModel, so the UI likely observes quiz state from the ViewModel rather than managing it locally.
- This ViewModel probably holds question data, loading/error status, current index, selected answers, and final score.
6. Network / API layer
- api/ contains the Retrofit-backed integration:
- RetrofitInstance.kt for client setup
- QuizApiService.kt / QuizQuestionApi.kt for request definitions
- Result.kt for the API response model
- NetworkResponse.kt for response/state wrapping
- This layer is the external boundary to the quiz-question API described in the README.
7. End-to-end data flow
- The flow is: user opens app → StartScreen → ViewModel requests quiz data via Retrofit → API response is parsed into models → QuizScreen renders questions from ViewModel state → answers are recorded → ResultScreen shows the outcome.
- UI never talks to the network directly; the ViewModel mediates all data access and state transitions.
8. Error and success handling
- NetworkResponse.kt suggests the app uses a wrapper pattern for loading/success/failure states rather than exposing raw Retrofit calls to the UI.
- The res/raw/failed.json and res/raw/success.json files indicate the project may also include canned response payloads for testing, fallback, or demo behavior.
9. Design system
- ui/theme/ contains Color.kt, Theme.kt, and Type.kt, which define the Compose design system.
- This keeps visual styling separate from screen logic and makes the UI consistently themed across the quiz flow.
10. Android resources and packaging
- Standard Android assets are present in res/ for launcher icons, colors, strings, themes, and backup/data-extraction XML.
- The presence of key.jks, app/release/QuizApp.apk, and baseline profile artifacts indicates the repo includes a release-signed build and some startup/performance optimization artifacts, but these are supporting concerns rather than core app architecture.
11. Testing boundaries
- src/test and src/androidTest are both present, which means the project supports:
- local JVM unit tests
- instrumented Android tests
- These sit outside the runtime architecture but show the repo is structured for both logic and UI validation.
12. Overall architectural pattern
- The app is essentially a Compose MVVM client:
- Compose screens render the UI
- ViewModel/LiveData owns quiz state and business flow
- Retrofit API layer fetches remote quiz data
- Navigation routes move the user through the quiz lifecycle
- For an architecture diagram, the most important arrows are between screens ↔ ViewModel ↔ API, with navigation connecting the three screens.
Main entry points: QuizViewModel.kt QuizViewModel · Theme.kt Theme · StartScreen.kt Start Screen · QuizScreen.kt Quiz Screen
Components 18
App module
Core Android application code and runtime flow.
- MainActivity · Android entry activity that boots the Compose UI tree.
app/src/main/java/com/example/quizapp/MainActivity.kt - Start Screen · Initial quiz entry screen where the user begins the flow.
app/src/main/java/com/example/quizapp/screen/StartScreen.kt - Quiz Screen · Main question-answering screen driven by quiz state.
app/src/main/java/com/example/quizapp/screen/QuizScreen.kt - Result Screen · Final outcome screen that shows score or completion state.
app/src/main/java/com/example/quizapp/screen/ResultScreen.kt - Routes · Central route definitions for moving between quiz phases.
app/src/main/java/com/example/quizapp/route/Routes.kt - QuizViewModel · Owns quiz state, transitions, and UI-facing data via LiveData.
app/src/main/java/com/example/quizapp/viewmodel/QuizViewModel.kt - NetworkResponse · Encapsulates loading, success, and failure states for API work.
app/src/main/java/com/example/quizapp/api/NetworkResponse.kt - QuizApiService · API interface describing quiz request endpoints.
app/src/main/java/com/example/quizapp/api/QuizApiService.kt - QuizQuestionApi · Quiz question data access boundary built on Retrofit.
app/src/main/java/com/example/quizapp/api/QuizQuestionApi.kt - Result Model · Response model used to parse quiz API results.
app/src/main/java/com/example/quizapp/api/Result.kt - RetrofitInstance · Configures the Retrofit client used by the quiz API layer.
app/src/main/java/com/example/quizapp/api/RetrofitInstance.kt - Theme · Compose theme entry point for app-wide styling.
app/src/main/java/com/example/quizapp/ui/theme/Theme.kt - Color · Central color palette for the Compose UI.
app/src/main/java/com/example/quizapp/ui/theme/Color.kt - Type · Typography tokens used across the Compose UI.
app/src/main/java/com/example/quizapp/ui/theme/Type.kt
Resources
UI assets, raw payloads, and Android resource definitions.
- Raw payloads · Canned success and failure JSON payloads for demo or fallback use.
app/src/main/res/raw/success.json
Tests
Local and instrumented test sources.
- Unit tests · Local JVM test entry point.
app/src/test/java/com/example/quizapp/ExampleUnitTest.kt - Instrumented tests · Device or emulator test entry point.
app/src/androidTest/java/com/example/quizapp/ExampleInstrumentedTest.kt
Release artifacts
Signed build output and performance artifacts.
- Release APK · Packaged release application artifact.
app/release/QuizApp.apk
Connections 22
- MainActivity → Start Screen: hosts · Activity boots the Compose UI and shows the entry screen.
- Start Screen → Routes: navigates · Start screen advances into the quiz flow through shared routes.
- Quiz Screen → Routes: navigates · Quiz screen moves between question and result destinations.
- Result Screen → Routes: navigates · Result screen can return to the start or other destinations.
- Start Screen → QuizViewModel: observes · Start screen reacts to ViewModel state and triggers quiz start.
- Quiz Screen → QuizViewModel: observes · Quiz screen renders questions and answer state from the ViewModel.
- Result Screen → QuizViewModel: observes · Result screen reads final score and completion state from the ViewModel.
- QuizViewModel → QuizQuestionApi: loads · ViewModel requests quiz data through the API boundary.
- QuizQuestionApi → QuizApiService: uses · API client delegates endpoint calls to the Retrofit service interface.
- QuizApiService → RetrofitInstance: configured by · Retrofit instance supplies the underlying HTTP client and converter setup.
- QuizViewModel → NetworkResponse: wraps · ViewModel exposes loading/success/failure quiz state through a wrapper.
- QuizQuestionApi → Result Model: parses · API responses are mapped into strongly typed result models.
- QuizViewModel → Result Model: consumes · ViewModel uses parsed results to drive quiz progress and scoring.
- Theme → Color: uses · Theme composes the shared color palette.
- Theme → Type: uses · Theme composes the shared typography tokens.
- Quiz Screen → Theme: styled by · Quiz screen is rendered with the shared Compose theme.
- Start Screen → Theme: styled by · Start screen uses the shared Compose theme.
- Result Screen → Theme: styled by · Result screen uses the shared Compose theme.
- QuizViewModel → Raw payloads: backs · Canned raw JSON may support fallback, demo, or testing flows.
- Unit tests → QuizViewModel: validates · Unit tests can exercise quiz state and logic locally.
- Instrumented tests → MainActivity: validates · Instrumented tests can verify the Android entry point and UI integration.
- Release APK → MainActivity: packages · Release artifact bundles the app built around the main activity.