How gaurav0973/lms works
Project Type and Purpose
• This is a full-stack web application (LMS) built with Next.js (app router) that handles both frontend pages and backend API routes.
• It provides user authentication (GitHub & email), communicates with a PostgreSQL database via Prisma ORM, and sends emails via Resend.
File Structure
Top-level directories and files:
• app/ – Next.js app router directory, contains page routes and layouts for public and auth-protected areas.
• app/api/auth/[...all]/route.ts – Next.js API route implementing BetterAuth authentication middleware.
• components/ui/ – Reusable UI primitives (ShadCN components).
• lib/ – Business-logic helpers: arcjet (rate-limiting), auth (BetterAuth setup), auth-client, db (Prisma client), env, resend (Resend email wrapper), utils.
• prisma/schema.prisma – DB schema.
• public/ – Static assets.
• Configuration: next.config.ts, tailwind.config.ts, postcss.config.mjs, tsconfig.json, Docker setup implied for PostgreSQL.
README for Insights
• Tech stack confirms Next.js (full-stack), PostgreSQL in Docker, Prisma, BetterAuth, Resend, ShadCN.
• Features: GitHub & email login, email flows via Resend.
• Future: rate limiting with arcjet.
Main Components
a. Client (Browser / Next.js Frontend pages)
b. Next.js Server (Server-side rendering, API routes)
c. Authentication Layer (BetterAuth middleware / auth client)
d. Database (PostgreSQL container) accessed via Prisma ORM
e. Email Service (Resend)
f. External OAuth Provider (GitHub)
g. Rate-limiting component (arcjet)
Relationships & Data Flows
• Client ↔ Next.js Server: page requests (SSR/SSG) and API calls (fetch to /api/auth/*).
• Next.js Server → DB: Prisma executes SQL queries against PostgreSQL.
• Next.js Server → Resend API: sending verification & login emails.
• Next.js Server ↔ GitHub OAuth endpoints: redirect & callback for GitHub login.
• Next.js Server ↔ arcjet: rate-limit checks before processing auth/API calls.
• DB stores user, session, verification tokens.
• UI Components (ShadCN) sit within the Client/Next.js pages.
Architectural Patterns & Design Principles
• “App router” folder-based routing (Next.js)
• Separation of concerns: UI (components/ui), API routes (app/api), data access (lib/db), auth logic (lib/auth, lib/auth-client).
• Middleware pattern for authentication (BetterAuth) in API routes.
• Infrastructure as code: Dockerized DB, environment variables (lib/env).
[ ] All major components represented (Client, Next.js Server, DB, Resend, GitHub OAuth, arcjet)
[ ] Notes or annotations for critical paths (e.g., “Email login flow”, “OAuth callback”)