How tanishqbhatia474/devlinks works
Project Type and Purpose
• From the README and file structure, this is a full-stack web application (“DevLinks”) built on Next.js.
• Purpose: allow users to authenticate via Google, then create and manage a personalized “link tree” (drag-and-drop, add/edit links), with server-side rendering, responsive design, and a preview mode.
File Structure
• Top-level files: next.config.mjs, package.json, tailwind.config.js, README.md, .eslintrc.json
• /models: Mongoose model(s) (user.js)
• /utils & /src/app/lib: database connection helpers (mongodb.js, database.js)
• src/app: Next.js App Router
• src/app/page.jsx: main landing page
• src/app/login/page.jsx: login UI
• src/app/preview/[userId]/page.jsx: public preview
• src/app/api: API routes under auth, user, getlinks—each exposing route.js handlers
• src/app/components: React components (Header, Linktree, Newlink)
• src/app/globals.css: global Tailwind styles
• NextAuth routes in src/app/api/auth/[...nextauth]/route.js
README Insights
• Tech stack: Next.js, Tailwind CSS, NextAuth.js, HTML5 drag-and-drop
• Features: Google Authentication, user profile, link management, responsive design
Main Components and Relationships
a. Frontend (Browser & Next.js Server Components)
• Browser: renders pages, executes client-side JS for drag-and-drop
• Next.js App Server: renders React components on server, handles data fetching in server components
• React Components: Header (displays profile, login/logout), Linktree (renders list), Newlink (UI for adding links)
b. API Layer
• Next.js API Routes:
• /api/auth → NextAuth.js (Google OAuth flow + session management)
• /api/user/[userId] → CRUD operations on user metadata
• /api/user/getlinks/[userId] → retrieve/save link ordering
c. Data Layer
• MongoDB Atlas (or on-prem)
• Mongoose models (models/user.js)
• Connection utilities (src/app/lib/mongodb.js, utils/database.js)
d. External Services
• Google OAuth (via NextAuth.js)
• Static assets served from /public
Important Patterns and Principles
• Separation of Concerns:
• Presentation Layer (React components, CSS)
• API Layer (Next.js route handlers)
• Data Layer (MongoDB + Mongoose)
• Server-Side Rendering (SSR) via Next.js App Router
• Authentication as a distinct module (NextAuth.js)
• Component Reusability (Header, Linktree, Newlink)
• Drag-and-drop uses browser APIs for UX