Skip to content

mufeed-dev/Redux-CRUD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ReduxTK Explore - User Management Demo

A comprehensive demonstration of Redux Toolkit capabilities in a modern React.js application. This project showcases state management, async operations, and best practices using a user management system.

๐ŸŽฏ Project Overview

ReduxTK Explore is an educational project designed to demonstrate the power and simplicity of Redux Toolkit for state management in React applications. It implements a complete CRUD system with real-world patterns and practices.

๐Ÿš€ Features

  • Complete CRUD Operations: Create, Read, Update, and Delete users
  • Real-time Search: Instant search functionality in navbar
  • Gender Filtering: Filter users by Male/Female/All
  • Responsive Design: Mobile-first Bootstrap styling
  • Modal Management: Beautiful user detail modals with avatars
  • Confirmation Dialogs: Safe delete operations with confirmation
  • Loading States: Visual feedback during API operations
  • Error Handling: Comprehensive error management

๐Ÿ› ๏ธ Tech Stack

Frontend & State Management

  • React 18 - Latest React features
  • Redux Toolkit - Modern Redux with less boilerplate
  • React-Redux - Official React bindings
  • React Router DOM - Client-side routing

UI & Styling

  • Bootstrap 5 - Responsive UI components
  • Custom CSS - Animated modals and custom components
  • Bootstrap Icons - Professional iconography

API & Data

  • MockAPI.io - Backend simulation
  • Fetch API - Modern HTTP requests
  • JSON Handling - Data serialization

๐Ÿ“ฆ Installation & Setup

  1. Clone and install dependencies

    git clone <repository-url>
    cd reduxtk-explore
    npm install
  2. Start the development server

    npm start
  3. Open your browser

    http://localhost:3000
    

๐Ÿ—๏ธ Project Structure

src/
โ”œโ”€โ”€ components/              # React Components
โ”‚   โ”œโ”€โ”€ Create.jsx          # User creation form
โ”‚   โ”œโ”€โ”€ Read.jsx            # Users list with search/filter
โ”‚   โ”œโ”€โ”€ Update.jsx          # User editing form
โ”‚   โ”œโ”€โ”€ Navbar.jsx          # Navigation with search
โ”‚   โ””โ”€โ”€ CustomModal.jsx     # User details modal
โ”œโ”€โ”€ features/               # Redux Toolkit Slices
โ”‚   โ””โ”€โ”€ userDetailSlice.js  # Complete user management slice
โ”œโ”€โ”€ App.js                  # Main application component
โ””โ”€โ”€ store.js               # Redux store configuration

๐Ÿ”ง Redux Toolkit Implementation

Store Configuration

// store.js
export const store = configureStore({
  reducer: {
    app: userDetail, // Feature-based slicing
  },
});

Async Thunks with Lifecycle Management

// Complete async operation handling
export const createUser = createAsyncThunk(
  "createUser",
  async (data, { rejectWithValue }) => {
    // API implementation with error handling
  }
);

// Lifecycle management in extraReducers
.addCase(createUser.pending, (state) => {
  state.loading = true;
})
.addCase(createUser.fulfilled, (state, action) => {
  state.loading = false;
  state.users.push(action.payload);
})

State Structure

{
  app: {
    users: [],        // Array of user objects
    loading: false,   // API call status
    error: null,      // Error messages
    searchData: ""    // Search query
  }
}

๐ŸŽจ Component Features

Create.jsx

  • Form for adding new users
  • Fields: Name, Email, Age, Gender
  • Form validation and submission

Read.jsx

  • Display all users in responsive cards
  • Real-time search and gender filtering
  • Delete with confirmation modal
  • View details in animated modal

Update.jsx

  • Pre-populated editing form
  • Controlled inputs with proper state management
  • Seamless data updates

CustomModal.jsx

  • Beautiful user profile display
  • First-letter avatar system
  • Smooth animations and transitions
  • Click-outside to close functionality

๐Ÿ”„ Data Flow Architecture

App.js (Data Fetching)
    โ†“
Redux Store (Single Source of Truth)
    โ†“
Components (Consume State)
    โ†“
User Actions (Dispatch Updates)
    โ†“
API Operations (Async Thunks)
    โ†“
State Updates (Immer-powered)

๐Ÿ“š Learning Objectives

Redux Toolkit Mastery

  • โœ… createSlice - Organized state management
  • โœ… createAsyncThunk - Async API operations
  • โœ… extraReducers - Async lifecycle handling
  • โœ… Immer Integration - Immutable updates made simple
  • โœ… Modern Hooks - useSelector and useDispatch

React-Redux Patterns

// Modern hooks pattern
const dispatch = useDispatch();
const { users, loading } = useSelector((state) => state.app);

// Dispatching async actions
dispatch(createUser(userData));

Real-world Implementation

  • Loading state management
  • Error handling strategies
  • Optimistic UI updates
  • Component-state communication

๐Ÿš€ Key Features Code

Search Implementation

// Real-time search in navbar
useEffect(() => {
  dispatch(searchUser(searchData));
}, [searchData, dispatch]);

User Filtering

// Combined search and gender filtering
users.filter((ele) => {
  if (searchData) {
    return ele.name.toLowerCase().includes(searchData.toLowerCase());
  }
  if (radioData && radioData !== "") {
    return ele.gender === radioData;
  }
  return ele;
});

Modal Management

// Click outside to close
<div className="modalBackground" onClick={() => setShowPopup(false)}>
  <div className="modalContainer" onClick={(e) => e.stopPropagation()}>
    {/* Modal content */}
  </div>
</div>

๐ŸŽฏ Educational Value

For Redux Beginners

  • Understand Redux fundamentals without boilerplate
  • Learn modern patterns (no more connect HOCs)
  • See real-world async operation handling

For Intermediate Developers

  • Advanced state structure design
  • Error handling strategies
  • Loading state management patterns
  • Component composition with Redux

Key Takeaways

  • Redux Toolkit reduces code by 60%+ vs traditional Redux
  • Immer makes immutable updates intuitive
  • createAsyncThunk simplifies API operations
  • Feature-based organization scales well

๐Ÿ”ฎ Next Steps

After mastering this project, explore:

  1. RTK Query - Data fetching and caching
  2. Redux Persist - State persistence
  3. Redux Toolkit with TypeScript - Type safety
  4. Redux Middleware - Custom functionality
  5. Performance Optimization - Memoized selectors

๐Ÿ“– Resources

๐Ÿค 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.


ReduxTK Explore serves as both a functional application and an educational resource for mastering modern Redux patterns with Redux Toolkit. Perfect for developers transitioning from traditional Redux or starting their state management journey!

Happy Coding! ๐Ÿš€

About

A complete React + Redux Toolkit demo showcasing modern state management with user CRUD operations, real-time search, filtering, and responsive UI.๐Ÿ“ˆ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors