Skip to content

Commit 191ff4c

Browse files
authored
Update ARCHITECTURE.md (#5765)
1 parent 99ab224 commit 191ff4c

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

docs/ARCHITECTURE.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Architecture
22

33
- [Overview](#overview)
4+
- [Application Modules](#application-modules)
5+
- [Core Library Modules](#core-library-modules)
6+
- [Specialized Library Modules](#specialized-library-modules)
7+
- [Supporting Modules (Source Sets and Test Fixtures)](#supporting-modules-source-sets-and-test-fixtures)
48
- [Data Layer](#data-layer)
59
- [Data Sources](#data-sources)
610
- [Managers](#managers)
@@ -20,17 +24,45 @@
2024

2125
## Overview
2226

23-
The app is broadly divided into the **data layer** and the **UI layer** and this is reflected in the two top-level packages of the app, `data` and `ui`. Each of these packages is then subdivided into the following sub-packages:
27+
The Bitwarden Android project employs a multi-module architecture to enhance separation of concerns, maintainability, and build efficiency. This architecture distinguishes between application modules, which are user-facing, and library modules, which provide shared functionalities.
2428

25-
- `auth`
26-
- `autofill`
27-
- `platform`
28-
- `tools`
29-
- `vault`
29+
### Application modules
30+
These modules represent the entry points and primary user interfaces for the applications. They are structured with standard Android source sets to organize code for different build types and testing:
3031

31-
Note that these packages are currently aligned with the [CODEOWNERS](../.github/CODEOWNERS) files for the project; no additional direct sub-packages of `ui` or `data` should be added. While this top-level structure is deliberately inflexible, the package structure within each `auth`, `autofill`, etc. are not specifically prescribed.
32+
* **`Bitwarden.app`**: This module constitutes the Bitwarden Password Manager application. It integrates various library modules to deliver password management and secure data storage features. It is responsible for the application's top-level setup, primary navigation graph, and dependency injection rooting for password manager functionalities. The `app` module utilizes product flavors to generate different versions of the application:
33+
* `src/standard/`: Contains code and resources specific to the 'standard' product flavor. Builds produced from this flavor are intended for distribution via the Google Play Store and include functionality dependent on Google Play Services.
34+
* `src/fdroid/`: Contains code and resources specific to the 'fdroid' product flavor. Builds produced from this flavor are intended for distribution via F-Droid. This flavor is stripped of all Google Play Services libraries and, as such, does not contain features like push notifications for real-time syncing.
35+
* `src/debug/`: Contains code and resources specific to the 'debug' build type (e.g., for enabling debug-specific features, configurations, or alternative API endpoints), which can be combined with any product flavor.
36+
* `src/release/`: Contains code and resources specific to the 'release' build type (e.g., for ProGuard/R8 configurations, release-specific API keys, or analytics configurations), which can be combined with any product flavor.
37+
* **`Bitwarden.authenticator`**: This module implements the Bitwarden Authenticator application. Its purpose is to store and generate two-factor authentication (2FA) codes, such as Time-based One-Time Passwords (TOTP), directly on the user's device. It provides the user interface and logic for managing authenticator accounts and displaying codes, functioning as a standalone authenticator application.
38+
* `src/debug/`: Contains code and resources specific to the 'debug' build type of the Authenticator.
39+
* `src/release/`: Contains code and resources specific to the 'release' build type of the Authenticator.
3240

33-
The responsibilities of the data layer are to manage the storage and retrieval of data from low-level sources (such as from the network, persistence, or Bitwarden SDK) and to expose them in a more ready-to-consume manner by the UI layer via "repository" and "manager" classes. The UI layer is then responsible for any final processing of this data for display in the UI as well for receiving events from the UI, updating the tracked state accordingly.
41+
### Core Library Modules
42+
43+
These libraries provide foundational capabilities utilized by application modules and other feature-specific libraries:
44+
45+
* **`Bitwarden.core`**: A fundamental library containing shared business logic, essential data models (entities, value objects), domain-specific utilities, and common interfaces. It is designed with minimal or no direct Android framework dependencies to ensure high reusability and testability.
46+
* **`Bitwarden.data`**: Manages the data layer for the applications. Responsibilities include defining repositories, data sources (for network APIs and local persistence like Room), data transformation logic (mappers), and managing data synchronization. It abstracts data origin and storage details from other parts of the system.
47+
* **`Bitwarden.network`**: Encapsulates all network communication logic. This includes API client setup (e.g., using Retrofit or Ktor), defining request/response models for network operations, and handling network interceptors and authentication.
48+
* **`Bitwarden.ui`**: A library module providing common UI elements, theming resources (colors, typography, shapes), custom Jetpack Compose components, base UI classes, and UI-related utility functions. It ensures a consistent user experience across different features and applications.
49+
50+
### Specialized Library Modules
51+
52+
These libraries offer more targeted functionalities:
53+
54+
* **`Bitwarden.authenticatorbridge`**: Serves as an interface or bridge facilitating communication and integration between the `Bitwarden.authenticator` module's functionalities and the`Bitwarden.app` module. This allows for controlled interaction while maintaining modular decoupling.
55+
* **`Bitwarden.annotation`**: Contains custom Java/Kotlin annotations used throughout the project. These annotations support compile-time code generation (e.g., for dependency injection with Dagger Hilt, or database schema generation with Room) and provide metadata for other development tools.
56+
57+
### Supporting Modules (Source Sets and Test Fixtures)
58+
59+
The project structure includes conventional Gradle source sets and test fixture modules that support
60+
development and testing:
61+
62+
* **`src/main/`**: The primary source set of a module, containing its functional code.
63+
* **`src/test/`**: Contains local unit tests (JVM-based) for the associated module.
64+
* **`src/testFixtures/`**: Provides shared testing utilities, mock objects, sample data, or helper
65+
functions reusable across various test modules.
3466

3567
## Data Layer
3668

0 commit comments

Comments
 (0)