PluginMind’s frontend is built with Next.js 14 (App Router), TypeScript, and NextAuth. This guide helps you extend it without breaking the secure proxy flow.
🧱 Project Layout
Loading code snippet…
🔐 NextAuth Configuration (src/auth.ts)
- Google provider only (GitHub scaffolding is present but optional).
- Secure mode controlled via
NEXT_PUBLIC_SECURE_TOKENS. - JWT callback stores Google tokens server-side.
- Session callback exposes
session.hasTokenwhen secure mode is enabled.
Loading code snippet…
🛰️ Proxy Route (app/api/proxy/[...path]/route.ts)
- Runs on the Node.js runtime.
- Injects
id_tokenwhen forwardingPOST /auth/google. - Forwards cookies and selected headers to the FastAPI backend.
- Retries against
BACKEND_ALT_URLif the primary backend is unreachable.
Key snippet:
Loading code snippet…
When calling API routes from the frontend, use the proxy:
Loading code snippet…
🪝 Useful Hooks & Services
| File | Purpose |
|---|---|
hooks/useAuth.ts | Wraps NextAuth session and the hasToken flag. |
services/api.service.ts | Centralised fetch helper that hits the proxy with credentials included. |
services/ai.service.ts | Frontend helper for calling /process and /services. |
When building new pages, import these utilities instead of rolling custom fetch logic.
🧪 Frontend Testing Tips
- Use Playwright (already listed in devDependencies) for E2E flows.
- For unit tests,
react-testing-libraryworks well with the existing component pattern. - Mock
next-auth/reactin tests to simulate authenticated states.
Example Playwright stub:
Loading code snippet…
🎨 Styling
- Tailwind CSS + shadcn/ui components power the design system.
components/ui/holds low-level components (buttons, cards, etc.).- Shared iconography lives in
components/icons.tsx.
Remember to run pnpm lint and pnpm typecheck before committing UI changes.
🧭 Tips for Extending the App
- Reuse the proxy – Never call the backend directly from
fetchin the browser. - Keep tokens server-only – If you must expose more session detail, do it inside the proxy route.
- Handle 401s gracefully – Redirect users to
/auth/signinwhen the backend responds withAUTHENTICATION_FAILED. - Surface metadata – The
/servicesendpoint returns registry metadata you can display in the UI.
Happy frontend hacking! 🎉