# android/platform-samples architecture

> Architecture diagram of the GitHub repository android/platform-samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/android/platform-samples
- Repository: https://github.com/android/platform-samples

## Overview

##### Project type and purpose
- This is an Android “platform samples” repository: a multi-module mobile application that showcases isolated Android OS API samples.
- The `app` module is the main container that pulls together dozens of feature/sample modules under `samples/*`. Each sample module demonstrates one API or capability. There is also a `shared` library module for common theming and utilities.

##### File structure
- Top-level:
- build scripts (`build.gradle.kts`, `settings.gradle.kts`, `gradle/`, Gradle wrapper)
- `.github/workflows` (CI pipelines)
- `app/` – the Android application module
- `samples/` – dozens of feature modules (accessibility, camera, connectivity, …)
- `shared/` – shared Kotlin library for themes and utilities
- `tools/` – repo setup scripts
- The `app` module depends on `shared` and each `samples/*` module.
- CI: GitHub Actions build workflow, spotless formatting, renovate dependency updates.

##### README for additional insights
- Confirms this is a collection of sample modules, intended for demonstration only, not production.
- Instructs to open the project in Android Studio and run the `app` configuration.

##### Essential elements in detail
- Three layers: Development → Build → Runtime.
- Drill down into the module boundary: the app module depends on shared and includes each sample.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Layer
    subgraph "Development" 
        direction TB
        Developer["Developer Workstation<br/>(Android Studio, Git CLI)"]:::dev
        GitHub["GitHub Repo"]:::dev
    end

    Developer -->|"commit & push"| GitHub

    %% CI/CD Layer
    subgraph "CI/CD & Build" 
        direction TB
        CI["GitHub Actions CI/CD"]:::dev
        BuildSys["Gradle Build System"]:::build
        APK["APK Artifact"]:::build
    end

    GitHub -->|"trigger workflow"| CI
    CI -->|"invoke gradlew"| BuildSys
    BuildSys -->|"produce APK"| APK

    %% Deployment
    APK -->|"deploy"| Device["Device / Emulator"]:::runtime

    %% Runtime Layer
    subgraph "Runtime Environment"
        direction TB
        OS["Android OS"]:::runtime
        subgraph "App Runtime Modules"
            direction TB
            App["App Module<br/>(UI Shell & Navigation)"]:::module
            Shared["Shared Library<br/>(Themes & Utilities)"]:::module
            subgraph "Samples"
                direction TB
                Acc["Accessibility Samples"]:::module
                Cam["Camera Samples"]:::module
                Conn["Connectivity Samples"]:::module
                Graph["Graphics Samples"]:::module
                Loc["Location Samples"]:::module
                Med["Media Samples"]:::module
                Priv["Privacy Samples"]:::module
                Stor["Storage Sample"]:::module
                UI["UI Samples"]:::module
            end
        end
    end

    Device -->|"launch APK"| App
    App -->|"depends on"| Shared
    App -->|"loads via NavGraph"| Acc
    App -->|"loads via NavGraph"| Cam
    App -->|"loads via NavGraph"| Conn
    App -->|"loads via NavGraph"| Graph
    App -->|"loads via NavGraph"| Loc
    App -->|"loads via NavGraph"| Med
    App -->|"loads via NavGraph"| Priv
    App -->|"loads via NavGraph"| Stor
    App -->|"loads via NavGraph"| UI

    Acc -->|"invoke API"| OS
    Cam -->|"invoke API"| OS
    Conn -->|"invoke API"| OS
    Graph -->|"invoke API"| OS
    Loc -->|"invoke API"| OS
    Med -->|"invoke API"| OS
    Priv -->|"invoke API"| OS
    Stor -->|"invoke API"| OS
    UI -->|"invoke API"| OS

    %% Click Events
    click App "https://github.com/android/platform-samples/tree/main/app/src/main/java/com/example/platform/app"
    click Shared "https://github.com/android/platform-samples/tree/main/shared/src/main/java/com/example/platform/shared"
    click Acc "https://github.com/android/platform-samples/tree/main/samples/accessibility/src/main/java/com/example/platform/accessibility"
    click Cam "https://github.com/android/platform-samples/tree/main/samples/camera/camera2/src/main/java/com/example/platform/camera"
    click Conn "https://github.com/android/platform-samples/tree/main/samples/connectivity/audio/src/main/java/com/example/platform/connectivity/audio"
    click Conn "https://github.com/android/platform-samples/tree/main/samples/connectivity/bluetooth/ble/src/main/java/com/example/platform/connectivity/bluetooth/ble"
    click Graph "https://github.com/android/platform-samples/tree/main/samples/graphics/pdf/src/main/java/com/example/platform/graphics/pdf"
    click Graph "https://github.com/android/platform-samples/tree/main/samples/graphics/ultrahdr/src/main/java/com/example/platform/graphics/ultrahdr/display"
    click Loc "https://github.com/android/platform-samples/tree/main/samples/location/src/main/java/com/example/platform/location"
    click Med "https://github.com/android/platform-samples/tree/main/samples/media/ultrahdr/src/main/java/com/example/platform/media/ultrahdr/video"
    click Med "https://github.com/android/platform-samples/tree/main/samples/media/video/src/main/java/com/example/platform/media/video"
    click Priv "https://github.com/android/platform-samples/tree/main/samples/privacy/data/src/main/java/com/example/platform/privacy/data"
    click Priv "https://github.com/android/platform-samples/tree/main/samples/privacy/permissions/src/main/java/com/example/platform/privacy/permissions"
    click Stor "https://github.com/android/platform-samples/tree/main/samples/storage/src/main/java/com/example/platform/storage"
    click CI "https://github.com/android/platform-samples/blob/main/.github/workflows/build.yml"
    click BuildSys "https://github.com/android/platform-samples/blob/main/build.gradle.kts"

    %% Class Definitions
    classDef dev fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef build fill:#E6F4EA,stroke:#28A745,color:#28A745;
    classDef module fill:#FFEFD5,stroke:#FF8C00,color:#FF8C00;
    classDef runtime fill:#F0F0F0,stroke:#A0A0A0,color:#606060;
```
