Skip to content

Commit 8ce7a11

Browse files
committed
apply code review
1 parent f55c323 commit 8ce7a11

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

docs/architecture/clients/index.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ The mono-repository root directory contains three main folders.
1717

1818
## Libs
1919

20-
Historically, much of the feature logic of Bitwarden has existed within the `apps` directories, only
21-
being moved to `libs` (usually `libs/common` or `libs/angular`) if it needed to be shared between
22-
multiple clients.
20+
Historically, much of the feature logic of Bitwarden has existed within the `apps/` directories,
21+
only being moved to `libs/` (usually `libs/common/` or `libs/angular/`) if it needed to be shared
22+
between multiple clients.
2323

2424
We are attempting to move to a more modular architecture by creating additional libs that are more
25-
feature-focused and more accurately convey team code ownership.
25+
feature-focused and which more accurately convey team code ownership.
2626

2727
- `common`: Common code shared between all the clients including CLI
28-
- `angular`: Low-level Angular specific utilities used by all the visual clients
28+
- `angular`: Low-level Angular utilities used by all the visual clients
2929
- `node`: Used to be shared code for CLI and Directory Connector CLI, but since directory connector
3030
no longer uses the same version of libs this module is deprecated
3131
- `admin-console`: Code owned by the Admin Console team
@@ -38,15 +38,21 @@ feature-focused and more accurately convey team code ownership.
3838
- `platform`: Code owned by the Platform team
3939
- `vault`: Code owned by the Vault team
4040

41-
For more on this approach, check out the
41+
### Background
42+
43+
More on this approach can be found in the
4244
[Nx documentation](https://nx.dev/concepts/more-concepts/applications-and-libraries):
4345

4446
> place 80% of your logic into the `libs/` folder and 20% into `apps/`
4547
46-
We are doing the opposite of this right now. What code should be moved from `apps/` to `libs/`? At
47-
this time, any code in the `/apps/web/*` that doesn't have a tight coupling with the web client can
48-
be moved into a lib. For components, this means they should only be the CL, no global CSS or
49-
anything exported from web-specific modules.
48+
We are doing the opposite of this right now. The code that remains in `apps/` should be primarily
49+
concerned with bootstrapping the application and consuming and configuring code exported from
50+
`libs/`. Over time, code not meeting this criteria should be moved from `apps/` to `libs/`.
51+
52+
Any code in the `apps/` that doesn't have a tight coupling with the client can be moved into a lib:
53+
if an exported member is wholly dependent on other libs but not `apps/`, it can likely be moved to a
54+
lib itself. (More concretely, this bars components that rely on global client-specific CSS, but not
55+
components built with Tailwind and the CL.)
5056

5157
> Having a dedicated library project is a much stronger boundary compared to just separating code
5258
> into folders, though. Each library has a so-called "public API", represented by an index.ts barrel
@@ -56,10 +62,10 @@ anything exported from web-specific modules.
5662
5763
An existing example of this pattern is `@bitwarden/components`:
5864

59-
- It is used by multiple apps and other libs
65+
- It is consumed by multiple apps and other libs
6066
- It manages a clear public and private API boundary through its barrel file
61-
- Code ownership is clear--only the files within `libs/components`
62-
- The team can make independent decisions around internal folder structure and code style
67+
- Code ownership is clear--the CL team only owns the files within `libs/components`
68+
- The CL team can make independent decisions around internal folder structure and code style
6369

6470
As part of this process, we are also investigating utilizing additional tooling (such as Nx) to make
6571
creating new libs on the fly easier.

0 commit comments

Comments
 (0)