Next.js 16 App Router frontend for ExplainMyCode. It now also hosts the API routes that mirror the Express backend.
- Node 18+
- Env vars in
.env(or runtime):MONGODB_URL– Mongo connection stringGROQ_API_KEY– for code/tut generationNEXT_PUBLIC_API_BASE– point to this app's origin (or leave blank to use relative API calls)
pnpm install
pnpm dev # http://localhost:3000
pnpm build # production buildPOST /api/explanations/generate– generate explanation via GroqPOST /api/explanations/save– save explanation (requires synced user)GET /api/explanations/user?uid=– list user explanationsGET|PUT|DELETE /api/explanations/:idPOST /api/explanations/learn– generate tutorialPOST /api/explanations/learn/save– save tutorialGET /api/explanations/learn/user?uid=– list user tutorialsGET|DELETE /api/explanations/learn/:idPOST /api/auth/sync-user– ensure user exists by firebase uid/email
/– landing + explain form/history– saved explanations/tutorials/history/[id]– detail view (works for both explanations and tutorials)/learn– tutorial generator
- Uses Mongo via
mongoosewith a cached connection helper inapp/api/_lib/db.ts. - Monaco editor is used for code display.
- Fonts are pulled from Google; offline builds may need local fallbacks.