Skip to content

pixel-prady/blogify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Blogify

A modern, full-stack blogging platform with rich text editing, syntax highlighting, authentication, and AI-powered blog generation. Built with the MERN stack and Google GenAI.

πŸš€ Features

  • πŸ” Secure authentication system with:

    • Access & Refresh Tokens (JWT)
    • HttpOnly cookies for storing tokens securely
    • Hashed passwords using bcrypt
  • πŸ–‹οΈ Rich Text Editor using Quill.js

  • πŸ€– AI Blog Writing powered by Google GenAI

  • πŸ’‘ Syntax Highlighting with Highlight.js

  • ⏱️ Relative timestamps with Moment.js

  • 🧼 HTML sanitization using dompurify

  • πŸ› οΈ File uploads via Multer and ImageKit

  • πŸ§‘β€πŸ’Ό Admin dashboard with blog and comment moderation tools:

    • View all blogs created by the logged-in admin
    • Approve or delete user comments
    • Toggle publish/unpublish status of blogs
    • Access dashboard metrics (total blogs, drafts, and comments count)
  • βš™οΈ State Management via Redux Toolkit

  • πŸ“£ Toast Notifications with react-hot-toast

  • 🎨 Tailwind CSS for styling

  • πŸŒ€ Smooth animations using Framer Motion

  • ☁️ Frontend deployed on Vercel

  • ☁️ Backend deployed on Railway - Deployed Backend repo


πŸ§‘β€πŸ’» Tech Stack

Frontend

  • React 18 (latest stable)
  • Vite 7
  • Tailwind CSS 4
  • React Router v7
  • Quill.js (Rich Text Editor)
  • Highlight.js (Code syntax highlighting)
  • Redux Toolkit (State management)
  • Axios
  • DOMPurify (HTML sanitization)
  • Moment.js
  • Framer Motion (Animations)
  • react-hot-toast (Notifications)
  • @tailwindcss/vite (Vite plugin for Tailwind)

Backend

  • Node.js (ESModules)
  • Express v5
  • MongoDB with Mongoose
  • JWT Authentication:
    • Access Token (short-lived)
    • Refresh Token (long-lived)
  • bcrypt for secure password hashing πŸ”
  • Google GenAI SDK (@google/genai) for AI blog creation
  • Multer (File uploads handling)
  • ImageKit SDK (Cloud image uploads)
  • Cookie-parser (HttpOnly cookie support)
  • CORS & dotenv for environment config
  • Nodemon (Dev server reload)
  • Prettier (Code formatting)

πŸ“ Project Structure

backend
β”œβ”€β”€ public
β”‚   └── temp ( for storing the image uploaded on server )
└── src
    β”œβ”€β”€ app.js
    β”œβ”€β”€ constants.js
    β”œβ”€β”€ controllers
    β”‚   β”œβ”€β”€ admin.controller.js
    β”‚   β”œβ”€β”€ blog.controller.js
    β”‚   └── user.controller.js
    β”œβ”€β”€ db
    β”‚   └── connection.js
    β”œβ”€β”€ gemini
    β”‚   └── gemini.js
    β”œβ”€β”€ index.js  ( entry point )
    β”œβ”€β”€ middleware
    β”‚   β”œβ”€β”€ auth.middleware.js
    β”‚   └── multer.middleware.js
    β”œβ”€β”€ models
    β”‚   β”œβ”€β”€ blog.model.js
    β”‚   β”œβ”€β”€ comments.model.js
    β”‚   └── user.model.js
    β”œβ”€β”€ routes
    β”‚   β”œβ”€β”€ admin.route.js
    β”‚   β”œβ”€β”€ auth.route.js ( refresh access token )
    β”‚   β”œβ”€β”€ blog.route.js
    β”‚   └── user.routes.js
    └── utils 
        β”œβ”€β”€ apiError.js
        β”œβ”€β”€ apiResponse.js
        β”œβ”€β”€ asyncHandler.js
        └── imageKit.js


frontend
β”œβ”€β”€ index.html
β”œβ”€β”€ public
β”‚   └── favicon.svg
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ App.css
β”‚   β”œβ”€β”€ App.jsx
β”‚   β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ components
β”‚   β”‚   β”œβ”€β”€ Blogcard.jsx
β”‚   β”‚   β”œβ”€β”€ Bloglist.jsx
β”‚   β”‚   β”œβ”€β”€ Footer.jsx
β”‚   β”‚   β”œβ”€β”€ Header.jsx
β”‚   β”‚   β”œβ”€β”€ Loader.jsx
β”‚   β”‚   β”œβ”€β”€ Logo.jsx
β”‚   β”‚   β”œβ”€β”€ NavBar.jsx
β”‚   β”‚   β”œβ”€β”€ Newsletter.jsx
β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.jsx
β”‚   β”‚   └── admin
β”‚   β”‚       β”œβ”€β”€ BlogTableItem.jsx
β”‚   β”‚       β”œβ”€β”€ CommentTableItem.jsx
β”‚   β”‚       β”œβ”€β”€ Login.jsx
β”‚   β”‚       β”œβ”€β”€ Register.jsx
β”‚   β”‚       └── Sidebar.jsx
β”‚   β”œβ”€β”€ hooks
β”‚   β”‚   └── typingHook.jsx
β”‚   β”œβ”€β”€ index.css
β”‚   β”œβ”€β”€ main.jsx
β”‚   β”œβ”€β”€ pages
β”‚   β”‚   β”œβ”€β”€ Blog.jsx
β”‚   β”‚   β”œβ”€β”€ Home.jsx
β”‚   β”‚   └── admin
β”‚   β”‚       β”œβ”€β”€ Addblog.jsx
β”‚   β”‚       β”œβ”€β”€ Comments.jsx
β”‚   β”‚       β”œβ”€β”€ Dashboard.jsx
β”‚   β”‚       β”œβ”€β”€ Layout.jsx
β”‚   β”‚       └── Listblog.jsx
β”‚   β”œβ”€β”€ store
β”‚   β”‚   β”œβ”€β”€ slices
β”‚   β”‚   β”‚   └── appSlice.js
β”‚   β”‚   └── store.js
β”‚   └── utils
β”‚       └── RefreshAccessToken.js


πŸ—‚οΈ Backend Model Schema

Below is the backend model schema showing the relations between users, blogs, and comments tables:

Backend Model Schema


πŸ“¦ Installation

Clone the repository

git clone https://github.com/pixel-prady/blogify.git
cd blogify

βš™οΈ Environment Variables Setup

Create .env files in both your backend and frontend folders with the following variables:

Backend .env

PORT=8000
MONGODB_URI=your_mongodb_connection_string
CORS_ORIGIN=http://localhost:5173
IMAGEKIT_PUBLIC_KEY=your_imagekit_public_key
IMAGEKIT_PRIVATE_KEY=your_imagekit_private_key
IMAGEKIT_URL_ENDPOINT=your_imagekit_url_endpoint

ACCESS_TOKEN_SECRET=your_jwt_access_token_secret
ACCESS_TOKEN_EXPIRY=30m 
REFRESH_TOKEN_SECRET=your_jwt_refresh_token_secret
REFRESH_TOKEN_EXPIRY=2d

GEMINI_API_KEY=your_google_genai_api_key

Frontend .env

VITE_BASE_URL="http://localhost:8000"

Setup Backend

cd backend
npm install
npm run dev

Setup frontend

cd frontend
npm install
npm run dev

πŸ”Œ API Routes

The backend exposes the following API endpoints, grouped by functionality:

User Routes (/api/v1/users)

Method Endpoint Description
POST /register Register a new user
POST /login User login
POST /logout Logout (authenticated)

Blog Routes (/api/v1/blog)

Method Endpoint Description
GET /all Get all blogs
GET /:blogId Get a blog by ID
POST /add-comment Add a comment to a blog
POST /comments Get comments for a blog
POST /addBlog Add a new blog (authenticated)
POST /delete Delete a blog by ID (authenticated)
POST /toggle-publish Toggle publish status (authenticated)
POST /generate Generate AI-powered blog content (authenticated)

Admin Routes (/api/v1/admin)

Method Endpoint Description
GET /comments Get all comments (authenticated)
GET /blogs Get all blogs of logged-in user (authenticated)
POST /delete-comment Delete a comment by ID (authenticated)
POST /approve-comment Approve a comment (authenticated)
GET /dashboard Get admin dashboard data (authenticated)

Auth Routes (/api/v1/token/refresh)

  • Routes related to token refresh and authentication management.

Note: Routes marked with (authenticated) require a valid JWT access token in the request headers.


πŸ–ΌοΈ Image Upload & Deletion Workflow

Blogify handles images with a hybrid approach of temporary local storage and cloud hosting via ImageKit.io, ensuring fast delivery and optimized space usage.

πŸ“Š Flow Diagram

Image Upload & Deletion Workflow


🎯 Fun Feature

✨ Instant UI Transformation

Change a single CSS variable in your index.css to completely restyle the entire application β€” including all SVG icon colors:

@theme {
  --color-primary: #711400;
}

🀝 Contributing

Contributions are welcome! Feel free to open issues or submit pull requests for improvements or bug fixes.

❀️ Made with love by Pradhuman Chaudhary

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published