Skip to content

PenThread: A responsive blog website with posts, comments, search, and categories. Built with HTML, CSS, and JavaScript for a seamless user experience.

Notifications You must be signed in to change notification settings

hemanthscode/penthread

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ PenThread - Full-Stack Blog Platform

Node.js React

๐ŸŒŸ Project Vision

PenThread is a modern, full-stack blogging platform designed for content creators, readers, and moderators to collaborate seamlessly. Built with enterprise-grade architecture, it delivers:

๐ŸŒŸ Rich content creation with categories and tags ๐Ÿ“Š Role-based dashboards (User, Author, Admin) ๐Ÿ’ฌ Advanced comment system with moderation โค๏ธ Social interactions (likes, favorites, views) ๐Ÿ”” Real-time notifications ๐ŸŽจ Beautiful, responsive UI with dark mode


๐Ÿ’‡๏ธ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    PENTHREAD PLATFORM                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚  โ”‚   REACT FRONTEND โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  EXPRESS BACKEND  โ”‚     โ”‚
โ”‚  โ”‚                  โ”‚  REST  โ”‚                   โ”‚     โ”‚
โ”‚  โ”‚  โ€ข Vite + React  โ”‚  API   โ”‚  โ€ข Node.js        โ”‚     โ”‚
โ”‚  โ”‚  โ€ข Tailwind CSS  โ”‚        โ”‚  โ€ข JWT Auth       โ”‚     โ”‚
โ”‚  โ”‚  โ€ข Zustand       โ”‚        โ”‚  โ€ข Mongoose ODM   โ”‚     โ”‚
โ”‚  โ”‚  โ€ข Axios         โ”‚        โ”‚  โ€ข Joi Validation โ”‚     โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚         โ–ฒ                              โ–ฒ                โ”‚
โ”‚         โ”‚                              โ”‚                โ”‚
โ”‚         โ”‚                              โ–ผ                โ”‚
โ”‚         โ”‚                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚         โ”‚                    โ”‚  MONGODB DATABASE โ”‚     โ”‚
โ”‚         โ”‚                    โ”‚                   โ”‚     โ”‚
โ”‚         โ”‚                    โ”‚  โ€ข Users          โ”‚     โ”‚
โ”‚         โ”‚                    โ”‚  โ€ข Posts          โ”‚     โ”‚
โ”‚         โ”‚                    โ”‚  โ€ข Comments       โ”‚     โ”‚
โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚  โ€ข Interactions   โ”‚     โ”‚
โ”‚           JWT + localStorage โ”‚  โ€ข Notifications  โ”‚     โ”‚
โ”‚                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽฏ Key Features

๐Ÿ” Authentication & Authorization

  • JWT-based secure authentication
  • Role-based access control (User, Author, Admin)
  • Password reset with email verification
  • Token refresh mechanism

๐Ÿ“ Content Management

  • Rich blog post creation and editing
  • Category and tag organization
  • Draft/Publish workflow
  • Author-owned content management

๐Ÿ’ฌ Advanced Comment System

  • Nested comment threads
  • Author/Admin comment moderation (Approve/Reject)
  • Comment status tracking (Pending/Approved/Rejected)
  • Comment owner deletion rights

โค๏ธ Social Interactions

  • Like posts
  • Favorite/bookmark posts
  • View count tracking
  • User interaction history

๐Ÿ“Š Analytics Dashboards

  • User Dashboard: Personal activity and stats
  • Author Dashboard: Post performance metrics
  • Admin Dashboard: Platform-wide analytics

๐Ÿ”” Notifications

  • Comment notifications
  • Moderation updates
  • Interaction alerts
  • Mark as read/unread

๐ŸŽจ Modern UI/UX

  • Responsive design (mobile-first)
  • Dark mode support
  • Smooth animations (Framer Motion)
  • Accessibility compliant

๐Ÿ”ง Technology Stack

Frontend

Technology Purpose
React 18 UI component library
Vite 5 Build tool & dev server
Tailwind CSS 3 Utility-first styling
Zustand State management
React Router 6 Client-side routing
Axios HTTP client
Framer Motion Animations
Lucide React Icon library

Backend

Technology Purpose
Node.js 18+ Runtime environment
Express 4 Web framework
MongoDB 6 NoSQL database
Mongoose ODM for MongoDB
JWT Authentication tokens
Joi Request validation
Bcryptjs Password hashing
Winston Logging
Nodemailer Email notifications

๐Ÿ—‚๏ธ Project Structure

๐Ÿ“ฆ penthread/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ backend/              # Node.js + Express API
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ config/          # DB, logger, env configs
โ”‚   โ”‚   โ”œโ”€โ”€ modules/         # Feature modules (auth, posts, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ middlewares/     # Auth, validation, error handling
โ”‚   โ”‚   โ”œโ”€โ”€ utils/           # Helpers, constants
โ”‚   โ”‚   โ”œโ”€โ”€ app.js           # Express app setup
โ”‚   โ”‚   โ””โ”€โ”€ server.js        # Server entry point
โ”‚   โ”œโ”€โ”€ .env
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ README.md
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ frontend/             # React + Vite SPA
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/      # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ pages/           # Route pages
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/           # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ services/        # API service layer
โ”‚   โ”‚   โ”œโ”€โ”€ store/           # Zustand stores
โ”‚   โ”‚   โ”œโ”€โ”€ context/         # React contexts
โ”‚   โ”‚   โ”œโ”€โ”€ utils/           # Helper functions
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx
โ”‚   โ”œโ”€โ”€ .env
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ README.md
โ”‚
โ””โ”€โ”€ ๐Ÿ“˜ README.md             # This file

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+ and npm 9+
  • MongoDB 6+ (local or Atlas)
  • Git

Installation

1. Clone Repository

git clone https://github.com/yourusername/penthread.git
cd penthread

2. Backend Setup

cd backend
npm install
cp .env.sample .env
# Edit .env with your MongoDB URI, JWT secret, etc.
npm run db:seed  # Seed database with sample data
npm run dev      # Start backend on port 5000

3. Frontend Setup

cd ../frontend
npm install
cp .env.sample .env
# Set VITE_API_BASE_URL=http://localhost:5000/api
npm run dev      # Start frontend on port 5173

4. Access Application

  • Frontend: http://localhost:5173
  • Backend API: http://localhost:5000/api

Default Seeded Accounts

Role Email Password
Admin admin@example.com Admin@123
Author author@example.com Author@123
User user@example.com User@123

๐Ÿงน API Documentation

Base URL

http://localhost:5000/api

Module Endpoints

Module Endpoints Auth Required
Auth /auth/register, /auth/login, /auth/refresh Mixed
Users /users, /users/:id, /users/profile โœ…
Posts /posts, /posts/:id, /posts/:id/publish โœ…
Comments /posts/:postId/comments, /comments/pending โœ…
Categories /categories, /categories/:id Mixed
Tags /tags, /tags/:id Mixed
Interactions /interactions/like, /interactions/favorite โœ…
Notifications /notifications, /notifications/:id/read โœ…
Dashboard /dashboard/admin, /dashboard/author โœ…

Import Postman Collection: backend/postman_collection.json


๐Ÿ‘ฅ User Roles & Permissions

Feature User Author Admin
View published posts โœ… โœ… โœ…
Create posts โŒ โœ… โœ…
Edit own posts โŒ โœ… โœ…
Edit any post โŒ โŒ โœ…
Comment on posts โœ… โœ… โœ…
Moderate own post comments โŒ โœ… โœ…
Moderate all comments โŒ โŒ โœ…
Manage categories/tags โŒ โœ… โœ…
View analytics Own Own All
User management โŒ โŒ โœ…

๐Ÿ”’ Security Features

โœ… Authentication

  • JWT access & refresh tokens
  • Bcrypt password hashing (10 rounds)
  • HTTP-only cookies (optional)

โœ… Authorization

  • Role-based middleware protection
  • Resource ownership validation
  • API endpoint guarding

โœ… Data Protection

  • Request validation with Joi schemas
  • MongoDB injection prevention
  • XSS protection via React JSX
  • CORS configuration
  • Rate limiting (Helmet + express-rate-limit)

โœ… Best Practices

  • Environment variable isolation
  • Centralized error handling
  • Audit logging with Winston
  • Secure HTTP headers

๐Ÿ“Š Database Schema

Core Collections

  • users - User accounts with role and profile info
  • posts - Blog posts with status, categories, tags
  • comments - Comments with moderation status
  • categories - Post categorization
  • tags - Post tagging
  • interactions - Likes, favorites, views
  • notifications - User notifications
  • activityLogs - Audit trail

Relationships

  • Users โ†” Posts (1:N - author relationship)
  • Posts โ†” Comments (1:N)
  • Posts โ†” Categories (N:M)
  • Posts โ†” Tags (N:M)
  • Users โ†” Interactions (1:N)

๐Ÿฅฏ Testing

Backend Testing

cd backend
npm run test        # Run Jest tests (to be implemented)

Postman Collection:

  • Automated tests for all endpoints
  • Environment variables for token management
  • Complete workflow testing

Frontend Testing

cd frontend
npm run test        # Run Vitest (to be implemented)
npm run test:e2e    # Run Playwright E2E tests

๐Ÿ“ฆ Deployment

Backend Deployment (Railway/Heroku/AWS)

# Build command
npm install
# Start command
npm run start
# Environment variables
NODE_ENV=production
MONGO_URI=<your-mongodb-atlas-uri>
JWT_SECRET=<your-secret>

Frontend Deployment (Vercel/Netlify)

# Build command
npm run build
# Output directory
dist/
# Environment variables
VITE_API_BASE_URL=https://your-backend-api.com/api

๐ŸŒˆ Features Roadmap

Phase 1 (Completed) โœ…

  • Full authentication system
  • Post CRUD with workflow
  • Comment system with moderation
  • Dashboard analytics
  • Social interactions

Phase 2 (Upcoming) ๐Ÿšง

  • Real-time notifications (WebSocket)
  • Rich text editor (TinyMCE/Quill)
  • Image upload (Cloudinary)
  • Advanced search & filters
  • Email queue system

Phase 3 (Future) ๐Ÿ”ฎ

  • Multi-language support (i18n)
  • Mobile app (React Native)
  • SEO optimization
  • Analytics dashboard v2
  • AI-powered content suggestions

๐Ÿค Contributing

We welcome contributions! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contribution Guidelines

  • Follow existing code style
  • Write meaningful commit messages
  • Add tests for new features
  • Update documentation

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ’ฌ Support & Contact


๐Ÿ™ Acknowledgments

  • React team for the amazing framework
  • Express.js community
  • MongoDB for flexible data modeling
  • Tailwind CSS for beautiful styling
  • All open-source contributors

โญ Show Your Support

If you find PenThread helpful, please give it a โญ on GitHub!


๐Ÿš€ Built with MERN, designed for scale, crafted with care. Made by developers, for developers and content creators.

About

PenThread: A responsive blog website with posts, comments, search, and categories. Built with HTML, CSS, and JavaScript for a seamless user experience.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages