Integration of backend pipeline engine + frontend themed UI into a single repo.
Browser → Frontend (Next.js 16, port 3000)
│
├── Landing (/), Login (/login), Register (/register)
├── Dashboard (/dashboard), Upload (/upload), Results (/jobs/:id)
│
└── /api/* ──(rewrite proxy)──▶ Backend (Next.js 14, port 3001)
│
├── NextAuth (JWT sessions)
├── Mongoose → MongoDB Atlas
├── 7-stage alignment pipeline
├── Standards assessment
└── ML sidecar (optional)
The frontend's next.config.ts rewrites all /api/* requests to BACKEND_URL (default http://localhost:3001). This means:
- No CORS needed — browser sees everything as same-origin
- Cookies flow naturally through the proxy (NextAuth session tokens)
- No backend changes — all API routes remain identical
# 1. Backend (port 3001)
cd backend
cp .env.example .env # fill in MONGODB_URI, NEXTAUTH_SECRET, GEMINI_API_KEY
npm install
npm run dev # starts on http://localhost:3001
# 2. Frontend (port 3000) — in a separate terminal
cd frontend
npm install
npm run dev # starts on http://localhost:3000
# 3. Open http://localhost:3000| Variable | Required | Description |
|---|---|---|
MONGODB_URI |
✅ | MongoDB Atlas connection string |
NEXTAUTH_SECRET |
✅ | Random 32+ char secret for JWT signing |
NEXTAUTH_URL |
✅ | http://localhost:3001 (backend's own URL) |
GEMINI_API_KEY |
✅ | Google AI Studio key for event canonicalization |
REDIS_URL |
❌ | Redis URL for Bull queue (falls back to inline) |
ENABLE_ML_SIDECAR |
❌ | true to enable ML advisory scoring |
ML_SIDECAR_URL |
❌ | ML sidecar URL (default http://localhost:8100) |
| Variable | Required | Description |
|---|---|---|
BACKEND_URL |
✅ | Backend URL for API proxy (default http://localhost:3001) |
/
├── backend/ # Next.js 14 — API, pipeline, auth, DB
│ ├── src/
│ │ ├── app/api/ # All API routes (unchanged)
│ │ ├── lib/pipeline/ # 7-stage alignment pipeline
│ │ ├── lib/db/models/ # Mongoose models
│ │ ├── lib/auth/ # NextAuth config
│ │ └── components/ # Backend UI (optional, not used by frontend)
│ ├── ml-sidecar/ # Python FastAPI ML service
│ └── package.json
│
├── frontend/ # Next.js 16 — Themed UI
│ ├── src/
│ │ ├── app/
│ │ │ ├── page.tsx # Animated landing page
│ │ │ ├── login/ # Login with mountain backdrop
│ │ │ ├── register/ # Registration page
│ │ │ ├── dashboard/ # Dashboard with real data
│ │ │ ├── upload/ # Dataset upload + pipeline trigger
│ │ │ └── jobs/[jobId]/ # Results with tabs + downloads
│ │ ├── components/
│ │ │ ├── DashboardLayout.tsx # Shared layout (topbar + nav)
│ │ │ └── icons.tsx # SVG icon components
│ │ ├── lib/
│ │ │ ├── api.ts # Centralized API client
│ │ │ ├── auth.ts # Auth helpers (login/logout/session)
│ │ │ └── mongodb.ts # Raw driver (seed script only)
│ │ └── middleware.ts # Auth guard for protected routes
│ └── package.json
│
├── shared/ # Shared type definitions (no runtime code)
│ └── types/
│ └── api.ts # API DTO interfaces
│
└── README.md # This file
| Frontend Page | Backend Endpoints Used |
|---|---|
/login |
POST /api/auth/callback/credentials, GET /api/auth/csrf, GET /api/auth/session |
/register |
POST /api/auth/register, then auto-login via NextAuth |
/dashboard |
GET /api/datasets, GET /api/alignment/jobs, GET /api/auth/session |
/upload |
POST /api/datasets (file upload), GET /api/datasets/:id, POST /api/alignment/run |
/jobs/:id — Summary |
GET /api/alignment/jobs/:id, GET /api/alignment/results/:id |
/jobs/:id — Matches |
GET /api/alignment/results/:id/matches?page=N&pageSize=100 |
/jobs/:id — Exceptions |
GET /api/alignment/results/:id/exceptions |
/jobs/:id — Audit |
GET /api/alignment/results/:id/audit |
/jobs/:id — Downloads |
GET /api/export/:id/xlsx, GET /api/export/:id/matches, GET /api/export/:id/exceptions |
Backend — zero logic changes:
package.json:devscript now runs on port 3001 (next dev -p 3001).env:NEXTAUTH_URLupdated tohttp://localhost:3001.env.example: AddedPORT=3001note
Frontend — minimal wiring changes:
next.config.ts: Addedrewrites()to proxy/api/*→ backendsrc/middleware.ts: New auth guard checking NextAuth session cookiessrc/lib/auth.ts: New — wraps NextAuth CSRF + credential flowsrc/lib/api.ts: New — centralized API client for all backend endpointssrc/app/login/page.tsx: Switched from username/fetch to email/NextAuthsrc/app/register/page.tsx: New registration page (same theme)src/app/dashboard/page.tsx: Replaced stub with real data from APIsrc/app/upload/page.tsx: New — file upload + pipeline triggersrc/app/jobs/[jobId]/page.tsx: New — results with tabs/tables/downloadssrc/components/DashboardLayout.tsx: New shared layout (topbar + nav)src/app/globals.css: Removedoverflow: hiddenfor scrollable dashboard pages
No changes to:
- Any backend API route
- Any pipeline stage logic
- Any database model/schema
- Any scoring, matching, or standards assessment code
- Export format or download mechanism
- ML sidecar integration
- ☐ Backend starts on port 3001 (
cd backend && npm run dev) - ☐ Frontend starts on port 3000 (
cd frontend && npm run dev) - ☐ Landing page loads with mountain animation
- ☐ Login page loads, "Register" link visible
- ☐ Registration works (creates user + org in MongoDB)
- ☐ Login works (email + password, sets NextAuth cookie)
- ☐ Dashboard loads with real datasets/jobs from DB
- ☐ Upload page: drag-drop .xlsx file, parse succeeds
- ☐ Upload page: "Run Alignment" starts a pipeline job
- ☐ Job results page: Summary tab shows counts
- ☐ Job results page: Matches tab shows paginated table
- ☐ Job results page: Exceptions tab shows data
- ☐ Job results page: Audit tab shows log entries
- ☐ Downloads: XLSX, matches CSV, exceptions CSV all download
- ☐ Logout works, redirects to login
- ☐ Protected routes redirect to login when not authenticated
- ☐
cd backend && npm run typecheckpasses - ☐
cd frontend && npm run buildpasses