AbhisharSingh/blogapp

0

stars

11

commits

JavaScript

primary language

Apr 4, 2026

updated

README

TechPulse β€” AI-Powered Tech & Engineering Blog

A production-ready MERN stack blog platform for software engineers and AI practitioners. Dark-first editorial design, AI-assisted authoring, full SEO optimization, and JWT-secured admin dashboard.

Screenshots / Live Demo

πŸ“Έ Add screenshots or a live demo link here once deployed.

Suggested screenshots:

  • Homepage hero section
  • Blog listing page with filters
  • Individual post with TL;DR, code highlighting, comments
  • Dashboard new-post editor with AI assist panel
  • Mobile responsive views

Tech Stack

LayerTechnology
FrontendReact 18, Vite, Tailwind CSS, React Router v6
Data LayerTanStack React Query v5
Rich Text EditorTipTap (with code block syntax highlighting)
SEOReact Helmet Async, JSON-LD, Open Graph
BackendNode.js, Express.js
DatabaseMongoDB Atlas (Mongoose ODM)
AuthJWT (access + refresh token rotation)
AIOpenAI API (gpt-4o-mini)
Rate Limitingexpress-rate-limit
ValidationJoi
DeploymentFrontend β†’ Vercel, Backend β†’ Render/Railway

Project Structure

blogapp/
β”œβ”€β”€ frontend/               # React + Vite app
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/          # Route-level page components
β”‚   β”‚   β”‚   └── dashboard/  # Admin dashboard pages
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/         # Layout, Navbar, Footer, ProtectedRoute, SEOHead
β”‚   β”‚   β”‚   └── blog/       # PostCard, NewsletterSignup
β”‚   β”‚   β”œβ”€β”€ hooks/          # useAuth (auth context)
β”‚   β”‚   β”œβ”€β”€ services/       # api.js (axios + all service functions)
β”‚   β”‚   └── utils/          # formatDate
β”‚   β”œβ”€β”€ vercel.json         # SPA fallback config
β”‚   └── .env.example
β”‚
└── backend/                # Express.js REST API
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ config/         # db.js (MongoDB connection)
    β”‚   β”œβ”€β”€ models/         # Mongoose models
    β”‚   β”œβ”€β”€ controllers/    # Route handlers
    β”‚   β”œβ”€β”€ routes/         # Express routers
    β”‚   β”œβ”€β”€ middleware/     # auth, admin, errorHandler, rateLimiter
    β”‚   β”œβ”€β”€ services/       # aiService.js (OpenAI)
    β”‚   β”œβ”€β”€ validators/     # Joi schemas
    β”‚   └── utils/          # slugify, readTime
    β”œβ”€β”€ db/
    β”‚   └── seed.js         # Database seeder (3 sample posts)
    β”œβ”€β”€ server.js
    └── .env.example

Local Setup

Prerequisites

  • Node.js 18+
  • MongoDB Atlas cluster (or local MongoDB)
  • OpenAI API key (optional β€” AI features degrade gracefully)

1. Clone and install

git clone https://github.com/AbhisharSingh/blogapp.git
cd blogapp

# Install backend deps
cd backend && npm install

# Install frontend deps
cd ../frontend && npm install

2. Configure environment variables

Backend β€” copy and edit:

cd backend
cp .env.example .env
# Edit .env with your values

Frontend β€” copy and edit:

cd frontend
cp .env.example .env
# Edit .env with your backend URL

3. Seed the database

cd backend
SEED_ADMIN_PASSWORD=YourSecurePassword123! npm run seed

This creates:

  • 3 sample published posts (RAG systems, React 18, LLM fine-tuning)
  • 3 categories (Machine Learning, Web Development, AI Engineering)
  • 1 admin user β€” email: admin@blogapp.dev, password: value of SEED_ADMIN_PASSWORD

4. Run the application

# Terminal 1 β€” Backend
cd backend
npm run dev   # starts on http://localhost:5000

# Terminal 2 β€” Frontend
cd frontend
npm run dev   # starts on http://localhost:5173

Open http://localhost:5173 in your browser.


Environment Variables Reference

Backend (backend/.env)

VariableDescriptionRequired
PORTServer port (default: 5000)No
MONGO_URIMongoDB connection stringYes
JWT_SECRETSecret for access tokensYes
JWT_REFRESH_SECRETSecret for refresh tokensYes
JWT_EXPIREAccess token TTL (default: 15m)No
JWT_REFRESH_EXPIRERefresh token TTL (default: 7d)No
OPENAI_API_KEYOpenAI API key for AI featuresNo
FRONTEND_URLAllowed CORS origin(s), comma-separatedNo
NODE_ENVdevelopment or productionNo
CLOUDINARY_CLOUD_NAMECloudinary cloud nameNo
CLOUDINARY_API_KEYCloudinary API keyNo
CLOUDINARY_API_SECRETCloudinary API secretNo

Frontend (frontend/.env)

VariableDescriptionRequired
VITE_API_URLBackend API base URLYes

API Documentation

Base URL: http://localhost:5000/api

All error responses follow: { "success": false, "message": "..." }

Health

MethodEndpointDescription
GET/healthHealth check

Auth

MethodEndpointBodyAuth
POST/auth/register{ name, email, password }β€”
POST/auth/login{ email, password }β€”
POST/auth/refresh{ refreshToken }β€”
POST/auth/logout{ refreshToken }β€”

Posts

MethodEndpointQuery ParamsAuth
GET/postspage, limit, category, tag, statusβ€”
GET/posts/searchq (search query)β€”
GET/posts/:slugβ€”β€”
POST/postsβ€”Admin
PUT/posts/:idβ€”Admin
DELETE/posts/:idβ€”Admin

Create/Update Post body:

{
  "title": "string",
  "excerpt": "string (max 300)",
  "content": "HTML string",
  "category": "string",
  "tags": ["tag1", "tag2"],
  "status": "draft|published",
  "coverImage": { "url": "string", "alt": "string" },
  "metaTitle": "string (max 60)",
  "metaDescription": "string (max 160)",
  "keywords": ["kw1", "kw2"],
  "tldr": ["point 1", "point 2", "point 3"]
}

Categories & Tags

MethodEndpointDescription
GET/categoriesGet all categories
GET/tagsGet all tags with counts

Comments

MethodEndpointBodyAuth
GET/posts/:id/commentsβ€”β€”
POST/posts/:id/comments{ authorName, email, content }β€”
DELETE/comments/:idβ€”Admin

Newsletter

MethodEndpointBody
POST/newsletter/subscribe{ email }

AI (Admin only)

MethodEndpointBodyDescription
POST/ai/generate{ topic, tone }Generate full draft
POST/ai/improve{ paragraph, instruction? }Rewrite paragraph
POST/ai/seo{ content, title }Generate SEO meta
POST/ai/tags{ content, title }Suggest tags
POST/ai/summary{ content }Generate TL;DR

Deployment Guide

MongoDB Atlas

  1. Create a free M0 cluster at mongodb.com/atlas
  2. Create a database user with readWrite role
  3. Whitelist IP 0.0.0.0/0 (or your Render/Railway IP)
  4. Copy the connection string to MONGO_URI

Backend β€” Render

  1. Push code to GitHub
  2. Go to render.com β†’ New Web Service
  3. Connect your GitHub repo, set root directory to backend
  4. Build command: npm install
  5. Start command: node server.js
  6. Add all environment variables from backend/.env.example
  7. Health check path: /api/health

Backend β€” Railway

  1. Go to railway.app β†’ New Project β†’ Deploy from GitHub
  2. Select repo, set root to backend
  3. Set PORT variable (Railway auto-detects)
  4. Add all other env vars
  5. Deploy

Frontend β€” Vercel

  1. Go to vercel.com β†’ New Project
  2. Import GitHub repo, set root directory to frontend
  3. Framework: Vite
  4. Add environment variable: VITE_API_URL=https://your-backend.onrender.com/api
  5. Deploy β€” vercel.json handles SPA routing fallback automatically

Features

  • βœ… Dark-first editorial design (Syne + Lora typography)
  • βœ… JWT auth with access + refresh token rotation
  • βœ… Role-based access (admin / reader)
  • βœ… TipTap rich text editor with code block syntax highlighting
  • βœ… AI draft generation, paragraph improvement, SEO metadata (OpenAI)
  • βœ… Full-text post search
  • βœ… Infinite scroll blog listing with category/tag filters
  • βœ… Related posts on single post page
  • βœ… View counter on posts
  • βœ… TL;DR summary box on posts
  • βœ… Comment system (moderated)
  • βœ… Newsletter subscription
  • βœ… React Helmet Async (meta, OG, Twitter card, canonical, JSON-LD)
  • βœ… robots.txt served from backend
  • βœ… Rate limiting (global + auth-specific)
  • βœ… Input validation (Joi)
  • βœ… Centralized error handling
  • βœ… Database seed script
  • βœ… Vercel SPA fallback config
  • βœ… .env.example for both frontend and backend

Contributors

Copilot

9 commits

AbhisharSingh

2 commits

AbhisharSingh/blogapp

0

stars

11

commits

JavaScript

primary language

Apr 4, 2026

updated

README

TechPulse β€” AI-Powered Tech & Engineering Blog

A production-ready MERN stack blog platform for software engineers and AI practitioners. Dark-first editorial design, AI-assisted authoring, full SEO optimization, and JWT-secured admin dashboard.

Screenshots / Live Demo

πŸ“Έ Add screenshots or a live demo link here once deployed.

Suggested screenshots:

  • Homepage hero section
  • Blog listing page with filters
  • Individual post with TL;DR, code highlighting, comments
  • Dashboard new-post editor with AI assist panel
  • Mobile responsive views

Tech Stack

LayerTechnology
FrontendReact 18, Vite, Tailwind CSS, React Router v6
Data LayerTanStack React Query v5
Rich Text EditorTipTap (with code block syntax highlighting)
SEOReact Helmet Async, JSON-LD, Open Graph
BackendNode.js, Express.js
DatabaseMongoDB Atlas (Mongoose ODM)
AuthJWT (access + refresh token rotation)
AIOpenAI API (gpt-4o-mini)
Rate Limitingexpress-rate-limit
ValidationJoi
DeploymentFrontend β†’ Vercel, Backend β†’ Render/Railway

Project Structure

blogapp/
β”œβ”€β”€ frontend/               # React + Vite app
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/          # Route-level page components
β”‚   β”‚   β”‚   └── dashboard/  # Admin dashboard pages
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/         # Layout, Navbar, Footer, ProtectedRoute, SEOHead
β”‚   β”‚   β”‚   └── blog/       # PostCard, NewsletterSignup
β”‚   β”‚   β”œβ”€β”€ hooks/          # useAuth (auth context)
β”‚   β”‚   β”œβ”€β”€ services/       # api.js (axios + all service functions)
β”‚   β”‚   └── utils/          # formatDate
β”‚   β”œβ”€β”€ vercel.json         # SPA fallback config
β”‚   └── .env.example
β”‚
└── backend/                # Express.js REST API
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ config/         # db.js (MongoDB connection)
    β”‚   β”œβ”€β”€ models/         # Mongoose models
    β”‚   β”œβ”€β”€ controllers/    # Route handlers
    β”‚   β”œβ”€β”€ routes/         # Express routers
    β”‚   β”œβ”€β”€ middleware/     # auth, admin, errorHandler, rateLimiter
    β”‚   β”œβ”€β”€ services/       # aiService.js (OpenAI)
    β”‚   β”œβ”€β”€ validators/     # Joi schemas
    β”‚   └── utils/          # slugify, readTime
    β”œβ”€β”€ db/
    β”‚   └── seed.js         # Database seeder (3 sample posts)
    β”œβ”€β”€ server.js
    └── .env.example

Local Setup

Prerequisites

  • Node.js 18+
  • MongoDB Atlas cluster (or local MongoDB)
  • OpenAI API key (optional β€” AI features degrade gracefully)

1. Clone and install

git clone https://github.com/AbhisharSingh/blogapp.git
cd blogapp

# Install backend deps
cd backend && npm install

# Install frontend deps
cd ../frontend && npm install

2. Configure environment variables

Backend β€” copy and edit:

cd backend
cp .env.example .env
# Edit .env with your values

Frontend β€” copy and edit:

cd frontend
cp .env.example .env
# Edit .env with your backend URL

3. Seed the database

cd backend
SEED_ADMIN_PASSWORD=YourSecurePassword123! npm run seed

This creates:

  • 3 sample published posts (RAG systems, React 18, LLM fine-tuning)
  • 3 categories (Machine Learning, Web Development, AI Engineering)
  • 1 admin user β€” email: admin@blogapp.dev, password: value of SEED_ADMIN_PASSWORD

4. Run the application

# Terminal 1 β€” Backend
cd backend
npm run dev   # starts on http://localhost:5000

# Terminal 2 β€” Frontend
cd frontend
npm run dev   # starts on http://localhost:5173

Open http://localhost:5173 in your browser.


Environment Variables Reference

Backend (backend/.env)

VariableDescriptionRequired
PORTServer port (default: 5000)No
MONGO_URIMongoDB connection stringYes
JWT_SECRETSecret for access tokensYes
JWT_REFRESH_SECRETSecret for refresh tokensYes
JWT_EXPIREAccess token TTL (default: 15m)No
JWT_REFRESH_EXPIRERefresh token TTL (default: 7d)No
OPENAI_API_KEYOpenAI API key for AI featuresNo
FRONTEND_URLAllowed CORS origin(s), comma-separatedNo
NODE_ENVdevelopment or productionNo
CLOUDINARY_CLOUD_NAMECloudinary cloud nameNo
CLOUDINARY_API_KEYCloudinary API keyNo
CLOUDINARY_API_SECRETCloudinary API secretNo

Frontend (frontend/.env)

VariableDescriptionRequired
VITE_API_URLBackend API base URLYes

API Documentation

Base URL: http://localhost:5000/api

All error responses follow: { "success": false, "message": "..." }

Health

MethodEndpointDescription
GET/healthHealth check

Auth

MethodEndpointBodyAuth
POST/auth/register{ name, email, password }β€”
POST/auth/login{ email, password }β€”
POST/auth/refresh{ refreshToken }β€”
POST/auth/logout{ refreshToken }β€”

Posts

MethodEndpointQuery ParamsAuth
GET/postspage, limit, category, tag, statusβ€”
GET/posts/searchq (search query)β€”
GET/posts/:slugβ€”β€”
POST/postsβ€”Admin
PUT/posts/:idβ€”Admin
DELETE/posts/:idβ€”Admin

Create/Update Post body:

{
  "title": "string",
  "excerpt": "string (max 300)",
  "content": "HTML string",
  "category": "string",
  "tags": ["tag1", "tag2"],
  "status": "draft|published",
  "coverImage": { "url": "string", "alt": "string" },
  "metaTitle": "string (max 60)",
  "metaDescription": "string (max 160)",
  "keywords": ["kw1", "kw2"],
  "tldr": ["point 1", "point 2", "point 3"]
}

Categories & Tags

MethodEndpointDescription
GET/categoriesGet all categories
GET/tagsGet all tags with counts

Comments

MethodEndpointBodyAuth
GET/posts/:id/commentsβ€”β€”
POST/posts/:id/comments{ authorName, email, content }β€”
DELETE/comments/:idβ€”Admin

Newsletter

MethodEndpointBody
POST/newsletter/subscribe{ email }

AI (Admin only)

MethodEndpointBodyDescription
POST/ai/generate{ topic, tone }Generate full draft
POST/ai/improve{ paragraph, instruction? }Rewrite paragraph
POST/ai/seo{ content, title }Generate SEO meta
POST/ai/tags{ content, title }Suggest tags
POST/ai/summary{ content }Generate TL;DR

Deployment Guide

MongoDB Atlas

  1. Create a free M0 cluster at mongodb.com/atlas
  2. Create a database user with readWrite role
  3. Whitelist IP 0.0.0.0/0 (or your Render/Railway IP)
  4. Copy the connection string to MONGO_URI

Backend β€” Render

  1. Push code to GitHub
  2. Go to render.com β†’ New Web Service
  3. Connect your GitHub repo, set root directory to backend
  4. Build command: npm install
  5. Start command: node server.js
  6. Add all environment variables from backend/.env.example
  7. Health check path: /api/health

Backend β€” Railway

  1. Go to railway.app β†’ New Project β†’ Deploy from GitHub
  2. Select repo, set root to backend
  3. Set PORT variable (Railway auto-detects)
  4. Add all other env vars
  5. Deploy

Frontend β€” Vercel

  1. Go to vercel.com β†’ New Project
  2. Import GitHub repo, set root directory to frontend
  3. Framework: Vite
  4. Add environment variable: VITE_API_URL=https://your-backend.onrender.com/api
  5. Deploy β€” vercel.json handles SPA routing fallback automatically

Features

  • βœ… Dark-first editorial design (Syne + Lora typography)
  • βœ… JWT auth with access + refresh token rotation
  • βœ… Role-based access (admin / reader)
  • βœ… TipTap rich text editor with code block syntax highlighting
  • βœ… AI draft generation, paragraph improvement, SEO metadata (OpenAI)
  • βœ… Full-text post search
  • βœ… Infinite scroll blog listing with category/tag filters
  • βœ… Related posts on single post page
  • βœ… View counter on posts
  • βœ… TL;DR summary box on posts
  • βœ… Comment system (moderated)
  • βœ… Newsletter subscription
  • βœ… React Helmet Async (meta, OG, Twitter card, canonical, JSON-LD)
  • βœ… robots.txt served from backend
  • βœ… Rate limiting (global + auth-specific)
  • βœ… Input validation (Joi)
  • βœ… Centralized error handling
  • βœ… Database seed script
  • βœ… Vercel SPA fallback config
  • βœ… .env.example for both frontend and backend

Contributors

Copilot

9 commits

AbhisharSingh

2 commits

Languages

JavaScript

95.0%

CSS

4.6%