# bitfireat/davx5-ose architecture

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

- Interactive diagram: https://gitdiagram.com/bitfireat/davx5-ose
- Repository: https://github.com/bitfireat/davx5-ose

## Overview

#### Purpose and Runtime
DAVx⁵ is a native Android/Kotlin application for CalDAV/CardDAV synchronization, task sync, and live WebDAV file access through Android’s Storage Access Framework. The main product module is `core`; `app-ose` supplies open-source-edition application/flavor wiring. Gradle builds the multi-module Android project via `settings.gradle.kts` and `build.gradle.kts`.

#### Application Entry and Composition
Android starts the app from manifests, then application classes initialize the shared core and OSE-specific layer. Dependency injection modules bind application variants, sync infrastructure, startup plugins, logging, and security integrations.
- `core/src/main/AndroidManifest.xml`
- `core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt`
- `app-ose/src/main/kotlin/com/davx5/ose/App.kt`

#### UI, Account Setup, and Authentication
Compose-based Activities/ViewModels expose account management, setup, collection selection, settings, push, and WebDAV mount screens. Login supports conventional URL/email discovery plus provider-specific Nextcloud, Google, and Fastmail OAuth flows. UI is a boundary over repositories and Android account/sync services.
- `core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginActivity.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginScreenViewModel.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/network/OAuthIntegration.kt`

#### Remote Discovery, Network, and Security
Service detection discovers DAV principals, home sets, and collections, persisting discovered server topology for account setup and later refresh. HTTP construction, DNS resolution, OAuth, client certificates, certificate security contexts, and Conscrypt integration form the network/security boundary to remote DAV servers.
- `core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/servicedetection/ServiceRefresher.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt`

#### Persistent Account and Service State
Room-backed `AppDatabase` stores DAV accounts, services, principals, home sets, collections, sync statistics, and WebDAV mount/document metadata. DAO-backed repositories insulate UI, discovery, sync, and provider code from storage. Schema history makes database migrations a compatibility boundary.
- `core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt`
- `core/schemas/at.bitfire.davdroid.db.AppDatabase/20.json`

#### Synchronization Orchestration
Android AccountManager/SyncAdapter and WorkManager entry points schedule and execute periodic or one-time sync. `SyncManager` selects domain-specific syncers for calendars, contacts, tasks, and JTX notes; these reconcile remote DAV resources with local Android provider state, validate conditions, record results, and notify users. Push registrations/messages can trigger or complement refresh behavior.
- `core/src/main/kotlin/at/bitfire/davdroid/sync/adapter/SyncAdapterImpl.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/sync/worker/SyncWorkerManager.kt`

#### Local Data and Format Translation
`resource` adapts app sync logic to local calendar, contacts, tasks, and JTX stores. The separate `synctools` Android library performs iCalendar/vCard parsing/generation and maps protocol objects to Android content-provider entities, including recurrence and provider-specific task/JTX contracts.
- `core/src/main/kotlin/at/bitfire/davdroid/resource/LocalCalendarStore.kt`
- `synctools/src/main/kotlin/at/bitfire/synctools/icalendar/ICalendarParser.kt`
- `synctools/src/main/kotlin/at/bitfire/synctools/mapping/contacts/ContactWriter.kt`

#### WebDAV Documents Provider
A distinct Storage Access Framework path exposes configured WebDAV mounts as Android documents. `DavDocumentsProvider` delegates browse/read/write/move operations to WebDAV operations, maintains database metadata, and uses disk/thumbnail caches for file access.
- `core/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/webdav/WebDavMountRepository.kt`
- `core/src/main/kotlin/at/bitfire/davdroid/webdav/operation/OpenDocumentOperation.kt`

Main entry points: [`core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt`](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt) (HTTP and security client), [`core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt`](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt) (Sync manager), [`core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt`](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt) (DAV resource discovery), [`core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt`](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt) (Core application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_manifest["Android manifest entry"]
  node_core_app["Core application<br/>Android application<br/>[CoreApp.kt]"]
  node_ose_app["OSE application layer<br/>flavor application<br/>[App.kt]"]
  node_login_ui["Login setup UI<br/>Compose activity/view-model<br/>[LoginActivity.kt]"]
  node_oauth["OAuth integrations<br/>authentication"]
end

subgraph group_dav["DAV services"]
  node_discovery["DAV resource discovery<br/>service detection"]
  node_refresh["Service refresher<br/>topology refresh"]
  node_http["HTTP and security client<br/>network boundary"]
  node_remote_dav(("Remote DAV servers<br/>CalDAV/CardDAV/WebDAV"))
end

subgraph group_sync["Sync pipeline"]
  node_sync_entry["Android sync scheduling<br/>SyncAdapter and WorkManager<br/>[SyncAdapterImpl.kt]"]
  node_sync_manager["Sync manager<br/>sync orchestration<br/>[SyncManager.kt]"]
  node_local_stores["Android local stores<br/>calendar/contact/task resources"]
  node_synctools["Format mapping library<br/>iCalendar/vCard translation<br/>[ICalendarParser.kt]"]
end

subgraph group_storage["Local storage"]
  node_database[("App database<br/>Room database<br/>[AppDatabase.kt]")]
  node_account_repo["Account repository<br/>DAO repository"]
end

subgraph group_documents["WebDAV documents"]
  node_documents_provider["DAV documents provider<br/>Storage Access Framework provider"]
  node_mount_repo["WebDAV mount repository<br/>mount metadata"]
  node_document_ops["WebDAV document operations<br/>file operations"]
end

node_gradle{{"Gradle multi-module build"}}

node_gradle -->|"builds"| node_core_app
node_gradle -->|"builds"| node_ose_app
node_manifest -->|"starts"| node_core_app
node_ose_app -->|"extends core"| node_core_app
node_core_app -->|"initializes"| node_account_repo
node_login_ui -->|"authenticates through"| node_oauth
node_login_ui -->|"starts setup discovery"| node_discovery
node_login_ui -->|"manages accounts"| node_account_repo
node_oauth -->|"configures auth"| node_http
node_discovery -->|"uses"| node_http
node_refresh -->|"reruns"| node_discovery
node_discovery -->|"persists topology"| node_database
node_account_repo -->|"reads and writes"| node_database
node_http -->|"secure DAV requests"| node_remote_dav
node_sync_entry -->|"executes"| node_sync_manager
node_sync_manager -->|"loads state and records results"| node_database
node_sync_manager -->|"syncs remotely"| node_http
node_sync_manager -->|"parses and maps"| node_synctools
node_synctools -->|"translates provider data"| node_local_stores
node_documents_provider -->|"loads mounts"| node_mount_repo
node_mount_repo -->|"stores metadata"| node_database
node_documents_provider -->|"delegates file access"| node_document_ops
node_document_ops -->|"uses WebDAV client"| node_http

click node_gradle "https://github.com/bitfireat/davx5-ose/blob/main/settings.gradle.kts"
click node_manifest "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/AndroidManifest.xml"
click node_core_app "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt"
click node_ose_app "https://github.com/bitfireat/davx5-ose/blob/main/app-ose/src/main/kotlin/com/davx5/ose/App.kt"
click node_login_ui "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginActivity.kt"
click node_oauth "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/network/OAuthIntegration.kt"
click node_discovery "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt"
click node_refresh "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/servicedetection/ServiceRefresher.kt"
click node_http "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt"
click node_database "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt"
click node_account_repo "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt"
click node_sync_entry "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/sync/adapter/SyncAdapterImpl.kt"
click node_sync_manager "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt"
click node_local_stores "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/resource/LocalCalendarStore.kt"
click node_synctools "https://github.com/bitfireat/davx5-ose/blob/main/synctools/src/main/kotlin/at/bitfire/synctools/icalendar/ICalendarParser.kt"
click node_documents_provider "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt"
click node_mount_repo "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/webdav/WebDavMountRepository.kt"
click node_document_ops "https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/webdav/operation/OpenDocumentOperation.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_manifest,node_core_app,node_ose_app,node_login_ui,node_oauth toneBlue
class node_discovery,node_refresh,node_http,node_remote_dav toneAmber
class node_sync_entry,node_sync_manager,node_local_stores,node_synctools toneMint
class node_database,node_account_repo toneRose
class node_documents_provider,node_mount_repo,node_document_ops toneIndigo
class node_gradle toneNeutral
```

## Components

### Android app

- [Android manifest entry](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/AndroidManifest.xml): manifest · `core/src/main/AndroidManifest.xml`
- [Core application](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt): Android application · Initializes shared core services. · `core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt`
- [OSE application layer](https://github.com/bitfireat/davx5-ose/blob/main/app-ose/src/main/kotlin/com/davx5/ose/App.kt): flavor application · `app-ose/src/main/kotlin/com/davx5/ose/App.kt`
- [Login setup UI](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginActivity.kt): Compose activity/view-model · `core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginActivity.kt`
- [OAuth integrations](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/network/OAuthIntegration.kt): authentication · Provider-specific login flows. · `core/src/main/kotlin/at/bitfire/davdroid/network/OAuthIntegration.kt`

### DAV services

- [DAV resource discovery](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt): service detection · Finds principals, home sets, and collections. · `core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt`
- [Service refresher](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/servicedetection/ServiceRefresher.kt): topology refresh · `core/src/main/kotlin/at/bitfire/davdroid/servicedetection/ServiceRefresher.kt`
- [HTTP and security client](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt): network boundary · Builds authenticated secure DAV clients. · `core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt`
- **Remote DAV servers**: CalDAV/CardDAV/WebDAV

### Sync pipeline

- [Android sync scheduling](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/sync/adapter/SyncAdapterImpl.kt): SyncAdapter and WorkManager · Runs periodic and one-time synchronization. · `core/src/main/kotlin/at/bitfire/davdroid/sync/adapter/SyncAdapterImpl.kt`
- [Sync manager](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt): sync orchestration · Selects calendar, contacts, tasks, and JTX syncers. · `core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt`
- [Android local stores](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/resource/LocalCalendarStore.kt): calendar/contact/task resources · `core/src/main/kotlin/at/bitfire/davdroid/resource/LocalCalendarStore.kt`
- [Format mapping library](https://github.com/bitfireat/davx5-ose/blob/main/synctools/src/main/kotlin/at/bitfire/synctools/icalendar/ICalendarParser.kt): iCalendar/vCard translation · Maps DAV objects to Android provider entities. · `synctools/src/main/kotlin/at/bitfire/synctools/icalendar/ICalendarParser.kt`

### Local storage

- [App database](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt): Room database · Accounts, DAV topology, sync state, and mount metadata. · `core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt`
- [Account repository](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt): DAO repository · `core/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt`

### WebDAV documents

- [DAV documents provider](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt): Storage Access Framework provider · Exposes configured WebDAV mounts as Android documents. · `core/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt`
- [WebDAV mount repository](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/webdav/WebDavMountRepository.kt): mount metadata · `core/src/main/kotlin/at/bitfire/davdroid/webdav/WebDavMountRepository.kt`
- [WebDAV document operations](https://github.com/bitfireat/davx5-ose/blob/main/core/src/main/kotlin/at/bitfire/davdroid/webdav/operation/OpenDocumentOperation.kt): file operations · Browses, reads, writes, and moves remote files. · `core/src/main/kotlin/at/bitfire/davdroid/webdav/operation/OpenDocumentOperation.kt`

### Other components

- [Gradle multi-module build](https://github.com/bitfireat/davx5-ose/blob/main/settings.gradle.kts): build · `settings.gradle.kts`

## Connections

- Gradle multi-module build → Core application: builds
- Gradle multi-module build → OSE application layer: builds
- Android manifest entry → Core application: starts
- OSE application layer → Core application: extends core
- Core application → Account repository: initializes
- Login setup UI → OAuth integrations: authenticates through
- Login setup UI → DAV resource discovery: starts setup discovery
- Login setup UI → Account repository: manages accounts
- OAuth integrations → HTTP and security client: configures auth
- DAV resource discovery → HTTP and security client: uses
- Service refresher → DAV resource discovery: reruns
- DAV resource discovery → App database: persists topology
- Account repository → App database: reads and writes
- HTTP and security client → Remote DAV servers: secure DAV requests
- Android sync scheduling → Sync manager: executes
- Sync manager → App database: loads state and records results
- Sync manager → HTTP and security client: syncs remotely
- Sync manager → Format mapping library: parses and maps
- Format mapping library → Android local stores: translates provider data
- DAV documents provider → WebDAV mount repository: loads mounts
- WebDAV mount repository → App database: stores metadata
- DAV documents provider → WebDAV document operations: delegates file access
- WebDAV document operations → HTTP and security client: uses WebDAV client
