Skip to content

example monorepo using turbo #2650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 15 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
.DS_Store
node_modules
/.svelte-kit
/package
/coverage
.svelte-kit
package
coverage
*.log
*.swp
/.vercel_build_output
/.vercel
/build-local
/.history
/build
/bin
.vercel_build_output
.vercel
build-local
.history
build
bin
server/ui-server
server/api
server/ui/assets
/test-results/
/playwright-report/
/playwright/.cache/
/dist
/audits
test-results/
playwright-report/
playwright/.cache/
dist
audits
go.work
go.work.sum
.turbo
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
turbo lint-staged
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodejs 22.14.0
bun 1.2.8
194 changes: 194 additions & 0 deletions MIGRATION_PROPOSAL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Temporal UI Monorepo Migration

_Oregon Trail Edition_

![Oregon Trail](https://videos.openai.com/vg-assets/assets%2Ftask_01jr8g85k1e19b8evhnw16qfza%2Fimg_0.webp?st=2025-04-07T15%3A04%3A07Z&se=2025-04-13T16%3A04%3A07Z&sks=b&skt=2025-04-07T15%3A04%3A07Z&ske=2025-04-13T16%3A04%3A07Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=3d249c53-07fa-4ba4-9b65-0bf8eb4ea46a&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=qN3YoUWOQ5PHD%2Fq92pL8lk2E5%2FZFHDzzkbID7eFmQhI%3D&az=oaivgprodscus)

## Overview

The Temporal UI team has loaded up their wagon, packed their crates,
and is ready to embark on a bold journey westward β€” toward the promised land of
a unified monorepo.

They’ve heard stories of faster builds, cleaner architecture, and shared
packages dancing freely across apps. But they’re also wary. The road is long,
and the terrain is unfamiliar. Some say entire builds have been lost to circular
dependencies. Others whisper of CI pipelines that vanished in the night.

And yet, there is hope. With careful planning, a trusty `pnpm` steed, and the
powerful `turborepo` oxen to pull us through, this migration can succeed. The
path won’t be easy β€” but it will be worth it.

## Goals

- Consolidate related packages and apps into a single workspace.
- Enable shared logic (schemas, components) to be centrally maintained.
- Cleanly separate OSS and internal UI code.
- Improve performance, coordination, and publishing workflows.

## Target Monorepo Layout

```
temporal-ui/
β”œβ”€β”€ apps/
β”‚ β”œβ”€β”€ cloud-ui/
β”‚ β”œβ”€β”€ codec-server/
β”‚ β”œβ”€β”€ dev-server/
β”‚ └── oss-ui/
β”œβ”€β”€ packages/
β”‚ β”œβ”€β”€ schemas/
β”‚ β”œβ”€β”€ oss-components/
β”‚ └── holocene/
β”œβ”€β”€ .github/
β”œβ”€β”€ package.json
β”œβ”€β”€ pnpm-workspace.yaml
└── turbo.json
```

## Repo/App/Package Relationships

```mermaid
flowchart TD
subgraph private-ui-repo["πŸ”’ Private UI Repo"]


subgraph Packages
schemas["πŸ“¦ schemas"]
oss-components["πŸ“¦ oss components"]
holocene["πŸ“¦ holocene"]
end

subgraph Apps
oss_ui["🧱 oss-ui"]
cloud_ui["☁️ cloud-ui"]
ui-server["πŸ–₯️ ui-server (Go)"]
codec_server["πŸ§ͺ codec-server (local codec development tool)"]
end

end

subgraph Public Repos
ui-repo["🧱 ui mirror"]
ui-server-repo["🧱 ui-server"]
end

%%dependencies
schemas --> oss_ui
holocene --> oss_ui
oss-components --> oss_ui
oss_ui --> cloud_ui

%% states
npm_release["πŸ“¦ Release Artifacts + NPM Publish"]

%% CI/CD pipeline
subgraph CI/CD
schemas -->|on release| npm_release
holocene -->|on release| npm_release
oss_ui -->|on release| npm_release -->|copy source code to public mirror| ui-repo
ui-server -->|on release| ui_server_assets["πŸ–₯️ build ui-server/assets"] -->|push to main| ui-server-repo
cloud_ui -->|on release| vercel_release["☁️ Vercel Deployment"]
ui-server-repo -->|on release| docker_release["🐳 Docker Image & Release Artifacts"]
end
```

## Migration Plan

### Phase 1: Bootstrapping

- Initialize `pnpm` workspaces.
- Move `schemas` to `packages/schemas`.
- Keep `ui/` in root during the transition.

### Phase 2: Component Extraction

- Move UI components to `packages/oss-components`.
- Move Holocene into `packages/holocene`.

### Phase 3: Appification

- Convert `ui` to `apps/oss-ui`.
- Move `dev-server` and `codec-server` into `apps/`.
- Update `pnpm dev` to launch all apps using `turbo dev`.

### Phase 4: OSS/Public Split

- Mark `oss-ui` as private.
- Introduce `cloud-ui` as a separate app.
- Mirror OSS elements to a public GitHub repo via CI/CD.

## Build & Release Strategy

### Packages

- Semantic versioning for all shared packages.
- Publish to npm.
- Align GitHub release tags with package versions.
- Use `prepublishOnly` for builds and validation.

### Apps

- Each app can be built and deployed independently.
- Releases tied to GitHub tags.

### OSS Sync

- Use CI pipelines to:
- Sync public packages/UI.
- Mirror release tags and changelogs.

## Tooling

### pnpm

- Fast installs.
- Deterministic dependency resolution.
- Efficient disk space usage.

### turborepo

- Task-based pipelines for build, lint, test, publish.
- Incremental builds.
- Local + remote caching.
- Parallel execution.

## Benefits

- Shared logic is centralized and testable.
- Fast builds and CI via turbo + caching.
- Easier release and version tracking.
- Future-proof modular architecture.

## Potential Drawbacks

![Hardships](https://videos.openai.com/vg-assets/assets%2Ftask_01jr64vaa9fv0a1xs70xw07yn7%2Fimg_0.webp?st=2025-04-07T15%3A03%3A02Z&se=2025-04-13T16%3A03%3A02Z&sks=b&skt=2025-04-07T15%3A03%3A02Z&ske=2025-04-13T16%3A03%3A02Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=3d249c53-07fa-4ba4-9b65-0bf8eb4ea46a&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=lYAbizuByWzS5tr%2FvnG%2BJFVWDTZN2V%2Bg55edcLY%2F9xQ%3D&az=oaivgprodscus)

| Hardship | Mitigation | Oregon Trail Outcome |
| ------------------------- | --------------------------------------------------- | ----------------------------------- |
| Migration complexity | Follow phase plan and test incrementally | Wagon tipped crossing the river |
| CI pipeline setup | Use turbo task definitions and remote caching | Lost two oxen and half the build |
| Multi-app dev setup | Use `pnpm dev` to orchestrate local app development | Jeb tried to run all apps manually |
| OSS/internal repo syncing | Automate syncing and tag mirroring via CI/CD | Cholera outbreak in the public repo |

## Conclusion

_We’ve Made It to the Willamette Valley_

![Oregon Trail](https://videos.openai.com/vg-assets/assets%2Ftask_01jr64kfatf8wbkqm8qz1wy8n7%2Fimg_0.webp?st=2025-04-07T15%3A03%3A02Z&se=2025-04-13T16%3A03%3A02Z&sks=b&skt=2025-04-07T15%3A03%3A02Z&ske=2025-04-13T16%3A03%3A02Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=3d249c53-07fa-4ba4-9b65-0bf8eb4ea46a&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=NFKCb8mDg4S5Ra8pW1IzMNbaudFKQmbPkEBB0aUOSrU%3D&az=oaivgprodscus)

After months of toil, trials, and tinkering, the Temporalities have crossed the
monorepo plains. They’ve survived the great package renaming, outlasted test
failures, and forded the mighty river of merge conflicts. Their reward? A clean,
modular codebase, efficient builds, and a future-proof structure that will serve
them for years to come.

Sure, we lost a few unused components along the way. And yes, someone _did_
briefly rename `main` to `wagon-lead`. But now we stand together, boots muddy,
hearts proud, in a monorepo built to last.

## Next Steps

1. Approve the monorepo structure and tooling.
2. Begin Phase 1: Move `schemas`.
3. Execute phases while coordinating with active development.
4. Finalize public OSS sync strategy and automate releases.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions apps/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/.svelte-kit
/package
/coverage
*.log
*.swp
/.vercel_build_output
/.vercel
/build-local
/.history
/build
/bin
server/ui-server
server/api
server/ui/assets
/test-results/
/playwright-report/
/playwright/.cache/
/dist
/audits
go.work
go.work.sum
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading