A fully-featured, production-ready CMS built with Next.js 14, Prisma, Supabase, and Tailwind CSS. Features a robust multi-user system with role-based access control and a beautiful public-facing frontend.
- 4 User Roles: Admin, Editor, Author, and Viewer
- Role-Based Access Control (RBAC)
- Admin: Full system access, user management, all content operations
- Editor: Create, edit, and publish all content, manage categories
- Author: Create and manage own content
- Viewer: Read-only access
- Rich markdown editor for post creation
- Categories and tags for content organization
- Draft and published states
- Cover images and excerpts
- Comment system (backend ready)
- SEO-friendly slugs
- Full-text content rendering with syntax highlighting
- Beautiful Article Pages: Modern, magazine-style layouts
- Homepage: Hero section with featured posts and category browsing
- Article List: Paginated article browsing with filters
- Category Pages: Browse articles by category
- Tag Pages: Explore content by tags
- About Page: Customizable about page
- Responsive Design: Perfect on mobile, tablet, and desktop
- Dark Mode Ready: Automatic theme support
- File upload system
- Media library with preview
- Image and file support
- Per-user upload tracking
- URL copy functionality
- Modern, responsive design with Tailwind CSS
- Clean admin dashboard with statistics
- Intuitive content editor
- Real-time data updates
- Gradient accents and smooth transitions
- Framework: Next.js 14 (App Router)
- Database: PostgreSQL (Supabase)
- ORM: Prisma
- Authentication: NextAuth.js
- UI: Tailwind CSS + Custom Components
- Language: TypeScript
- Deployment: Vercel
- Markdown: React Markdown
- Node.js 18+
- npm or yarn
- Supabase account (free tier available)
- Vercel account (optional, for deployment)
- Clone the repository:
git clone https://github.com/your-username/ai-cms.git
cd ai-cms- Install dependencies:
npm install-
Set up Supabase:
- Go to supabase.com and create a new project
- Get your database connection strings from Settings > Database
- Copy
.env.exampleto.envand add your Supabase credentials
-
Configure environment variables:
# Database (Supabase)
DATABASE_URL="postgresql://postgres:[PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres?pgbouncer=true"
DIRECT_URL="postgresql://postgres:[PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres"
# NextAuth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here"
# App
APP_NAME="AI CMS"
APP_URL="http://localhost:3000"- Initialize the database:
npx prisma generate
npx prisma db push- Start the development server:
npm run dev-
Seed the database (optional): Visit
http://localhost:3000/api/seedin your browser to create demo users. -
Access the application:
- Public Frontend: http://localhost:3000
- Admin Dashboard: http://localhost:3000/admin
- Login: http://localhost:3000/login
After seeding, you can login with:
- Admin: [email protected] / admin123
- Editor: [email protected] / editor123
- Author: [email protected] / author123
Deploy and initialize your database entirely through the web - no local terminal commands needed!
- Push to GitHub:
git push origin main-
Deploy to Vercel:
- Go to vercel.com
- Click "Import Project"
- Select your GitHub repository
- Add environment variables (from your Supabase project):
DATABASE_URL=postgresql://postgres.xxx:[email protected]:6543/postgres NEXTAUTH_URL=https://your-app.vercel.app NEXTAUTH_SECRET=your-random-secret SETUP_SECRET=your-setup-secret
- Click "Deploy"
-
Automatic Database Setup: The build process automatically:
- β Generates Prisma Client
- β Pushes schema to database
- β Builds the application
No manual commands needed!
-
Initialize Data (Choose One):
Option A: Setup Page (Recommended)
- Visit:
https://your-app.vercel.app/setup - Enter your
SETUP_SECRET - Click "Initialize Database"
- Click "Seed Database"
Option B: Direct API
- Visit:
https://your-app.vercel.app/api/seed
- Visit:
-
Done! π
- Login:
https://your-app.vercel.app/login - Use:
[email protected]/admin123
- Login:
π For complete zero-touch setup guide, see SETUP-GUIDE.md
π For detailed deployment instructions, see DEPLOYMENT.md
Once deployed, Vercel automatically:
- β
Builds on every push to
mainbranch - β Creates preview deployments for pull requests
- β Runs database migrations
- β Invalidates cache as needed
ai-cms/
βββ app/ # Next.js app directory
β βββ (public)/ # Public-facing pages
β β βββ articles/ # Article pages
β β βββ categories/ # Category pages
β β βββ tags/ # Tag pages
β β βββ about/ # About page
β βββ api/ # API routes
β β βββ auth/ # Authentication
β β βββ posts/ # Posts CRUD
β β βββ users/ # User management
β β βββ categories/ # Categories
β β βββ tags/ # Tags
β β βββ media/ # Media upload
β β βββ seed/ # Database seeding
β βββ admin/ # Admin dashboard
β β βββ posts/ # Post management
β β βββ users/ # User management
β β βββ categories/ # Category management
β β βββ media/ # Media library
β βββ login/ # Login page
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Homepage
βββ components/ # React components
β βββ ui/ # Base UI components
β β βββ button.tsx
β β βββ card.tsx
β β βββ input.tsx
β βββ admin/ # Admin components
β β βββ admin-nav.tsx
β β βββ post-editor.tsx
β β βββ ...
β βββ public/ # Public components
β βββ public-nav.tsx
β βββ footer.tsx
β βββ article-card.tsx
β βββ markdown-renderer.tsx
βββ lib/ # Utility functions
β βββ prisma.ts # Prisma client
β βββ auth.ts # Auth configuration
β βββ utils.ts # Helper functions
βββ prisma/ # Database schema
β βββ schema.prisma # Prisma schema
βββ types/ # TypeScript types
β βββ next-auth.d.ts
βββ public/ # Static assets
β βββ uploads/ # User uploads
βββ .env.example # Environment variables template
βββ vercel.json # Vercel configuration
βββ DEPLOYMENT.md # Deployment guide
βββ README.md # This file
| Feature | Admin | Editor | Author | Viewer |
|---|---|---|---|---|
| View Dashboard | β | β | β | β |
| View Public Site | β | β | β | β |
| Create Posts | β | β | β | β |
| Edit Own Posts | β | β | β | β |
| Edit All Posts | β | β | β | β |
| Delete Own Posts | β | β | β | β |
| Delete All Posts | β | β | β | β |
| Manage Categories | β | β | β | β |
| Create Tags | β | β | β | β |
| Upload Media | β | β | β | β |
| Manage Users | β | β | β | β |
| Page | Route | Description |
|---|---|---|
| Homepage | / |
Hero section, featured posts, categories |
| Articles | /articles |
Paginated article list |
| Article Detail | /articles/[slug] |
Full article with Markdown rendering |
| Categories | /categories |
All categories |
| Category Page | /categories/[slug] |
Articles in category |
| Tag Page | /tags/[slug] |
Articles with tag |
| About | /about |
About page |
| Page | Route | Description |
|---|---|---|
| Dashboard | /admin |
Statistics and recent posts |
| Posts | /admin/posts |
Manage all posts |
| New Post | /admin/posts/new |
Create new post |
| Edit Post | /admin/posts/[id]/edit |
Edit existing post |
| Users | /admin/users |
User management (Admin only) |
| Categories | /admin/categories |
Manage categories and tags |
| Media | /admin/media |
Media library |
Authentication
POST /api/auth/[...nextauth]- Authentication
Posts
GET /api/posts- List all postsPOST /api/posts- Create postGET /api/posts/[id]- Get post by IDPATCH /api/posts/[id]- Update postDELETE /api/posts/[id]- Delete post
Users (Admin only)
GET /api/users- List all usersPOST /api/users- Create userGET /api/users/[id]- Get userPATCH /api/users/[id]- Update userDELETE /api/users/[id]- Delete user
Categories
GET /api/categories- List categoriesPOST /api/categories- Create category
Tags
GET /api/tags- List tagsPOST /api/tags- Create tag
Media
GET /api/media- List media filesPOST /api/media- Upload file
Utilities
POST /api/seed- Seed database with demo data
npm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLintnpx prisma studio- Open Prisma Studio (database GUI)npx prisma generate- Generate Prisma Clientnpx prisma db push- Push schema changes to databasenpx prisma migrate dev- Create and apply migration
The CMS uses the following main models:
- User: User accounts with role-based access
- Post: Content with markdown support
- Category: Content categorization
- Tag: Content tagging
- Media: File uploads
- Comment: Post comments (ready for implementation)
Required environment variables:
DATABASE_URL # Supabase pooled connection
DIRECT_URL # Supabase direct connection
NEXTAUTH_URL # Application URL
NEXTAUTH_SECRET # Auth secret key
APP_NAME # Application name
APP_URL # Application URL- β Passwords hashed with bcrypt
- β API routes protected with NextAuth middleware
- β Role-based access control on all operations
- β SQL injection prevention via Prisma
- β CSRF protection via NextAuth
- β Environment variables for sensitive data
- β Secure session management
Update the following files to customize branding:
-
Logo & Name:
components/public/public-nav.tsxcomponents/public/footer.tsx
-
Colors:
tailwind.config.ts- Update color schemeapp/globals.css- Update CSS variables
-
Content:
app/(public)/about/page.tsx- Update about pageapp/page.tsx- Update homepage content
- Add new API route: Create in
app/api/[feature]/route.ts - Add new admin page: Create in
app/admin/[feature]/page.tsx - Add new public page: Create in
app/(public)/[feature]/page.tsx - Update schema: Modify
prisma/schema.prisma
- β Server-side rendering (SSR)
- β Static generation for public pages
- β Image optimization with Next.js Image
- β Connection pooling with Supabase
- β Efficient database queries with Prisma
- β Edge-ready with Vercel deployment
See DEPLOYMENT.md for common issues and solutions.
- Email verification
- Password reset flow
- Comment moderation UI
- Post versioning
- Advanced media editing
- Analytics dashboard
- Export/import functionality
- Multi-language support
- SEO meta tags
- RSS feed
- Search functionality
- Email notifications
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions:
- Check DEPLOYMENT.md for deployment help
- Review Next.js docs
- Consult Prisma docs
- Visit Supabase docs
Built with β€οΈ using Next.js, Prisma, Supabase, and Tailwind CSS.