Application Bootstrap
Entry Point
The application bootstraps fromapps/web/src/main.ts:
App Module Structure
The OSS version (apps/web/src/app/app.module.ts):
bitwarden_license/bit-web/app.module.ts and extends the OSS module with enterprise features.
Core Module
The Core Module (apps/web/src/app/core/core.module.ts) provides foundational services:
- Dependency Injection: Sets up all service providers
- Client Type: Registers as
ClientType.Web - Platform Services: Web-specific implementations (file download, platform utils, storage)
- Authentication Services: Account, auth, SSO, and user decryption services
- Cryptographic Services: Encryption, key management, and crypto functions
- State Management: Observable storage services for disk and memory
Key Services
Routing Architecture
Main Routing Module
The OSS routing module (apps/web/src/app/oss-routing.module.ts) defines the primary application routes:
Lazy Loading
The web vault extensively uses Angular’s lazy loading for code splitting:Organization Routing
Organization Routes
Fromapps/web/src/app/admin-console/organizations/organization-routing.module.ts:
Organization Route Resolution
The redirect guard determines the appropriate landing page based on permissions:Route Guards
Authentication Guards
From@bitwarden/angular/auth/guards:
authGuard: Ensures user is authenticatedlockGuard: Checks if vault is lockedunauthGuardFn: Redirects authenticated users away from auth pagestdeDecryptionRequiredGuard: Handles trusted device encryption flows
Organization Permission Guards
Location:apps/web/src/app/admin-console/organizations/guards/
Organization Permissions Guard
File:org-permissions.guard.ts
The primary guard for organization access control:
Enterprise Organization Guard
File:is-enterprise-org.guard.ts
Checks if an organization is enterprise tier:
Additional Guards
is-paid-org.guard.ts: Checks if organization has a paid subscriptionorg-redirect.guard.ts: Handles automatic redirects to appropriate org pages
Other Guards
deepLinkGuard: Handles deep linking scenariospremiumInterestRedirectGuard: Manages premium feature interest flowssetupExtensionRedirectGuard: Redirects users to extension setup when appropriate
Multi-Tenant Organization Features
The web vault is designed for enterprise multi-tenant organizations:Permission Helpers
From@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction:
canAccessOrgAdmin(org)- Can access admin consolecanAccessVaultTab(org)- Can view organization vaultcanAccessMembersTab(org)- Can manage memberscanAccessGroupsTab(org)- Can manage groupscanAccessReportingTab(org)- Can view reportscanAccessSettingsTab(org)- Can modify settings
Organization Structure
Organization Policies
Organizations can enforce policies on members:Environment Selection
The web vault supports region selection for cloud deployments: File:apps/web/src/app/components/environment-selector/environment-selector.component.ts
Feature Flags
The web vault uses feature flags for gradual rollouts:State Management
The web vault uses RxJS observables for state management:- Observable Storage: Disk and memory storage with reactive updates
- Account Service: Active account state management
- Organization Service: Organization membership and permissions
- Sync Service: Data synchronization with server
Testing
The web vault uses Jest for unit testing:.spec.ts extension.