A full-stack product filtering application built with Django (backend) and React.js (frontend). This application demonstrates how to implement filtering by multible categories, price range ,searching, and pagination functionality in a modern web application, making it easy for users to navigate and find products that match their criteria.
- Overview
- Features
- Tech Stack
- Installation
- Usage
- Project Structure
- API Endpoints
- Contributing
- License
This project combines the power of Django as a robust backend framework and React.js as a dynamic frontend library. It is designed to handle product data efficiently and provide an intuitive user interface for filtering, searching, and paginating through products based on various criteria.
- Advanced Filtering: Filter products by categories, price range, and more.
- Search Functionality: Full-text search to quickly find products.
- Pagination: Simple pagination to navigate through products, with customizable items per page.
- Responsive Design: The application is fully responsive and works seamlessly across devices.
- State Management: Zustand is used for state management in the React application.
- Data Fetching: Axios is used to interact with the backend API for fetching and manipulating product data.
- REST API: The backend exposes a well-structured REST API for handling product data, including pagination and custom filtering.
- Modular Code Structure: The project is organized to allow easy scalability and maintenance.
- Django: A high-level Python web framework that enables rapid development of secure and maintainable websites.
- Django REST Framework: A powerful toolkit for building Web APIs in Django.
- React.js: A JavaScript library for building user interfaces.
- Bootstrap: A popular CSS framework for building responsive and mobile-first websites.
- Zustand: A small, fast, and scalable state management solution for React.
- Axios: A promise-based HTTP client for making requests to the backend API.
- SQLite: A lightweight database used for development and testing (can be replaced with PostgreSQL/MySQL for production).
- Python 3.x
- Node.js & npm
- Git
-
Clone the repository:
git clone https://github.com/Mohamed-Taha-Essa/dj-react-product-filter.git cd dj-react-product-filter/backend
-
Create and activate a virtual environment:
python -m venv env source env/bin/activate # On Windows use `env\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Run migrations:
python manage.py migrate
-
Start the Django development server:
python manage.py runserver
-
Navigate to the frontend directory:
cd ../frontend
-
Install dependencies:
npm install
-
Start the React development server:
npm start
-
Access the application:
- Backend API:
http://localhost:8000/api/
- Frontend UI:
http://localhost:3000/
- Backend API:
-
Explore the filtering functionality:
- Use the search bar and filters on the frontend to find products that meet your criteria.
- Use the pagination controls to navigate through the product listings.
- Adjust the number of products displayed per page using the custom filter in the backend.
dj-react-product-filter/
│
├── backend/ # Django backend
│ ├── product_filter/ # Django project folder
│ ├── products/ # Products app
│ ├── db.sqlite3 # SQLite database (for development)
│ └── manage.py # Django management script
│
└── frontend/ # React frontend
├── public/ # Public assets
├── src/ # React source code
├── tailwind.config.js # Tailwind CSS configuration
└── package.json # Node.js dependencies and scripts
- GET /api/products/: Retrieve a list of products with filtering, searching, and pagination capabilities.
- Parameters:
page
: Specifies the page number (default: 1).page_size
: Specifies the number of products per page (default: 10, customizable via backend).
- Parameters:
- GET /api/products/:id/: Retrieve details of a specific product.
- POST /api/products/: Add a new product (requires authentication).
- PUT /api/products/:id/: Update a product (requires authentication).
- DELETE /api/products/:id/: Delete a product (requires authentication).
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.