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 onlyapps/admin→ Admin panel (no i18n)apps/api→ API routes (minimal deps)
Expected benefits
| Metric | Before | After |
|---|---|---|
| Web build | ~60s | ~30s |
| Admin build | N/A | ~15s |
| API build | N/A | ~10s |
Implementation
Create apps/admin
mkdir -p apps/admin/appMove 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
mkdir -p apps/api/appMove 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:
| Project | Root Directory | Domain |
|---|---|---|
| cute-web | apps/web | cute.com |
| cute-admin | apps/admin | admin.cute.com |
| cute-api | apps/api | api.cute.com |
Set same DB/Supabase credentials across all projects.
Auth across subdomains
Set cookies on parent domain for cross-subdomain auth:
cookieStore.set(name, value, {
...options,
domain: process.env.NODE_ENV === "production" ? ".cute.com" : undefined,
});- User logs in on
cute.com - Cookie set on
.cute.com(parent domain) - 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.tsxapps/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, rootpackage.json,apps/docs/openapi.json
Risk mitigation
- Shared auth - Parent domain cookie config
- CORS - API needs CORS headers for cross-origin calls
- Types - Shared via
@repo/dband feature packages - Env vars - Same vars across all Vercel projects