Skip to content

rudra2609-06/react-blog-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redux Blog Project

A modern, feature-rich blogging application built with React, Redux Toolkit, and Tailwind CSS. This project demonstrates best practices in state management, authentication, and responsive design for building scalable web applications.

� Live Demo

Check out the live application: https://react-blog-project-one.vercel.app

�🎯 Project Overview

Redux Blog Project is a full-featured blogging platform that allows users to create, read, update, and delete blog posts. The application features user authentication, real-time search functionality, and a beautiful, responsive UI built with modern web technologies.

✨ Features

  • User Authentication: Secure login and sign-up system with route protection
  • Blog Management: Create, read, update, and delete blog posts
  • Search Functionality: Real-time search to filter blogs by title or content
  • Like System: Users can like/unlike blog posts
  • Responsive Design: Mobile-friendly UI that works on all devices
  • State Management: Centralized state management with Redux Toolkit
  • API Integration: Asynchronous API calls using Axios and Redux Thunk
  • Animations: Smooth transitions and animations using Framer Motion
  • Modal Dialogs: Interactive modals for editing and viewing blog details

🏗️ Project Structure

redux-blog-project/
├── src/
│   ├── api/
│   │   └── apiInstance.js          # Axios instance for API calls
│   ├── assests/                    # Static assets (images, logos)
│   ├── components/
│   │   ├── Login.jsx               # Login form component
│   │   ├── SignUp.jsx              # Sign-up form component
│   │   ├── Navbar.jsx              # Navigation bar component
│   │   └── Modal.jsx               # Modal dialog component
│   ├── features/
│   │   ├── blogSlice.js            # Redux slice for blog state
│   │   └── userSlice.js            # Redux slice for user state
│   ├── hoc/
│   │   ├── UserAuth.jsx            # Protected route wrapper
│   │   └── PublicRoutes.jsx        # Public route wrapper
│   ├── pages/
│   │   ├── Home.jsx                # Blog listing page
│   │   └── AddBlog.jsx             # Create/edit blog page
│   ├── store/
│   │   └── store.js                # Redux store configuration
│   ├── App.jsx                     # Main app component
│   ├── App.css                     # App styles
│   ├── index.css                   # Global styles
│   └── main.jsx                    # Entry point
├── public/                         # Public assets
├── db.json                         # JSON server database
├── package.json                    # Project dependencies
├── vite.config.js                  # Vite configuration
├── eslint.config.js                # ESLint configuration
└── README.md                       # This file

🔧 Tech Stack

Frontend

  • React (v19.2.0) - UI library for building interactive interfaces
  • Redux Toolkit (v2.11.2) - State management library
  • React Redux (v9.2.0) - Official React bindings for Redux
  • React Router DOM (v7.12.0) - Client-side routing
  • Tailwind CSS (v4.1.18) - Utility-first CSS framework
  • Framer Motion (v12.27.0) - Animation library for React
  • Lucide React (v0.562.0) - Icon library

Development & Build

  • Vite (v7.2.4) - Fast build tool and dev server
  • Axios (v1.13.2) - HTTP client for API requests
  • ESLint (v9.39.1) - Code quality tool
  • json-server (v1.0.0-beta.3) - Mock REST API server

🚀 Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd redux-blog-project
  2. Install dependencies

    npm install
  3. Start the JSON server (in a separate terminal)

    npm run dev:server
    # or use json-server directly
    json-server --watch db.json --port 3000
  4. Start the development server

    npm run dev
  5. Open your browser Navigate to http://localhost:5173 (or the port shown in terminal)

📦 Available Scripts

  • npm run dev - Start the development server with hot module replacement
  • npm run build - Create an optimized production build
  • npm run lint - Run ESLint to check code quality
  • npm run preview - Preview the production build locally

🔐 Authentication Flow

The application implements a two-layer route protection system:

  • PublicRoutes: Redirects authenticated users away from login/signup pages
  • UserAuth: Protects private routes and redirects unauthenticated users to login
  • User credentials are stored in Redux state and localStorage for session persistence

🌐 API Integration

The application communicates with a JSON server API running on http://localhost:3000/:

Endpoints

  • GET /blogs - Fetch all blog posts
  • POST /blogs - Create a new blog post
  • PUT /blogs/:id - Update a blog post
  • DELETE /blogs/:id - Delete a blog post
  • GET /users - Fetch all users
  • POST /users - Register a new user

All API requests are handled through Axios with Redux Thunk for asynchronous operations.

🎨 UI Components

Key Components

  • Navbar - Navigation bar with user profile and logout functionality
  • Modal - Reusable dialog for editing blog details
  • Login/SignUp - Authentication forms with validation
  • Home - Blog feed with search and like functionality
  • AddBlog - Form for creating new blog posts

Styling

The project uses Tailwind CSS for styling with:

  • Responsive grid layouts
  • Flexbox utilities
  • Custom color schemes
  • Smooth animations via Framer Motion

🔄 State Management

Redux Toolkit manages application state with two main slices:

blogSlice.js

  • Manages blog posts (fetch, create, update, delete)
  • Handles search and filter operations
  • Manages like/unlike functionality
  • Includes loading states and error handling

userSlice.js

  • Manages user authentication state
  • Stores user profile information
  • Handles login/logout operations

🎬 Getting Started with Development

Creating a New Blog Post

  1. Navigate to the "Add Blog" page
  2. Fill in the blog title and content
  3. Submit the form - the blog will be added to the database and Redux store

Searching Blogs

  1. Use the search bar on the home page
  2. Type a keyword to filter blogs in real-time
  3. Click clear to reset the search

Editing a Blog

  1. Click the edit icon on a blog card
  2. Modal opens with editable content
  3. Update and save changes

Deleting a Blog

  1. Click the delete icon on a blog card
  2. Blog is removed from the database and state

📱 Responsive Design

The application is fully responsive with:

  • Mobile-first approach
  • Tailwind CSS breakpoints (sm, md, lg, xl)
  • Flexible layouts that adapt to different screen sizes
  • Touch-friendly interactive elements

🚨 Error Handling

The application includes comprehensive error handling:

  • API error messages displayed to users
  • Redux state for loading and error states
  • Try-catch blocks in async thunks
  • User-friendly error notifications

🔍 Code Quality

The project maintains code quality through:

  • ESLint configuration for consistent code style
  • Component-based architecture
  • Separation of concerns (components, pages, features, hoc)
  • Reusable utilities and custom hooks

🌟 Best Practices

  • Redux Toolkit for simplified state management
  • Async thunks for API operations
  • Higher-Order Components (HOC) for route protection
  • Component composition for reusability
  • Environment-based API configuration
  • Proper error handling and loading states

🐛 Troubleshooting

Port Already in Use

If port 5173 or 3000 is already in use, modify the vite config or specify a different port:

npm run dev -- --port 3001
json-server --watch db.json --port 3001

Hot Module Replacement (HMR) Not Working

Clear node_modules and reinstall dependencies:

rm -rf node_modules package-lock.json
npm install

API Connection Issues

Ensure the JSON server is running on http://localhost:3000/ before starting the development server.

📄 License

This project is open source and available under the MIT License.

🤝 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a pull request

📞 Support

We're here to help! If you have any questions, issues, or feedback about the Redux Blog Project, please reach out using any of the following methods:

Getting Help


Made with ❤️ using React and Redux Toolkit

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors