Skip to content

Monorepo Reorganization — Complete

Date: 2026-02-08 Issue: #246 Branch: feat/monorepo-reorganization

Summary

Implemented the full 5-phase monorepo reorganization plan, moving from a flat repository structure to an organized monorepo with apps/, services/, packages/, and tooling/ top-level directories.

Changes

Phase 1: Apps Directory Migration

  • Moved main web app (src/, index.html, vite.config.mjs, vitest.config.js, test.setup.js, public/) → apps/web/
  • Moved admin portal (admin/) → apps/admin/
  • Updated Vite config with root: __dirname and envDir pointing to repo root
  • Updated all 4 GitHub Actions workflows (deploy-dev, deploy-prod, deploy-preview, ci)
  • Updated ESLint config, vitest configs

Phase 2: Services Directory Migration

  • Moved firebase-functions/services/functions/firebase/
  • Moved cloud-run-docs-api/services/api/docs/
  • Moved discord-bot/services/bots/discord/
  • Updated firebase.json source path
  • Updated npm workspace paths

Phase 3: Tooling Directory Migration

  • Moved .storybook/tooling/.storybook/
  • Moved scripts/tooling/scripts/
  • Updated 40+ script references in package.json
  • Updated internal __dirname paths in ~12 scripts (one extra directory level)
  • Updated import paths in scripts referencing apps/web/src/

Phase 4: Create Shared Packages

  • Created packages/shared/ with @lantern/shared package
  • Added auth/index.js — USER_ROLES, AUTH_ERRORS, ROLE_HIERARCHY, hasRequiredRole()
  • Added encryption/index.js — ENCRYPTION_CONFIG constants, placeholder for Issue #147
  • Added utils/index.js — isDevelopment(), getFirebaseEnvironment(), DevLogInterface
  • Added tests in packages/shared/__tests__/auth.test.js
  • Registered as npm workspace

Phase 5: Output Directory Standardization

  • Updated Storybook build output from storybook-static/tooling/storybook-static/
  • Updated build-storybook scripts with --output-dir tooling/storybook-static
  • Updated bundle-storybook-admin.mjs source path
  • Updated all 4 GitHub Actions workflows for new storybook deploy path

Documentation

  • Updated CLAUDE.md with new monorepo structure and paths
  • Updated .github/copilot-instructions.md with new structure and paths
  • Updated README.md with new paths

Validation

  • npm run build:app — passes (builds in ~9s)
  • npm run test:coverage — 379 tests passing, 85%+ coverage
  • npx vitest run packages/shared/__tests__/auth.test.js — 2 tests passing
  • All git history preserved via git mv

Built with VitePress