Workspace Layout
The repository follows a clear separation between deployable applications and reusable libraries:Apps vs Libs
Applications (apps/)
Applications are the final, deployable artifacts. Each app:
- Has its own build configuration (webpack, tsconfig, etc.)
- Targets a specific platform (browser extension, desktop app, web app, CLI)
- Consumes shared libraries from
libs/ - Contains platform-specific code that doesn’t belong in shared libraries
| Application | Description | Technology |
|---|---|---|
browser | Browser extension for Chrome, Firefox, Safari, Opera | Angular + WebExtensions API |
cli | Command-line interface for automation and scripting | Node.js + Commander |
desktop | Desktop application for Windows, macOS, Linux | Angular + Electron |
web | Web vault accessible via browser | Angular |
Libraries (libs/)
Libraries contain reusable code shared across multiple applications. Each library:
- Focuses on a specific domain or functionality
- Has minimal dependencies on other libraries
- Exports a clear public API through index files
- Is framework-agnostic when possible (except Angular-specific libs)
Domain Libraries
Domain Libraries
auth- Authentication, login strategies, SSO, 2FAvault- Cipher management, folders, collectionsadmin-console- Organization and provider managementbilling- Subscription and payment handlingkey-management- Cryptographic operations, key derivation
Platform Libraries
Platform Libraries
common- Core business logic, models, servicesplatform- Platform abstractions (storage, crypto, state)angular- Angular-specific utilities and base classesnode- Node.js-specific implementations
UI Libraries
UI Libraries
components- Shared UI component library (Storybook)assets- Icons, images, fonts
Utility Libraries
Utility Libraries
tools- Generator, importer, exporter functionalitystate- State management primitivesserialization- JSON serialization utilitiesguid- GUID type definitions and utilities
Testing Libraries
Testing Libraries
core-test-utils- Common testing utilitiesstate-test-utils- State testing helpersstorage-test-utils- Storage mocking utilities
Workspace Configuration
The monorepo uses npm workspaces defined inpackage.json:
package.json
- Hoists dependencies to the root
node_modulesfor efficiency - Links local packages automatically (no need for
npm link) - Enables workspace commands like
npm run build --workspace=@bitwarden/auth
TypeScript Path Mappings
Thetsconfig.base.json defines path aliases for all libraries, enabling clean imports across the monorepo:
tsconfig.base.json
Project Structure Conventions
Each library follows a consistent internal structure:Key Conventions:
Abstractions First
Define interfaces in
abstractions/ folders before implementing servicesIndex Exports
Only export public APIs through
index.ts - keep internals privateFramework Separation
Separate Angular code (
angular/) from framework-agnostic code (common/)Colocation
Keep related files together (model, service, tests in same folder)
Dependency Guidelines
Allowed Dependencies:
- Apps can depend on any library
- Libraries should minimize cross-dependencies
- Avoid circular dependencies between libraries
- Platform libraries (
common,platform) should have minimal dependencies
Dependency Anti-Patterns:
Enterprise Code Organization
Enterprise/commercial features live inbitwarden_license/:
- Maintains clear licensing boundaries
- Enables building GPL-only versions by excluding this directory
- Follows the same organizational patterns as the open-source code
Adding New Code
When to Create a New Library:
If all answers are yes, create a new library. Otherwise, add to an existing library or app.
When to Add to an Existing App:
- Platform-specific implementation details
- Application-specific UI components
- Integration code that glues libraries together
- Code that will never be shared
Best Practices
Next Steps
Nx Workspace
Learn how Nx manages builds, caching, and task execution
Dependency Injection
Understand service registration and DI patterns