Skip to content

pixiebytez/fullstack-strapi-blog-admin-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Blog CMS Platform

Production-grade headless CMS built with Strapi v5 + Next.js 14 + PostgreSQL + Redis + Docker

CI/CD License: MIT Strapi v5 Next.js 14


image

πŸš€ Features

Feature Details
Strapi v5 Backend Headless CMS with REST + GraphQL APIs
Next.js 14 Frontend App Router, SSR, ISR, static generation
PostgreSQL Primary database with connection pooling
Redis Caching API response caching, rate limiting store
JWT Auth Register, login, forgot password, email verify
RBAC Admin, Moderator, Author, Public roles
Blog CMS Draft/publish, slugs, SEO meta, OpenGraph
Comment System Nested comments, moderation, spam detection
Newsletter Subscribe, confirm, unsubscribe flows
AI Generation OpenAI integration for content generation
Trending Engine Score-based trending with decay algorithm
Search API Full-text search across blogs
Related Posts Category + tag based recommendations
Image Upload Cloudinary (prod) / local (dev)
Docker Dev + prod compose files, multi-stage builds
CI/CD GitHub Actions β€” lint, test, build, deploy
Nginx Reverse proxy, SSL, gzip, rate limiting

πŸ“ Project Structure

ai-blog-cms/
β”œβ”€β”€ backend/                    # Strapi v5
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ database.js         # PostgreSQL config
β”‚   β”‚   β”œβ”€β”€ server.js           # Host/port/admin
β”‚   β”‚   β”œβ”€β”€ middlewares.js      # Middleware stack
β”‚   β”‚   └── plugins.js          # GraphQL, email, upload
β”‚   └── src/
β”‚       β”œβ”€β”€ api/
β”‚       β”‚   β”œβ”€β”€ blog/           # Blog CRUD + custom endpoints
β”‚       β”‚   β”œβ”€β”€ category/       # Categories
β”‚       β”‚   β”œβ”€β”€ tag/            # Tags
β”‚       β”‚   β”œβ”€β”€ comment/        # Comments + moderation
β”‚       β”‚   └── newsletter/     # Newsletter subscription
β”‚       β”œβ”€β”€ middlewares/
β”‚       β”‚   β”œβ”€β”€ rate-limit.js   # Redis-backed rate limiting
β”‚       β”‚   β”œβ”€β”€ redis-cache.js  # Response caching
β”‚       β”‚   └── audit-log.js    # Write operation logging
β”‚       β”œβ”€β”€ policies/
β”‚       β”‚   β”œβ”€β”€ is-owner.js     # Resource ownership check
β”‚       β”‚   β”œβ”€β”€ is-admin.js     # Role-based access
β”‚       β”‚   └── is-authenticated.js
β”‚       β”œβ”€β”€ extensions/
β”‚       β”‚   └── users-permissions/  # Custom auth + lifecycle hooks
β”‚       └── index.js            # Cron jobs, health endpoint
β”‚
β”œβ”€β”€ frontend/                   # Next.js 14
β”‚   └── src/
β”‚       β”œβ”€β”€ app/
β”‚       β”‚   β”œβ”€β”€ page.tsx                    # Home (ISR)
β”‚       β”‚   β”œβ”€β”€ blog/page.tsx               # Blog list
β”‚       β”‚   β”œβ”€β”€ blog/[slug]/page.tsx        # Blog detail (SSG + ISR)
β”‚       β”‚   β”œβ”€β”€ (auth)/login/page.tsx
β”‚       β”‚   β”œβ”€β”€ (auth)/register/page.tsx
β”‚       β”‚   └── (dashboard)/dashboard/page.tsx
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ blog/           # BlogCard, BlogList, RelatedPosts
β”‚       β”‚   β”œβ”€β”€ comment/        # CommentSection (nested)
β”‚       β”‚   └── layout/         # Header, Footer
β”‚       β”œβ”€β”€ hooks/
β”‚       β”‚   β”œβ”€β”€ useAuth.ts      # Authentication hook
β”‚       β”‚   └── useBlogs.ts     # Blog data hooks
β”‚       β”œβ”€β”€ lib/
β”‚       β”‚   β”œβ”€β”€ strapi.ts       # Axios API client
β”‚       β”‚   └── utils.ts        # Utilities
β”‚       β”œβ”€β”€ store/
β”‚       β”‚   └── auth.store.ts   # Zustand auth store
β”‚       └── types/index.ts      # TypeScript interfaces
β”‚
β”œβ”€β”€ nginx/nginx.conf            # Reverse proxy config
β”œβ”€β”€ docker-compose.yml          # Development stack
β”œβ”€β”€ docker-compose.prod.yml     # Production stack
└── .github/workflows/ci-cd.yml # GitHub Actions pipeline

⚑ Quick Start (Docker β€” recommended)

Prerequisites

  • Docker Desktop 4.x+
  • Docker Compose v2+
# 1. Clone the repo
git clone https://github.com/yourusername/ai-blog-cms.git
cd ai-blog-cms

# 2. Copy environment files
cp backend/.env.example  backend/.env
cp frontend/.env.example frontend/.env.local

# 3. Edit backend/.env β€” set your secrets
nano backend/.env

# 4. Start all services
docker compose up -d

# 5. Open the apps
# Strapi Admin:  http://localhost:1337/admin
# Next.js:       http://localhost:3000
# PgAdmin:       http://localhost:5050
# GraphQL:       http://localhost:1337/graphql

πŸ›  Local Development (without Docker)

Backend

cd backend
npm install
cp .env.example .env
# Edit .env with your PostgreSQL/Redis credentials
npm run develop

Frontend

cd frontend
npm install
cp .env.example .env.local
# Edit .env.local with NEXT_PUBLIC_STRAPI_URL
npm run dev

πŸ”‘ Environment Variables

Backend (backend/.env)

Variable Description Example
DATABASE_CLIENT DB driver postgres
DATABASE_HOST DB host localhost
DATABASE_NAME DB name aiblog
DATABASE_USERNAME DB user aiblog
DATABASE_PASSWORD DB password secret
REDIS_HOST Redis host localhost
REDIS_PASSWORD Redis password secret
JWT_SECRET 32+ char secret your_secret
OPENAI_API_KEY OpenAI key sk-...
CLOUDINARY_NAME Cloudinary cloud mycloud
SMTP_HOST Email host smtp.gmail.com

Frontend (frontend/.env.local)

Variable Description
NEXT_PUBLIC_STRAPI_URL Strapi base URL
NEXT_PUBLIC_STRAPI_API_TOKEN Strapi API token
NEXT_PUBLIC_SITE_URL Your frontend URL
REVALIDATE_SECRET ISR revalidation token

πŸ“‘ API Reference

REST Endpoints

Blogs

Method Endpoint Description
GET /api/blogs List blogs (paginated, filterable)
GET /api/blogs/slug/:slug Get blog by slug
GET /api/blogs/trending Get trending blogs
GET /api/blogs/search?q=... Full-text search
GET /api/blogs/:id/related Get related posts
POST /api/blogs Create blog (auth required)
PUT /api/blogs/:id Update blog (owner only)
DELETE /api/blogs/:id Delete blog (owner only)
POST /api/blogs/generate AI-generate content

Categories

Method Endpoint Description
GET /api/categories List all categories with blog count
GET /api/categories/slug/:slug Category + paginated blogs

Comments

Method Endpoint Description
GET /api/comments/blog/:blogId Get approved comments
POST /api/comments Post comment (auth required)
POST /api/comments/:id/like Like a comment
PATCH /api/comments/:id/moderate Moderate (admin only)

Auth

Method Endpoint Description
POST /api/auth/local Login
POST /api/auth/local/register Register
POST /api/auth/forgot-password Forgot password
POST /api/auth/reset-password Reset password
GET /api/users/me Get current user

Newsletter

Method Endpoint Description
POST /api/newsletters/subscribe Subscribe
GET /api/newsletters/confirm?token= Confirm email
GET /api/newsletters/unsubscribe?email= Unsubscribe

GraphQL

http://localhost:1337/graphql

Sample query:

query GetBlogs($page: Int, $pageSize: Int) {
  blogs(
    pagination: { page: $page, pageSize: $pageSize }
    sort: "publishedDate:desc"
    filters: { publishedAt: { notNull: true } }
  ) {
    data {
      id
      attributes {
        title
        slug
        excerpt
        publishedDate
        viewCount
        featuredImage { data { attributes { url } } }
        author { data { attributes { username firstName lastName } } }
        category { data { attributes { name slug } } }
      }
    }
    meta { pagination { total pageCount } }
  }
}

πŸš€ Production Deployment

See DEPLOYMENT.md for the full production guide.

Quick summary:

# 1. Set production secrets in .env files
# 2. Build and start production stack
docker compose -f docker-compose.prod.yml up -d

# 3. Set up SSL (Let's Encrypt)
certbot certonly --webroot -w /var/www/certbot -d yourdomain.com

πŸ—οΈ Architecture

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Nginx (443)   β”‚  SSL termination, rate limiting
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
          β”‚  Next.js:3000β”‚      β”‚ Strapi:1337   β”‚
          β”‚  (SSR/ISR)   β”‚      β”‚ (REST/GraphQL)β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                          β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
                          β”‚PostgreSQL β”‚   β”‚   Redis   β”‚
                          β”‚ (primary) β”‚   β”‚ (cache)   β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” RBAC Roles

Role Permissions
Public Read published blogs, categories, tags, comments
Authenticated + Create comments, like, subscribe
Author + Create/edit/delete own blogs
Moderator + Moderate comments, manage categories/tags
Administrator Full access to everything + admin panel

πŸ“Š Performance Features

  • ISR (Incremental Static Regeneration) β€” blog pages cached and revalidated every 5 mins
  • Redis caching β€” API responses cached (5min default, configurable per route)
  • CDN-friendly β€” all static assets have immutable cache headers
  • Image optimisation β€” Next.js <Image> with AVIF/WebP, Cloudinary CDN
  • Connection pooling β€” PostgreSQL pool (min 2, max 10)
  • Query optimisation β€” selective populate on every Strapi query
  • Gzip compression β€” enabled in both Nginx and Next.js

πŸ€– AI Content Generation

# POST /api/blogs/generate
curl -X POST http://localhost:1337/api/blogs/generate \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "topic":    "Strapi v5 Production Setup Guide",
    "tone":     "professional",
    "length":   "long",
    "keywords": ["strapi tutorial", "headless cms", "nodejs"]
  }'

Returns: { title, excerpt, content (markdown), tags, seoMeta }


πŸ“„ License

MIT Β© 2024 AI Blog CMS β€” Open source and free to use.


🌟 Keywords (SEO)

Strapi tutorial Β· Strapi CMS example Β· Strapi production setup Β· Strapi with Next.js Β· Strapi Docker setup Β· Strapi authentication Β· Strapi PostgreSQL guide Β· Build CMS with Strapi Β· Strapi REST API example Β· Strapi GraphQL tutorial

About

πŸš€ Full-stack Strapi blog with admin dashboard β€” A production-ready headless CMS blog built with Strapi backend, React/Next.js frontend, and a powerful admin panel. Features authentication, CRUD operations, media management, and custom admin UI. Ideal for developers learning Strapi, headless CMS architecture, or building full-stack JS applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors