Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MyReferRepos/ai-cms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

63 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI CMS - Multi-User Content Management System created by AI.

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.

Deploy with Vercel

🌟 Features

πŸ” Multi-User System

  • 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

πŸ“ Content Management

  • 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

🎨 Public Frontend

  • 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

πŸ“ Media Management

  • File upload system
  • Media library with preview
  • Image and file support
  • Per-user upload tracking
  • URL copy functionality

πŸ’Ž User Interface

  • Modern, responsive design with Tailwind CSS
  • Clean admin dashboard with statistics
  • Intuitive content editor
  • Real-time data updates
  • Gradient accents and smooth transitions

πŸš€ Technology Stack

  • 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

πŸ“¦ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Supabase account (free tier available)
  • Vercel account (optional, for deployment)

Local Development Setup

  1. Clone the repository:
git clone https://github.com/your-username/ai-cms.git
cd ai-cms
  1. Install dependencies:
npm install
  1. Set up Supabase:

    • Go to supabase.com and create a new project
    • Get your database connection strings from Settings > Database
    • Copy .env.example to .env and add your Supabase credentials
  2. 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"
  1. Initialize the database:
npx prisma generate
npx prisma db push
  1. Start the development server:
npm run dev
  1. Seed the database (optional): Visit http://localhost:3000/api/seed in your browser to create demo users.

  2. Access the application:

Demo Accounts

After seeding, you can login with:

🌐 Deployment to Vercel

πŸš€ Zero-Touch Deployment (Recommended - No Local Commands!)

Deploy and initialize your database entirely through the web - no local terminal commands needed!

  1. Push to GitHub:
git push origin main
  1. 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"
  2. Automatic Database Setup: The build process automatically:

    • βœ… Generates Prisma Client
    • βœ… Pushes schema to database
    • βœ… Builds the application

    No manual commands needed!

  3. 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
  4. Done! πŸŽ‰

πŸ“– For complete zero-touch setup guide, see SETUP-GUIDE.md

πŸ“– For detailed deployment instructions, see DEPLOYMENT.md

Automatic Updates

Once deployed, Vercel automatically:

  • βœ… Builds on every push to main branch
  • βœ… Creates preview deployments for pull requests
  • βœ… Runs database migrations
  • βœ… Invalidates cache as needed

πŸ“‚ Project Structure

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

🎯 Key Features Explained

Role-Based Permissions

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 βœ… ❌ ❌ ❌

Public Pages

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

Admin Pages

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

API Endpoints

Authentication

  • POST /api/auth/[...nextauth] - Authentication

Posts

  • GET /api/posts - List all posts
  • POST /api/posts - Create post
  • GET /api/posts/[id] - Get post by ID
  • PATCH /api/posts/[id] - Update post
  • DELETE /api/posts/[id] - Delete post

Users (Admin only)

  • GET /api/users - List all users
  • POST /api/users - Create user
  • GET /api/users/[id] - Get user
  • PATCH /api/users/[id] - Update user
  • DELETE /api/users/[id] - Delete user

Categories

  • GET /api/categories - List categories
  • POST /api/categories - Create category

Tags

  • GET /api/tags - List tags
  • POST /api/tags - Create tag

Media

  • GET /api/media - List media files
  • POST /api/media - Upload file

Utilities

  • POST /api/seed - Seed database with demo data

πŸ› οΈ Development

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm start - Start production server
  • npm run lint - Run ESLint
  • npx prisma studio - Open Prisma Studio (database GUI)
  • npx prisma generate - Generate Prisma Client
  • npx prisma db push - Push schema changes to database
  • npx prisma migrate dev - Create and apply migration

Database Schema

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)

Environment Variables

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

πŸ”’ Security

  • βœ… 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

🎨 Customization

Branding

Update the following files to customize branding:

  1. Logo & Name:

    • components/public/public-nav.tsx
    • components/public/footer.tsx
  2. Colors:

    • tailwind.config.ts - Update color scheme
    • app/globals.css - Update CSS variables
  3. Content:

    • app/(public)/about/page.tsx - Update about page
    • app/page.tsx - Update homepage content

Adding Features

  1. Add new API route: Create in app/api/[feature]/route.ts
  2. Add new admin page: Create in app/admin/[feature]/page.tsx
  3. Add new public page: Create in app/(public)/[feature]/page.tsx
  4. Update schema: Modify prisma/schema.prisma

πŸ“ˆ Performance

  • βœ… 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

πŸ› Troubleshooting

See DEPLOYMENT.md for common issues and solutions.

πŸ“ Future Enhancements

  • 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

πŸ“„ License

MIT

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ’¬ Support

For issues and questions:


Built with ❀️ using Next.js, Prisma, Supabase, and Tailwind CSS.

Deploy your own instance with one click: Deploy with Vercel

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •