IntegrateWise Web App — Bootable State Plan
Current Architecture (What Actually Exists)
Codebase Location
- Source:
/Users/nirmal/Github/integratewise-live/integratewise-complete/apps/web/ - Build copy:
/tmp/iw-build/(bypasses macOScom.apple.provenancepermission block) - Package manager: pnpm@9 (monorepo with 41 workspace projects)
- Framework: Next.js 16.0.10 (Turbopack)
- DB: Supabase (project:
hrrbciljsqxnmuwwnrnt) - Secrets: Doppler (prod) /
.env.local(dev)
Two Parallel UI Systems (Root Cause of Issues)
| System | Location | Layout | Auth | Data |
|---|---|---|---|---|
| V1 "Original" | src/app/(app)/ | UnifiedShell + RBAC + Domain Shells | middleware.ts → Supabase session check → redirect to /auth/login | Requires profiles, tenants tables |
| V2 "Kimi's" | src/app/dashboard/, src/app/tasks/, etc. | DashboardLayout (standalone sidebar) | None (blocked by V1 middleware) | All hardcoded mock data |
V1 has 400+ pages inside (app)/, including admin panel with 40+ sub-pages. Uses:
UnifiedShell→useRBAChook → Supabaseprofilestable lookup → Domain shell injectionTenantProvider→ fetches/api/tenant/contextmiddleware.ts→ catches ALL non-public routes, requires Supabase auth session- Auth login at
/auth/loginusingauth-client.ts→ Cloudflare Auth Worker atauth.integratewise.ai
V2 (Kimi's commit bffe6a2) added 16 standalone pages using a simple DashboardLayout. These pages:
- Work independently without any DB connection
- Render static mock data
- Use a simpler sidebar component
- Have a new login page at
/login-newwired to direct Supabase auth
The Conflict
The middleware.ts from V1 intercepts ALL routes and redirects unauthenticated users to /auth/login. Even after disabling it, Turbopack caches the compiled middleware and continues redirecting. The .next cache must be fully cleared + server restarted for middleware changes to take effect.
What's NOT Set Up
- No SQL schema in Supabase —
profiles,tenants,roles,health_checktables don't exist - No
/api/tenant/contextroute returning tenant data - No
exec_sqlRPC stored procedure in Supabase - Auth worker at
auth.integratewise.aiis not deployed (V1's auth-client.ts points there) - 27 Cloudflare Workers referenced in docs — none deployed
Plan: 3 Tasks to Bootable State
Task 1: Fix Middleware + Clear Cache (5 min)
Goal: Allow all standalone pages to load without auth redirect
Steps:
- Replace
middleware.tswith a minimal version that ONLY protects/(app)/routes - Delete
.next/cache completely - Restart dev server
- Verify:
/dashboard,/test,/onboarding,/login-newall load
Why: The Turbopack cache holds the compiled old middleware. Even renaming the file doesn't work without cache clear. The simplest fix is a clean middleware that only gates (app) routes.
Task 2: Create Supabase Schema (10 min)
Goal: Create the minimum tables so V1 auth + RBAC works
Steps:
- Create SQL migration with:
profilestable (id, full_name, avatar_url, role, tenant_id, created_at)tenantstable (id, name, industry, plan, created_at)health_checktable (id, checked_at)- Basic RLS policies
- Run migration against Supabase (via dashboard SQL editor or CLI)
- Create a test user in Supabase Auth dashboard
- Verify:
/testpage shows "Database Connected"
Task 3: Wire Login → Dashboard Flow (10 min)
Goal: Complete auth flow: login → session → dashboard with real data
Steps:
- Ensure
/login-newcallssignInWithSupabaseEmail(already done) - On success, redirect to
/dashboard - Verify the Supabase session cookie is set
- Dashboard loads (with static data for now — that's fine)
Files Modified So Far (This Session)
| File | Change | Status |
|---|---|---|
apps/web/.env.local | Created with Supabase credentials | ✅ Done |
apps/web/src/app/login-new/page.tsx | Wired to signInWithSupabaseEmail + error handling | ✅ Done |
apps/web/src/components/shell/UnifiedShell.tsx | Fixed lowercase imports + moved Search import | ✅ Done |
apps/web/src/app/page.tsx | Redirect to /login-new instead of /today | ✅ Done |
apps/web/src/app/(app)/{accounts,integrations,knowledge,pipeline,settings,tasks}/ | Removed to fix parallel route conflicts | ✅ Done (in /tmp/iw-build) |
apps/web/src/middleware.ts | Renamed to .disabled (but Turbopack cache didn't pick it up) | ⚠️ Needs proper fix |
Key Insight: macOS Provenance Block
The source directory has com.apple.provenance extended attributes (macOS Sequoia security) that prevent:
mkdirinside the directory (pnpm install fails)cpof.env.local
Workaround: Copy to /tmp/iw-build/, install there, run from there. All code changes need to be made in BOTH locations (source for git, /tmp for running).
Doppler Note
Production uses Doppler for secrets. The .env.local approach is for local dev only. Both paths are supported by provider.ts which reads process.env.NEXT_PUBLIC_SUPABASE_URL regardless of source.