Skip to content

Commit 9a23d3f

Browse files
authored
docs: Add ADR 004 - Component Library Restructure (#1871)
2 parents 3071fdf + 056067a commit 9a23d3f

File tree

2 files changed

+135
-1
lines changed

2 files changed

+135
-1
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Component Library Restructure
2+
3+
* Status: **Accepted**
4+
* Authors: @AliceR, @vgeorge, @ifsimicoded, @dzole0311
5+
* Deciders: VEDA UI Team
6+
* As of: December 2025
7+
8+
## Context and Problem Statement
9+
10+
This work builds on broader architectural changes captured in [ADR 006: VEDA2 Architecture Refactor](./006-veda2-architecture-refactor.md). ADR 004 focuses on repository structure changes to better separate library code from runnable applications.
11+
12+
VEDA UI had a split architecture:
13+
14+
1. **Storybook** in `/storybook` (Vite, separate deps)
15+
2. **Library exports** scattered through `/app` and bundled from `/app/scripts/libs/index.ts`
16+
3. **Two build systems**: Gulp/Parcel (app + library) and Vite (Storybook)
17+
18+
This made library boundaries unclear and component discovery difficult.
19+
20+
Previously, the library exports were managed through `/app/scripts/libs/index.ts` which imported components from various locations throughout the application. This has been moved to `packages/veda-ui/src/libs/index.ts` in PR #1898.
21+
22+
```ts
23+
// Scattered exports (pre-monorepo)
24+
export { PageHero } from '$components/common/page-hero';
25+
export { CatalogContent } from './page-components';
26+
export { PageHeader, PageFooter } from './uswds-components';
27+
// ... many more scattered imports
28+
```
29+
30+
## Primary Goal: Defining Clear Boundaries
31+
32+
Define clear boundaries between library packages and runnable applications:
33+
34+
* Clear location for exportable components
35+
* Less ambiguity between “app code” and “library code”
36+
37+
## Decision Drivers
38+
39+
* **Developer experience**: Clear separation between library components and application code
40+
* **Library evolution**: Clear path toward a standalone component library
41+
* **Migration clarity**: Obvious location for new library components
42+
* **Build system modernization**: Better organization supports planned build system updates (see [v7 roadmap](#references))
43+
* **Monorepo boundaries**: Define clear boundaries between packages and applications
44+
45+
## Considered Options
46+
47+
### Option A: Keep Current Structure
48+
49+
Keep exported components scattered under the app structure.
50+
51+
**Pros:**
52+
53+
* No immediate restructuring work required
54+
* Existing imports and references remain unchanged
55+
56+
**Cons:**
57+
58+
* Continued confusion about library boundaries
59+
* Dual build system maintenance
60+
* Difficult component discovery for library consumers
61+
* No clear migration path forward
62+
63+
### Option B: Move Everything to `/storybook` Immediately
64+
65+
Relocate all library components into Storybook in one step.
66+
67+
**Pros:**
68+
69+
* Clean break from legacy structure
70+
* Unified build system immediately
71+
* Clear component organization
72+
73+
**Cons:**
74+
75+
* High-risk, large-scale migration
76+
* Potential breaking changes for existing applications
77+
* Significant coordination required across team
78+
79+
### Option C: Gradual Migration with Renamed `/core` Directory (Original Proposal)
80+
81+
Rename `/storybook` to `/core` to signal “library first”, keep Vite-based Storybook, and migrate components gradually.
82+
83+
**Pros:**
84+
85+
* Clear naming that reflects purpose (core library vs. just Storybook)
86+
* Gradual, lower-risk migration path
87+
* Maintains backward compatibility during transition
88+
* Vite build system advantages for modern component development
89+
90+
**Cons:**
91+
92+
* Temporary complexity during migration period
93+
* Requires coordination for new component placement
94+
* Doesn't establish broader monorepo structure
95+
96+
### Option D: Monorepo Structure with `/packages` and `/apps`
97+
98+
Establish a monorepo split between reusable packages and runnable apps (library code lives under `packages/`, runnable apps live under `apps/`).
99+
100+
**Trade-offs:**
101+
102+
**Pros:**
103+
104+
* Clear boundaries between package code and runnable apps
105+
* Easier component discovery
106+
* Supports evolving build tooling per-surface
107+
108+
**Cons:**
109+
110+
* Incremental migration work
111+
* Temporary ambiguity while old and new structures coexist
112+
113+
## Decision
114+
115+
**We choose Option D: Monorepo Structure with `/packages` and `/apps`**
116+
117+
During team discussion on [PR #1871](https://github.com/NASA-IMPACT/veda-ui/pull/1871), the proposal evolved from Option C to a monorepo structure. @ifsimicoded expressed skepticism about moving files around without addressing broader developer concerns, but did not oppose moving files around. @vgeorge moved forward with [PR #1898](https://github.com/NASA-IMPACT/veda-ui/pull/1898), which was merged and established the monorepo structure (`packages/veda-ui/`).
118+
119+
## Direction
120+
121+
* Keep exportable library code under `packages/veda-ui/`
122+
* Keep runnable apps under `apps/`
123+
* Storybook placement is flexible; recommendation is to colocate it with the library package (`packages/veda-ui/storybook/`) when practical
124+
* Prefer incremental migration and preserve compatibility exports during transition
125+
* Build tooling work is related but out-of-scope here and should likely be addressed in v7 (see [#1889](https://github.com/NASA-IMPACT/veda-ui/issues/1889) and [#1900](https://github.com/NASA-IMPACT/veda-ui/issues/1900))
126+
127+
## References
128+
129+
* [PR #1871](https://github.com/NASA-IMPACT/veda-ui/pull/1871) - Introduces ADR 004 (by @AliceR)
130+
* [ADR 006: VEDA2 Architecture Refactor](./006-veda2-architecture-refactor.md)
131+
* [Architecture documentation](../development/ARCHITECTURE.md)

docs/development/ARCHITECTURE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ That is why the ui repo (`veda-ui`) is used as a submodule of `veda-config`.
1515

1616
## VEDA2 Architecture Refactor
1717

18-
**Note:** In 2024, the team initiated a major architecture refactor (VEDA2) to modernize VEDA UI. See [ADR: VEDA2 Architecture Refactor](../adr/006-veda2-architecture-refactor.md) for details on the ongoing transition to a library-based approach.
18+
**Note:** In 2024, the team initiated a major architecture refactor (VEDA2) to modernize VEDA UI. See:
19+
20+
- [ADR 006: VEDA2 Architecture Refactor](../adr/006-veda2-architecture-refactor.md)
21+
- [ADR 004: Component Library Restructure](../adr/004-component-library-restructure.md) for the repo-structure direction (library under `packages/`, apps under `apps/`)
1922

2023
A user wishing to setup a new Veda instance, only has to fork `veda-config`, change the configuration variables and the content, and you are ready to launch your own instance.
2124

0 commit comments

Comments
 (0)