The Pet Food E-Commerce Platform is an online store dedicated to providing food and accessories for pets. With a user-friendly interface and modern features, the platform offers a seamless, secure, and optimized shopping experience for pet lovers.
- VNPAY Payment Integration: Supports fast and secure payments via VNPAY, including QR code, bank cards, and e-wallets.
- Transaction Management: Comprehensive system to track purchase history and payment statuses for users.
- Category Optimization with Redis and Tree Pattern:
- Uses Redis to cache product categories, reducing database query times and improving performance.
- Implements a Tree Pattern for hierarchical category design (e.g., Dog Food → Dry Food → Brand X), enabling efficient category management and retrieval.
- Product Search and Filtering:
- Search products by keywords with fast and accurate results.
- Filter products by price range, category, brand, or other criteria.
- Cart Management: Allows users to add, remove, or update product quantities in the cart, with real-time total order value display.
- Responsive UI: Optimized for both desktop and mobile devices, ensuring a smooth shopping experience.
- Frontend: ReactJS, Tailwind CSS
- Backend: Node.js, Express.js
- Database: MongoDB (for storing products, transactions, and user data)
- Cache: Redis (for optimizing category queries and search)
- Search: Elasticsearch (for full-text search and advanced filtering)
- Payment: VNPAY API
- Authentication: JWT (JSON Web Token)
- Hosting: Vercel (frontend), Heroku (backend)
- Node.js (v16 or higher)
- MongoDB (local or MongoDB Atlas)
- Redis (local or Redis Cloud)
- Elasticsearch (optional, for advanced search capabilities)
- VNPAY Merchant account (for payment integration)
-
Clone the repository
git clone https://github.com/username/pet-food-ecommerce.git cd pet-food-ecommerce -
Install dependencies
- Frontend:
cd client npm install - Backend:
cd server npm install
- Frontend:
-
Configure environment variables
- Create a
.envfile in theserverdirectory with the following:MONGODB_URI=mongodb://localhost:27017/pet_food_ecommerce REDIS_URL=redis://localhost:6379 ELASTICSEARCH_URL=http://localhost:9200 VNPAY_TMN_CODE=your_vnpay_tmn_code VNPAY_HASH_SECRET=your_vnpay_hash_secret JWT_SECRET=your_jwt_secret - Create a
.envfile in theclientdirectory with:REACT_APP_API_URL=http://localhost:5000
- Create a
-
Start MongoDB and Redis
- Ensure MongoDB and Redis are running locally or use cloud services (MongoDB Atlas, Redis Cloud).
- (Optional) Set up and run Elasticsearch for advanced search functionality.
-
Configure VNPAY
- Register a VNPAY Merchant account to obtain
TMN_CODEandHASH_SECRET. - Update these credentials in the server’s
.envfile.
- Register a VNPAY Merchant account to obtain
-
Run the application
- Backend:
cd server npm start - Frontend:
cd client npm start
By default, the backend runs on
http://localhost:5000and the frontend onhttp://localhost:3000. - Backend:
-
Test the application
- Open a browser and navigate to
http://localhost:3000. - Register/login, add products to the cart, try searching/filtering products, and complete a payment via VNPAY.
- Open a browser and navigate to
-
Search and Filter Products:
- Use the search bar to find products by name or description.
- Apply filters for price range, category (e.g., cat food, accessories), or brand.
-
Manage Cart:
- Add products to the cart from the product list or detail page.
- Update quantities or remove items directly in the cart.
-
Pay with VNPAY:
- At checkout, select VNPAY as the payment method.
- Scan the QR code or enter card details to complete the transaction.
-
View Transactions:
- Access transaction history in the user account section.
- Check payment statuses (success, failed, or pending).
- Redis: Product categories are cached in Redis to minimize database queries.
- Tree Pattern: Categories are structured hierarchically, enabling fast retrieval of sub-categories.
- Elasticsearch: Enhances search and filtering with full-text search and complex query support.
- Ensure HTTPS is configured for production to support VNPAY and secure user data.
- Monitor Redis and Elasticsearch to maintain performance under high traffic.
- For production, register and verify an official VNPAY Merchant account.
- Commit all configuration files (except
.env) when pushing to GitHub.
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature. - Commit your changes:
git commit -m "Add your feature". - Push to the branch:
git push origin feature/your-feature. - Submit a Pull Request.
This project is licensed under the MIT License.






