Background
The GuildPass monorepo uses pnpm workspaces across 9 packages (contracts, env, integration-client, webhook-utils, docs, discord-bot, access-api, dashboard, and potentially mobile). Recent build failures reveal gaps in build orchestration, dependency management, and shared configuration. Clear documentation and tooling would prevent misconfigurations and speed up onboarding.
Problem
- No build orchestration docs: No clear guide on the intended build order, dependency resolution, or parallel vs. sequential execution
- Ambiguous package roles: It's unclear which packages are libraries, which are applications, and how they depend on each other
- No troubleshooting guide: When builds fail (as they have), developers lack a runbook
- No CI/CD specification: The pnpm monorepo setup may not align with GitHub Actions workflows
Expected Outcome
- Clear monorepo documentation explaining structure, build flow, and package dependencies
- Build orchestration defined (what builds in what order, parallelization strategy)
- Troubleshooting guide for common failures
- Automated validation (e.g., GitHub Actions checking workspace integrity)
- Developer quick-start guide for local setup and builds
Suggested Implementation
-
Create MONOREPO.md in the workspace root:
# GuildPass Monorepo Structure
## Overview
- **Packages**: Reusable libraries and shared utilities
- `packages/contracts`: TypeScript types for on-chain interfaces
- `packages/env`: Environment configuration schema validation
- `packages/integration-client`: Web3 integration client
- `packages/webhook-utils`: Webhook utilities
- **Apps**: Consumer applications
- `apps/docs`: Docusaurus documentation
- `apps/dashboard`: Next.js 14 dashboard
- `apps/access-api`: Fastify API server
- `apps/discord-bot`: Discord bot service
- `apps/mobile`: Expo/React Native mobile app (optional)
## Build Order
1. `packages/` (independent libraries, no app dependencies)
- `packages/contracts` → `packages/env` → `packages/integration-client`, `packages/webhook-utils`
2. `apps/` (depend on packages)
- `apps/docs`, `apps/dashboard`, `apps/access-api`, `apps/discord-bot` (parallel)
## Commands
- `pnpm install`: Install all dependencies
- `pnpm build`: Build all packages and apps
- `pnpm build -r --filter @guildpass/env`: Build specific package
- `pnpm typecheck`: Type-check all packages
- `pnpm lint`: Lint all code
- `pnpm -r dev`: Run all apps in dev mode (if configured)
## Troubleshooting
See TROUBLESHOOTING.md
-
Create TROUBLESHOOTING.md:
# Build Troubleshooting
## Error: "Module not found: Can't resolve './schemas/dashboard.js'"
**Cause**: `packages/env` did not emit `.js` files.
**Fix**:
1. Check `packages/env/tsconfig.json` for `outDir` and `emitDeclarationOnly` settings
2. Run `pnpm build -r --filter @guildpass/env`
3. Verify `packages/env/dist/` contains `.js` and `.d.ts` files
4. Run `pnpm -r build` again
## Error: "error TS5042: Option 'project' cannot be mixed with source files"
**Cause**: Build script contains malformed arguments.
**Fix**:
1. Check the package's `package.json` `build` script
2. Ensure it contains only `tsc -p tsconfig.json` (no extra commands)
3. Remove any appended `pnpm start`, `pnpm typecheck`, `pnpm lint`, etc.
-
Create a pnpm workspace diagram in ARCHITECTURE.md showing package dependencies:
packages/contracts (types)
↓
packages/env (validation)
↓
packages/integration-client (Web3 SDK)
↓
packages/webhook-utils (utilities)
↓
apps/* (dashboard, api, bot, docs)
No circular dependencies expected.
-
Add .github/workflows/monorepo-ci.yml (or update existing CI):
name: Monorepo CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- run: pnpm install
- run: pnpm -r build
- run: pnpm -r typecheck
- run: pnpm lint
-
Add workspace validation script in scripts/validate-workspace.js:
// Check all packages have required fields in package.json
// Verify no circular dependencies
// Ensure all tsconfig.json files extend base config
Acceptance Criteria
Affected Files/Directories
MONOREPO.md (create)
TROUBLESHOOTING.md (create)
ARCHITECTURE.md (create)
.github/workflows/monorepo-ci.yml (create or update)
scripts/validate-workspace.js (create)
README.md (update with link to monorepo guide)
Background
The GuildPass monorepo uses pnpm workspaces across 9 packages (contracts, env, integration-client, webhook-utils, docs, discord-bot, access-api, dashboard, and potentially mobile). Recent build failures reveal gaps in build orchestration, dependency management, and shared configuration. Clear documentation and tooling would prevent misconfigurations and speed up onboarding.
Problem
Expected Outcome
Suggested Implementation
Create
MONOREPO.mdin the workspace root:Create
TROUBLESHOOTING.md:Create a pnpm workspace diagram in
ARCHITECTURE.mdshowing package dependencies:# Architecturepackages/contracts (types)
↓
packages/env (validation)
↓
packages/integration-client (Web3 SDK)
↓
packages/webhook-utils (utilities)
↓
apps/* (dashboard, api, bot, docs)
Add
.github/workflows/monorepo-ci.yml(or update existing CI):Add workspace validation script in
scripts/validate-workspace.js:Acceptance Criteria
MONOREPO.mddocuments structure, build order, and key commandsTROUBLESHOOTING.mdincludes solutions for recent build failuresARCHITECTURE.mdshows package dependency graphAffected Files/Directories
MONOREPO.md(create)TROUBLESHOOTING.md(create)ARCHITECTURE.md(create).github/workflows/monorepo-ci.yml(create or update)scripts/validate-workspace.js(create)README.md(update with link to monorepo guide)