refactor(web): move website into turbo app workspace
This commit is contained in:
parent
2664804e91
commit
b4e626a868
66 changed files with 318 additions and 298 deletions
96
README.md
96
README.md
|
|
@ -1,11 +1,20 @@
|
|||
# Dimension Lab Website
|
||||
|
||||
Standalone React runtime for the Dimension Lab system overview dashboard.
|
||||
Turbo/Bun workspace for the Dimension Lab system overview dashboard and its
|
||||
reusable React component library.
|
||||
|
||||
This project is not a Homepage customization and does not depend on Homepage
|
||||
runtime, frontend code, or configuration. The dashboard will be model-driven:
|
||||
the reusable renderer stays content-free, while environment-specific data lives
|
||||
in validated dashboard model state.
|
||||
the reusable UI package stays content-free, while environment-specific data
|
||||
lives in validated dashboard model state inside the web app.
|
||||
|
||||
## Workspace Layout
|
||||
|
||||
- `apps/web`: Vite React website, Bun API server, model fixtures, Drizzle
|
||||
persistence, Playwright e2e checks, and container build.
|
||||
- `packages/ui`: reusable dashboard React components, design tokens,
|
||||
shadcn/radix primitives, generic fixtures, and Storybook.
|
||||
- `docs/superpowers`: migration specs and execution plans used for this repo.
|
||||
|
||||
## Development
|
||||
|
||||
|
|
@ -18,18 +27,18 @@ This MVP uses Drizzle with Bun SQLite for local file-backed persistence.
|
|||
|
||||
## Scripts
|
||||
|
||||
- `bun run dev`: start the local Vite development server with a Bun API proxy.
|
||||
- `bun run check`: run TypeScript checks.
|
||||
- `bun run test`: run Vitest.
|
||||
- `bun run dev`: start the web app dev runtime through Turbo.
|
||||
- `bun run check`: run TypeScript checks in all workspaces.
|
||||
- `bun run test`: run the unit test stage in all workspaces.
|
||||
- `bun run test:unit`: run Vitest explicitly as the unit test stage.
|
||||
- `bun run test:e2e`: build and run Playwright browser smoke and QA checks.
|
||||
- `bun run test:qa`: run the MVP release gate.
|
||||
- `bun run build`: build the production app.
|
||||
- `bun run preview`: preview the production build.
|
||||
- `bun run storybook`: start the component explorer on port 6006.
|
||||
- `bun run build-storybook`: build the static Storybook review artifact.
|
||||
- `bun run db:generate`: generate Drizzle migrations from the server schema.
|
||||
- `bun run db:check`: validate migration consistency.
|
||||
- `bun run test:qa`: run the release gate through Turbo.
|
||||
- `bun run build`: build the UI package, production website, and Bun server.
|
||||
- `bun run preview`: preview the production web build.
|
||||
- `bun run storybook`: start the UI package component explorer on port 6006.
|
||||
- `bun run build-storybook`: build the UI package static Storybook artifact.
|
||||
- `bun run db:generate`: generate web app Drizzle migrations.
|
||||
- `bun run db:check`: validate web app migration consistency.
|
||||
|
||||
## Persistence
|
||||
|
||||
|
|
@ -40,14 +49,14 @@ URL is:
|
|||
DATABASE_URL=file:./data/dimensionlab.sqlite
|
||||
```
|
||||
|
||||
SQLite files under `data/` are ignored. Drizzle schema lives in
|
||||
`src/lib/server/db/schema.ts`; tracked migrations live in `drizzle/`. Runtime
|
||||
startup applies the checked-in dashboard migrations before reads or writes. If
|
||||
the app is launched from outside the repo tree, set `DASHBOARD_MIGRATIONS_DIR`
|
||||
to the tracked migrations directory. The current driver is `bun:sqlite`, which
|
||||
keeps this repo installable in the Bun workflow. The store boundary is isolated
|
||||
so a later Postgres driver can replace the SQLite connection without changing
|
||||
the dashboard model or renderer.
|
||||
SQLite files under `data/` and `apps/*/data/` are ignored. Drizzle schema lives
|
||||
in `apps/web/src/lib/server/db/schema.ts`; tracked migrations live in
|
||||
`apps/web/drizzle/`. Runtime startup applies the checked-in dashboard migrations
|
||||
before reads or writes. If the app is launched from outside the web app tree,
|
||||
set `DASHBOARD_MIGRATIONS_DIR` to the tracked migrations directory. The current
|
||||
driver is `bun:sqlite`, which keeps this repo installable in the Bun workflow.
|
||||
The store boundary is isolated so a later Postgres driver can replace the
|
||||
SQLite connection without changing the dashboard model or renderer.
|
||||
Stored dashboard documents pass through a version migration boundary before
|
||||
reads or writes; the MVP supports `dashboard.v1` and fails unsupported versions
|
||||
with an explicit migration error.
|
||||
|
|
@ -55,25 +64,26 @@ with an explicit migration error.
|
|||
## Seed Data
|
||||
|
||||
The initial Dimension Lab dashboard lives in
|
||||
`src/lib/model/fixtures/dimensionlab.ts` as validated model data. It includes
|
||||
the first-screen telemetry, service groups, status strip, weather module,
|
||||
Iconify icon identifiers, links, and datasource references. Values that are not
|
||||
live yet are labeled as fallback values in the data so later datasource adapters
|
||||
can replace them without changing presentation components.
|
||||
`apps/web/src/lib/model/fixtures/dimensionlab.ts` as validated model data. It
|
||||
includes the first-screen telemetry, service groups, status strip, weather
|
||||
module, Iconify icon identifiers, links, and datasource references. Values that
|
||||
are not live yet are labeled as fallback values in the data so later datasource
|
||||
adapters can replace them without changing presentation components.
|
||||
|
||||
## Runtime Shape
|
||||
|
||||
The browser app is built with Vite and React. Local development starts Vite for
|
||||
HMR and a loopback Bun API server for `/api/*` routes. Production uses a small
|
||||
Bun HTTP server at `build/index.js` to serve the Vite `dist/` assets and JSON
|
||||
API routes. The current persistence runtime is Bun because the MVP SQLite
|
||||
driver is `bun:sqlite`.
|
||||
The browser app in `apps/web` is built with Vite and React. Local development
|
||||
starts Vite for HMR and a loopback Bun API server for `/api/*` routes.
|
||||
Production uses a small Bun HTTP server at `apps/web/build/index.js` to serve
|
||||
the Vite `apps/web/dist/` assets and JSON API routes. The current persistence
|
||||
runtime is Bun because the MVP SQLite driver is `bun:sqlite`.
|
||||
|
||||
## Storybook
|
||||
|
||||
Storybook covers the reusable UI components with generic fixtures only. Stories
|
||||
must not import environment-specific dashboard content; the presentation layer
|
||||
accepts labels, values, icons, status, and links through typed props.
|
||||
Storybook lives with `packages/ui` and covers the reusable UI components with
|
||||
generic fixtures only. Stories must not import environment-specific dashboard
|
||||
content; the presentation layer accepts labels, values, icons, status, and links
|
||||
through typed props.
|
||||
|
||||
## MVP QA Gate
|
||||
|
||||
|
|
@ -106,27 +116,29 @@ belong in validated model data, not reusable components.
|
|||
|
||||
## Deployment Notes
|
||||
|
||||
The production build emits Vite client assets under `dist/` and a Bun server
|
||||
entry at `build/index.js`. A minimal deployment flow is:
|
||||
The production build emits Vite client assets under `apps/web/dist/` and a Bun
|
||||
server entry at `apps/web/build/index.js`. A minimal deployment flow is:
|
||||
|
||||
```sh
|
||||
bun install --frozen-lockfile
|
||||
bun run build
|
||||
cd apps/web
|
||||
DATABASE_URL=file:/data/dimensionlab.sqlite HOST=0.0.0.0 PORT=3000 bun build/index.js
|
||||
```
|
||||
|
||||
Mount `/data` or set `DATABASE_URL` to another persistent SQLite path. If the
|
||||
process starts outside the repository root, set `DASHBOARD_MIGRATIONS_DIR` to
|
||||
the checked-in `drizzle/` directory so startup migrations can run.
|
||||
the checked-in `apps/web/drizzle/` directory so startup migrations can run.
|
||||
|
||||
### Internal Container
|
||||
|
||||
The checked-in `Containerfile` builds the React client and Bun server into a
|
||||
runtime image. For the Dimension Lab internal host, run it behind Caddy on a
|
||||
loopback port and mount persistent state at `/data`:
|
||||
The checked-in `apps/web/Containerfile` builds the React client and Bun server
|
||||
from the workspace root into a runtime image. For the Dimension Lab internal
|
||||
host, run it behind Caddy on a loopback port and mount persistent state at
|
||||
`/data`:
|
||||
|
||||
```sh
|
||||
podman build -t localhost/dimensionlab-website:latest .
|
||||
podman build -f apps/web/Containerfile -t localhost/dimensionlab-website:latest .
|
||||
podman run --rm \
|
||||
--publish 127.0.0.1:25341:3000 \
|
||||
--volume "$HOME/containers/dimensionlab-website/data:/data:Z" \
|
||||
|
|
@ -137,4 +149,4 @@ podman run --rm \
|
|||
The env file must provide `AGENT_CONFIG_TOKEN`. Runtime defaults inside the
|
||||
image set `HOST=0.0.0.0`, `PORT=3000`,
|
||||
`DATABASE_URL=file:/data/dimensionlab.sqlite`, and
|
||||
`DASHBOARD_MIGRATIONS_DIR=/app/drizzle`.
|
||||
`DASHBOARD_MIGRATIONS_DIR=/repo/apps/web/drizzle`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue