# chromeos/android-google-drive-backup-sample architecture

> Architecture diagram of the GitHub repository chromeos/android-google-drive-backup-sample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chromeos/android-google-drive-backup-sample
- Repository: https://github.com/chromeos/android-google-drive-backup-sample

## Overview

This Android sample lets a user authorize Drive access, manage app text files through the activity, and optionally schedule background file updates. The README identifies the activity as the authorization and service-creation entry point, the ViewModel as the UI-to-Drive coordinator, and WorkManager as the background mechanism. Source excerpts were not provided, so relationships below rely on README statements; implementation details beyond those statements are omitted.

Main entry points: [`app/src/main/java/com/example/drivebackupsample/FileViewModel.kt`](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/FileViewModel.kt) (File ViewModel), [`app/src/main/java/com/example/drivebackupsample/MainActivity.kt`](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/MainActivity.kt) (Main activity), [`app/src/main/java/com/example/drivebackupsample/DriveUploadWorker.kt`](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveUploadWorker.kt) (Drive upload worker), [`app/src/main/java/com/example/drivebackupsample/DriveUploadWorkerFactory.kt`](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveUploadWorkerFactory.kt) (Worker factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foreground["Foreground Drive access"]
  node_activity["Main activity<br/>[MainActivity.kt]"]
  node_viewmodel["File ViewModel<br/>[FileViewModel.kt]"]
  node_extensions["Drive extensions<br/>[DriveExtensions.kt]"]
end

subgraph group_background["Background updates"]
  node_workmanager["WorkManager"]
  node_worker_factory["Worker factory"]
  node_upload_worker["Drive upload worker"]
end

subgraph group_drive["Drive storage"]
  node_drive_service["Drive service"]
  node_drive_api["Drive API"]
  node_my_drive[("My Drive files")]
end

node_user(("User"))

node_user -->|"uses controls"| node_activity
node_activity -->|"authorizes and creates"| node_drive_service
node_activity -->|"exposes actions"| node_viewmodel
node_viewmodel -->|"uses"| node_extensions
node_viewmodel -->|"makes file calls"| node_drive_api
node_drive_service -->|"provides authorized client"| node_viewmodel
node_drive_api -->|"queries and updates"| node_my_drive
node_viewmodel -->|"creates and edits text files"| node_my_drive
node_viewmodel -->|"schedules background updates"| node_workmanager
node_workmanager -->|"creates workers"| node_worker_factory
node_worker_factory -->|"creates"| node_upload_worker
node_upload_worker -->|"uses API client"| node_drive_service
node_upload_worker -->|"updates or creates files"| node_my_drive

click node_activity "https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/MainActivity.kt"
click node_viewmodel "https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/FileViewModel.kt"
click node_extensions "https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveExtensions.kt"
click node_worker_factory "https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveUploadWorkerFactory.kt"
click node_upload_worker "https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveUploadWorker.kt"

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_activity,node_viewmodel,node_extensions,node_user toneBlue
class node_workmanager,node_worker_factory,node_upload_worker toneAmber
class node_drive_service,node_drive_api,node_my_drive toneMint
```

## Components

### Foreground Drive access

- [Main activity](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/MainActivity.kt): `app/src/main/java/com/example/drivebackupsample/MainActivity.kt`
- [File ViewModel](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/FileViewModel.kt): `app/src/main/java/com/example/drivebackupsample/FileViewModel.kt`
- [Drive extensions](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveExtensions.kt): `app/src/main/java/com/example/drivebackupsample/DriveExtensions.kt`

### Background updates

- **WorkManager**
- [Worker factory](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveUploadWorkerFactory.kt): `app/src/main/java/com/example/drivebackupsample/DriveUploadWorkerFactory.kt`
- [Drive upload worker](https://github.com/chromeos/android-google-drive-backup-sample/blob/master/app/src/main/java/com/example/drivebackupsample/DriveUploadWorker.kt): `app/src/main/java/com/example/drivebackupsample/DriveUploadWorker.kt`

### Drive storage

- **Drive service**
- **Drive API**
- **My Drive files**

### Other components

- **User**

## Connections

- User → Main activity: uses controls (evidence: `README.md`)
- Main activity → Drive service: authorizes and creates (evidence: `README.md`)
- Main activity → File ViewModel: exposes actions (evidence: `README.md`)
- File ViewModel → Drive extensions: uses (evidence: `README.md`)
- File ViewModel → Drive API: makes file calls (evidence: `README.md`)
- Drive service → File ViewModel: provides authorized client (evidence: `README.md`)
- Drive API → My Drive files: queries and updates (evidence: `README.md`)
- File ViewModel → My Drive files: creates and edits text files (evidence: `README.md`)
- File ViewModel → WorkManager: schedules background updates (evidence: `README.md`)
- WorkManager → Worker factory: creates workers (evidence: `README.md`)
- Worker factory → Drive upload worker: creates (evidence: `README.md`)
- Drive upload worker → Drive service: uses API client (evidence: `README.md`)
- Drive upload worker → My Drive files: updates or creates files (evidence: `README.md`)
