How shubham7854/headless-cms works
Project Type & Purpose
• Full-stack Next.js 13 “App Router” application.
• Implements user authentication (sign-in/sign-up), an admin console for managing posts & users, and a public thumbnails folder.
• Uses Prisma as the ORM, Tailwind for styling, Node.js runtime.
Main Components
A. Client (Browser)
– React pages & components served by Next.js (src/app/(auth), src/app/(admin), etc.)
– Tailwind.css styling applied at build time.
B. Next.js Server
1. Frontend Layer (App Router)
• Server + client React components (page.jsx under each route).
• Static assets served from /public (e.g., /thumbnails).
2. Backend/API Layer
• Server-side actions (src/app/actions/getBlogs.js, getSingleUser.js)
• Next.js route handlers (if any) or in-component fetch calls
• Authentication logic in (auth) pages.
C. Data Access Layer
• Prisma Client invoked by actions and page server-side code.
• Prisma schema defined in prisma/schema.prisma – models for User, Post, etc.
D. Database
• PostgreSQL / MySQL / SQLite instance (as configured in .env).
E. (Optional) CDN / Edge
Relationships & Data Flows
1. Browser → Next.js Frontend
• HTTP GET for pages (e.g., /auth/sign-in, /admin/posts)
• CSS/JS bundles and static assets fetched from /public.
2. Frontend → Backend (in-page data calls)
• page.jsx calls fetch() or server actions getBlogs() / getSingleUser().
• These invoke Prisma Client queries.
3. Backend → Prisma → Database
• Prisma issues SQL queries to read/write Users, Posts.
4. Auth workflows
• Sign-up form → POST to auth handler → create user via Prisma → session (cookie/JWT) issued
• Sign-in form → verify credentials via Prisma → session.
5. Admin workflows
• Admin → /admin/posts → fetch list of posts via getBlogs() → render table
• Admin → /admin/users → fetch list via getSingleUser() → render.
Architectural Patterns & Principles
• “App Router” directory-based routing (each folder under src/app is a route segment).
• Server & client React components (use “use client” where needed).
• Single codebase handling both rendering and API logic (backend interwoven).
• Prisma as a data-mapper (separates schema from code).
• Tailwind for utility-first CSS (build-time configured via tailwind.config.js).