🔐Backend ArchitectureComing Soon
Authentication
NextAuth.js with Google OAuth, JWT sessions, and admin role management.
Video coming soon
Add a YouTube video ID to the topics config
Documentation
Overview
Authentication is handled by NextAuth.js (Auth.js) with Google OAuth as the primary provider. Sessions use JWT strategy for stateless auth.
Auth Flow
- User clicks "Sign in with Google"
- OAuth flow with Google (consent screen, redirect)
- On first login: User document created in MongoDB
- JWT token issued with user ID, admin flag
- Session available server-side via
auth()and client-side viauseSession()
Admin System
adminboolean on the User model (defaultfalse)- Set manually in the database
- JWT callback reads
adminfrom DB and stores it in the token adminProceduremiddleware checks the flag on every admin request
Route Protection
- Server components —
auth()+ redirect in layout files - tRPC — procedure-level middleware
- Client —
useSession()for conditional UI
Technical Details
<!-- Add details about session strategy decisions, token refresh, etc. -->Content coming soon — add your video and detailed writeup here.