You are a senior full-stack engineer and architect.Your task: Build a modular, plug-and-play blog plugin that can be installed into any Next.js 14+ (App Router) project and be production-ready immediately.Requirements:1. Frontend - Use Next.js 14 App Router with React Server Components where applicable. - Use TailwindCSS for styling, integrated with shadcn/ui components. - Implement a light/dark theme toggle with next-themes
and a toggle UI component from shadcn. - Blog listing page (/blog
) that shows all published posts with title, excerpt, tags, published date, likes, and views. - Individual blog post page (/blog/[slug]
) that renders the full post content (rich text/Markdown), shows comments, likes, and view count. - Responsive and accessible design for mobile, tablet, and desktop. - Use TipTap as the rich text editor for blog post creation/editing.2. Admin Panel - Under /admin
, protected by JWT or Clerk authentication. - CRUD operations for posts (create, read, update, delete). - Post fields: title, slug (unique), content (rich text), tags (array), published (boolean), images upload. - Image uploads must support multiple images per post, with previews and embed support. - Moderation panel for comments: view, approve, delete. - Show post statistics: total likes, views, and comment count.3. Backend and API - Use Prisma ORM connected to PostgreSQL for data persistence. - Database schema includes: User
, Post
, Comment
, Like
, View
. - RESTful API routes for posts, comments, likes, views, supporting GET, POST, PATCH, DELETE as relevant. - Ensure security in API routes, validating authenticated admin actions.4. Features - Comments system with nested replies, moderation required before publishing. - Likes system: users can like/unlike posts; likes are counted per user/IP to prevent duplicates. - Views tracking: count unique views per post, avoid inflating with repeated refreshes. - SEO optimized pages with dynamic metadata for posts. - Image upload handled via a cloud solution like UploadThing or Cloudinary (or local storage fallback).5. Code Quality - Use TypeScript throughout. - Modular code structure, reusable components. - Clean folder structure following Next.js best practices. - Well-documented code and comments. - Include error handling and validation.6. Deliverables - Fully working codebase with frontend, backend API routes, Prisma schema. - Setup instructions for database and environment variables. - Example .env
file. - Scripts for database migrations and seeding. - Responsive UI components with theme toggling. - Admin authentication flow.7. Bonus (Optional) - Draft autosave functionality in the editor. - Markdown export/import for posts. - Analytics dashboard showing post engagement trends.Please generate all necessary code files with comments, including:- prisma/schema.prisma
- Next.js route handlers (app/api/
routes)- React components and pages (app/blog
, app/admin
)- Auth utilities and middleware- TailwindCSS and shadcn UI setup- Theme toggle implementationYour output must be production-ready, performant, accessible, and secure. Include clear code comments explaining major parts.---Start by generating the Prisma schema and Next.js API routes for posts and comments.
You can drop these files into any Next.js 14+ App Router project. Route Handlers live in app/api and use server-only code as recommended for App Router APIs 1.
Notes and next steps
Environment variables used so far:
Actions
References
To configure the generation, complete these steps:
i want t seecthe live site
You can now click to preview /blog and open a post. These pages are server components that fetch data via Route Handlers in the App Router, which is the recommended pattern in Next.js 14+ 1. Using app/api Route Handlers to implement REST endpoints is the standard approach within the App Router 21.
If you want these pages to read real data:
Actions
References
To configure the generation, complete these steps:
run the app and show the result