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

Skip to content

karthi209/pattinam

Repository files navigation

Pattinam Blog Platform

A modern blog platform with interactive maps, user authentication, and content management features.

Features

Blog Posts

  • Create, read, update, and delete blog posts
  • Rich text content support
  • Interactive map integration
  • Category-based organization
  • SEO-friendly URLs with slugs
  • View count tracking
  • Publication date management

User Management

  • Google OAuth authentication
  • User roles (admin, user)
  • Profile management
    • Username customization
    • Display name updates
    • Last login tracking
  • Secure JWT-based authentication

Comments System

  • Nested comments (up to 3 levels deep)
  • Like/Dislike functionality
  • Image upload support
  • Comment reactions tracking
  • Moderation capabilities
  • Real-time updates

Map Integration

  • Interactive map embedding in posts
  • Custom map center coordinates
  • Zoom level control
  • Location-based features
  • Map data persistence

Admin Features

  • Post management dashboard
  • User role management
  • Content moderation
  • Analytics tracking
  • System configuration

Technical Stack

Frontend

  • React.js
  • Tailwind CSS
  • React Router
  • Context API for state management
  • Custom hooks for authentication
  • Responsive design

Backend

  • Node.js with Express
  • PostgreSQL database
  • JWT authentication
  • Google OAuth integration
  • File upload handling
  • Rate limiting
  • CORS configuration

Security Features

  • Helmet.js for security headers
  • Rate limiting for API protection
  • CORS policy implementation
  • Secure session management
  • Password hashing
  • Input validation
  • XSS protection

Setup Instructions

Prerequisites

  • Node.js (v14 or higher)
  • PostgreSQL (v12 or higher)
  • Google OAuth credentials

Environment Variables

Create a .env file in the backend directory with:

DB_HOST=your_db_host
DB_PORT=your_db_port
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_db_name
JWT_SECRET=your_jwt_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=your_google_callback_url
FRONTEND_URL=your_frontend_url

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/pattinam.git
cd pattinam
  1. Install backend dependencies:
cd backend
npm install
  1. Install frontend dependencies:
cd ../frontend
npm install
  1. Start the development servers:

Backend:

cd backend
npm run dev

Frontend:

cd frontend
npm run dev

Database Schema

Users Table

CREATE TABLE users (
  user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  username TEXT UNIQUE NOT NULL,
  email TEXT UNIQUE NOT NULL,
  display_name TEXT,
  role TEXT DEFAULT 'user',
  password_hash TEXT,
  auth_provider TEXT,
  last_login TIMESTAMP WITH TIME ZONE
);

Posts Table

CREATE TABLE post (
  postid UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  title TEXT NOT NULL,
  content TEXT NOT NULL,
  author TEXT NOT NULL,
  category TEXT NOT NULL,
  publicationdate DATE NOT NULL,
  tags TEXT[],
  slug TEXT UNIQUE NOT NULL,
  created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
  hasmap BOOLEAN DEFAULT false,
  visit_count INTEGER DEFAULT 0,
  mapcenter TEXT,
  zoom INTEGER
);

Comments Table

CREATE TABLE comment (
  comment_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  post_id UUID NOT NULL,
  user_id UUID NOT NULL,
  content TEXT NOT NULL,
  parent_comment_id UUID,
  image_url TEXT,
  likes INTEGER DEFAULT 0,
  dislikes INTEGER DEFAULT 0,
  created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
  is_approved BOOLEAN DEFAULT false,
  FOREIGN KEY (post_id) REFERENCES post(postid) ON DELETE CASCADE,
  FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE,
  FOREIGN KEY (parent_comment_id) REFERENCES comment(comment_id) ON DELETE CASCADE
);

API Endpoints

Authentication

  • POST /api/auth/google - Google OAuth login
  • GET /api/auth/google/callback - Google OAuth callback
  • GET /api/auth/me - Get current user info
  • POST /api/auth/logout - Logout user

Posts

  • GET /api/bloglist - Get paginated posts
  • GET /api/blog/:slug - Get single post
  • POST /api/posts - Create new post
  • DELETE /api/posts/:postId - Delete post
  • POST /api/posts/:postId/view - Increment view count

Comments

  • GET /api/comments/:postId - Get post comments
  • POST /api/comments - Create comment
  • DELETE /api/comments/:commentId - Delete comment
  • POST /api/comments/:commentId/like - Like comment
  • POST /api/comments/:commentId/dislike - Dislike comment

Contributing

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

License

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

Contact

For any questions or support, please contact:

About

Pattinam attempts to document Tamil Nādu cities through blogs, maps and data

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •  

Languages