Monorepo app separation

Plan to separate web, admin, and api into independent apps

Overview

Current state

Everything lives in apps/web: i18n routes, admin panel, API routes.

Target state

  • apps/web → Main site with i18n only
  • apps/admin → Admin panel (no i18n)
  • apps/api → API routes (minimal deps)

Expected benefits

MetricBeforeAfter
Web build~60s~30s
Admin buildN/A~15s
API buildN/A~10s

Implementation

Create apps/admin

Terminal
mkdir -p apps/admin/app

Move apps/web/app/(admin)/admin/*apps/admin/app/admin/*

package.json - Include @repo/db, @repo/supabase, @repo/ui-web, @repo/features, @repo/config

next.config.ts - No i18n plugin, no cacheComponents, transpile workspace packages

Create apps/api

Terminal
mkdir -p apps/api/app

Move apps/web/app/api/*apps/api/app/api/*

package.json - Include @repo/db, @repo/supabase, @repo/features, @repo/orpc, @repo/ai, @repo/config. No UI deps.

next.config.ts - Minimal config, no styling/images

Clean up apps/web

  • Delete apps/web/app/(admin)/ folder
  • Delete apps/web/app/api/ folder
  • Remove admin-only deps from package.json
  • Only [locale]/ routes remain

Deployment

Vercel configuration

Three Vercel projects pointing to same repo:

ProjectRoot DirectoryDomain
cute-webapps/webcute.com
cute-adminapps/adminadmin.cute.com
cute-apiapps/apiapi.cute.com

Set same DB/Supabase credentials across all projects.

Auth across subdomains

Set cookies on parent domain for cross-subdomain auth:

packages/supabase/client/server.ts
cookieStore.set(name, value, {
  ...options,
  domain: process.env.NODE_ENV === "production" ? ".cute.com" : undefined,
});
  1. User logs in on cute.com
  2. Cookie set on .cute.com (parent domain)
  3. Browser sends cookie to ALL subdomains automatically

Local dev: All apps run on localhost (different ports) - cookies work automatically.

Checklist

Files to create

  • apps/admin/package.json, next.config.ts, tsconfig.json, app/layout.tsx
  • apps/api/package.json, next.config.ts, tsconfig.json, app/layout.tsx

Files to move

  • apps/web/app/(admin)/admin/*apps/admin/app/admin/*
  • apps/web/app/api/*apps/api/app/api/*

Files to update

  • apps/web/package.json, turbo.json, root package.json, apps/docs/openapi.json

Risk mitigation

  1. Shared auth - Parent domain cookie config
  2. CORS - API needs CORS headers for cross-origin calls
  3. Types - Shared via @repo/db and feature packages
  4. Env vars - Same vars across all Vercel projects