# ash1ik/quiz-app architecture

> Architecture diagram of the GitHub repository ash1ik/quiz-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ash1ik/quiz-app
- Repository: https://github.com/ash1ik/quiz-app

## Overview

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: [`app/src/main/java/com/example/quizapp/viewmodel/QuizViewModel.kt`](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/viewmodel/QuizViewModel.kt) (QuizViewModel), [`app/src/main/java/com/example/quizapp/ui/theme/Theme.kt`](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/ui/theme/Theme.kt) (Theme), [`app/src/main/java/com/example/quizapp/screen/StartScreen.kt`](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/StartScreen.kt) (Start Screen), [`app/src/main/java/com/example/quizapp/screen/QuizScreen.kt`](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/QuizScreen.kt) (Quiz Screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App module"]
  node_main_activity["MainActivity<br/>Compose host<br/>[MainActivity.kt]"]
  node_start_screen["Start Screen<br/>Compose screen<br/>[StartScreen.kt]"]
  node_quiz_screen["Quiz Screen<br/>Compose screen<br/>[QuizScreen.kt]"]
  node_result_screen["Result Screen<br/>Compose screen<br/>[ResultScreen.kt]"]
  node_routes["Routes<br/>navigation map<br/>[Routes.kt]"]
  node_quiz_vm["QuizViewModel<br/>state orchestrator<br/>[QuizViewModel.kt]"]
  node_network_response["NetworkResponse<br/>response wrapper<br/>[NetworkResponse.kt]"]
  node_quiz_api_service["QuizApiService<br/>Retrofit service<br/>[QuizApiService.kt]"]
  node_quiz_question_api["QuizQuestionApi<br/>API client<br/>[QuizQuestionApi.kt]"]
  node_result_model["Result Model<br/>api model<br/>[Result.kt]"]
  node_retrofit_instance["RetrofitInstance<br/>network setup"]
  node_theme["Theme<br/>design system<br/>[Theme.kt]"]
  node_color["Color<br/>theme tokens<br/>[Color.kt]"]
  node_type["Type<br/>theme tokens<br/>[Type.kt]"]
end

subgraph group_resources["Resources"]
  node_raw_payloads["Raw payloads<br/>sample json<br/>[success.json]"]
end

subgraph group_tests["Tests"]
  node_tests_local["Unit tests<br/>jvm tests<br/>[ExampleUnitTest.kt]"]
  node_tests_android["Instrumented tests<br/>android tests"]
end

subgraph group_release["Release artifacts"]
  node_release_apk["Release APK<br/>build artifact<br/>[QuizApp.apk]"]
end

node_main_activity -->|"hosts"| node_start_screen
node_start_screen -->|"navigates"| node_routes
node_quiz_screen -->|"navigates"| node_routes
node_result_screen -->|"navigates"| node_routes
node_start_screen -->|"observes"| node_quiz_vm
node_quiz_screen -->|"observes"| node_quiz_vm
node_result_screen -->|"observes"| node_quiz_vm
node_quiz_vm -->|"loads"| node_quiz_question_api
node_quiz_question_api -->|"uses"| node_quiz_api_service
node_quiz_api_service -->|"configured by"| node_retrofit_instance
node_quiz_vm -->|"wraps"| node_network_response
node_quiz_question_api -->|"parses"| node_result_model
node_quiz_vm -->|"consumes"| node_result_model
node_theme -->|"uses"| node_color
node_theme -->|"uses"| node_type
node_quiz_screen -->|"styled by"| node_theme
node_start_screen -->|"styled by"| node_theme
node_result_screen -->|"styled by"| node_theme
node_quiz_vm -.->|"backs"| node_raw_payloads
node_tests_local -.->|"validates"| node_quiz_vm
node_tests_android -.->|"validates"| node_main_activity
node_release_apk -.->|"packages"| node_main_activity

click node_main_activity "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/MainActivity.kt"
click node_start_screen "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/StartScreen.kt"
click node_quiz_screen "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/QuizScreen.kt"
click node_result_screen "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/ResultScreen.kt"
click node_routes "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/route/Routes.kt"
click node_quiz_vm "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/viewmodel/QuizViewModel.kt"
click node_network_response "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/NetworkResponse.kt"
click node_quiz_api_service "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/QuizApiService.kt"
click node_quiz_question_api "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/QuizQuestionApi.kt"
click node_result_model "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/Result.kt"
click node_retrofit_instance "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/RetrofitInstance.kt"
click node_theme "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/ui/theme/Theme.kt"
click node_color "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/ui/theme/Color.kt"
click node_type "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/ui/theme/Type.kt"
click node_raw_payloads "https://github.com/ash1ik/quiz-app/blob/master/app/src/main/res/raw/success.json"
click node_tests_local "https://github.com/ash1ik/quiz-app/blob/master/app/src/test/java/com/example/quizapp/ExampleUnitTest.kt"
click node_tests_android "https://github.com/ash1ik/quiz-app/blob/master/app/src/androidTest/java/com/example/quizapp/ExampleInstrumentedTest.kt"
click node_release_apk "https://github.com/ash1ik/quiz-app/blob/master/app/release/QuizApp.apk"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_activity,node_start_screen,node_quiz_screen,node_result_screen,node_routes,node_quiz_vm,node_network_response,node_quiz_api_service,node_quiz_question_api,node_result_model,node_retrofit_instance,node_theme,node_color,node_type toneBlue
class node_raw_payloads toneAmber
class node_tests_local,node_tests_android toneMint
class node_release_apk toneRose
```

## Components

### App module

Core Android application code and runtime flow.

- [MainActivity](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/MainActivity.kt): Compose host · Android entry activity that boots the Compose UI tree. · `app/src/main/java/com/example/quizapp/MainActivity.kt`
- [Start Screen](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/StartScreen.kt): Compose screen · Initial quiz entry screen where the user begins the flow. · `app/src/main/java/com/example/quizapp/screen/StartScreen.kt`
- [Quiz Screen](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/QuizScreen.kt): Compose screen · Main question-answering screen driven by quiz state. · `app/src/main/java/com/example/quizapp/screen/QuizScreen.kt`
- [Result Screen](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/screen/ResultScreen.kt): Compose screen · Final outcome screen that shows score or completion state. · `app/src/main/java/com/example/quizapp/screen/ResultScreen.kt`
- [Routes](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/route/Routes.kt): navigation map · Central route definitions for moving between quiz phases. · `app/src/main/java/com/example/quizapp/route/Routes.kt`
- [QuizViewModel](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/viewmodel/QuizViewModel.kt): state orchestrator · Owns quiz state, transitions, and UI-facing data via LiveData. · `app/src/main/java/com/example/quizapp/viewmodel/QuizViewModel.kt`
- [NetworkResponse](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/NetworkResponse.kt): response wrapper · Encapsulates loading, success, and failure states for API work. · `app/src/main/java/com/example/quizapp/api/NetworkResponse.kt`
- [QuizApiService](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/QuizApiService.kt): Retrofit service · API interface describing quiz request endpoints. · `app/src/main/java/com/example/quizapp/api/QuizApiService.kt`
- [QuizQuestionApi](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/QuizQuestionApi.kt): API client · Quiz question data access boundary built on Retrofit. · `app/src/main/java/com/example/quizapp/api/QuizQuestionApi.kt`
- [Result Model](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/Result.kt): api model · Response model used to parse quiz API results. · `app/src/main/java/com/example/quizapp/api/Result.kt`
- [RetrofitInstance](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/api/RetrofitInstance.kt): network setup · Configures the Retrofit client used by the quiz API layer. · `app/src/main/java/com/example/quizapp/api/RetrofitInstance.kt`
- [Theme](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/ui/theme/Theme.kt): design system · Compose theme entry point for app-wide styling. · `app/src/main/java/com/example/quizapp/ui/theme/Theme.kt`
- [Color](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/ui/theme/Color.kt): theme tokens · Central color palette for the Compose UI. · `app/src/main/java/com/example/quizapp/ui/theme/Color.kt`
- [Type](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/java/com/example/quizapp/ui/theme/Type.kt): theme tokens · 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](https://github.com/ash1ik/quiz-app/blob/master/app/src/main/res/raw/success.json): sample json · 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](https://github.com/ash1ik/quiz-app/blob/master/app/src/test/java/com/example/quizapp/ExampleUnitTest.kt): jvm tests · Local JVM test entry point. · `app/src/test/java/com/example/quizapp/ExampleUnitTest.kt`
- [Instrumented tests](https://github.com/ash1ik/quiz-app/blob/master/app/src/androidTest/java/com/example/quizapp/ExampleInstrumentedTest.kt): android 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](https://github.com/ash1ik/quiz-app/blob/master/app/release/QuizApp.apk): build artifact · Packaged release application artifact. · `app/release/QuizApp.apk`

## Connections

- 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.
