A full-stack web application that scrapes product data from Flipkart and presents it through a modern, responsive web interface. Built with Python FastAPI backend and Next.js React frontend.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation
- Configuration
- Usage
- API Documentation
- Frontend Features
- Development
- Contributing
- License
- Automated Flipkart scraping with pagination support
- Real-time product data extraction (title, price, rating, specifications)
- Intelligent retry mechanisms for robust data collection
- Duplicate detection to prevent data redundancy
- Session management with cookie handling
- RESTful API built with FastAPI
- MySQL database integration with SQLAlchemy ORM
- Advanced search functionality with fuzzy matching
- Multiple filtering options (price, rating, category, brand)
- Statistical analytics and trending algorithms
- Comprehensive error handling and logging
- Modern React 18+ UI with Next.js 15
- Responsive design with Tailwind CSS
- Advanced product browsing with filters and search
- Interactive image galleries with navigation
- Shopping cart functionality with local storage
- Real-time data caching for optimal performance
- Python 3.8+ - Core language
- FastAPI - Modern web framework
- SQLAlchemy - Database ORM
- MySQL - Primary database
- BeautifulSoup4 - HTML parsing
- curl-cffi - HTTP requests with CF bypass
- Pydantic - Data validation
- Next.js 15 - React framework
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Styling framework
- Radix UI - Component primitives
- Framer Motion - Animations
- Axios - HTTP client
- Lucide React - Icon library
- ESLint - Code linting
- PostCSS - CSS processing
- Git - Version control
Flipkart/
βββ backend/ # Python FastAPI backend
β βββ alchemy/ # Database models and connections
β β βββ create_tables.py # Database schema setup
β β βββ database.py # Database connection and queries
β β βββ models.py # SQLAlchemy models
β β βββ schemas.py # Pydantic schemas
β βββ api/ # FastAPI application
β β βββ main.py # Application entry point
β β βββ routers/ # API route handlers
β βββ modules/ # Scraping modules
β β βββ flipkart/ # Flipkart-specific scraper
β βββ settings/ # Configuration files
β βββ utils/ # Utility functions
β βββ requirements.txt # Python dependencies
β
βββ frontend/ # Next.js React frontend
β βββ src/
β β βββ app/ # Next.js app directory
β β βββ api/ # API integration layer
β β βββ components/ # React components
β β β βββ ui/ # Reusable UI components
β β β βββ Storefront.tsx # Main product interface
β β βββ hooks/ # Custom React hooks
β β βββ lib/ # Utility functions
β βββ public/ # Static assets
β βββ package.json # Node.js dependencies
β βββ tailwind.config.js # Styling configuration
β
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
Follow these steps to get the project running on your local machine.
Ensure you have the following installed:
- Python 3.8+ - Download Python
- Node.js 18+ - Download Node.js
- MySQL 8.0+ - Download MySQL or XAMPP
- Git - Download Git
git clone https://github.com/zaidkx7/flipkart-scraper.git
cd flipkart-scraper-
Navigate to the backend directory:
cd backend -
Create and Activate Virtual Environment:
# Windows python -m venv venv venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a file named
.envin thebackendfolder and add your database credentials:# backend/.env MYSQL_HOST=localhost MYSQL_USER=root MYSQL_PASSWORD=your_password MYSQL_DB=flipkart
-
Database Setup: First, make sure your MySQL server is running and create the database:
-- Run this in your MySQL client CREATE DATABASE flipkart;
Then, create the tables:
# From the backend directory python alchemy/create_tables.py -
Start the Backend Server:
python -m uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload # or python api/main.pyServer will start at
http://localhost:8000.
-
Navigate to the frontend directory: Open a new terminal and run:
cd frontend -
Install Dependencies:
npm install # if this doesn't work try this npm install --force -
Configure Environment Variables: Create a file named
.env.localin thefrontendfolder:# frontend/.env.local NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
-
Start the Frontend Development Server:
npm run dev
The app will be available at
http://localhost:3000.
The API will be available at: http://localhost:8000
- API Documentation:
http://localhost:8000/docs - Alternative docs:
http://localhost:8000/redoc
cd backend
python modules/flipkart/main.py- Real-time search with debouncing
- Multi-criteria filtering (brand, price, rating, specs)
- Dynamic price range sliders with Indian currency formatting
- Category-based browsing
- Scrollable image carousel with left/right navigation
- Thumbnail gallery for quick image selection
- Keyboard navigation support (arrow keys)
- Image zoom and full-screen view
- Add/remove products with quantity management
- Persistent cart using localStorage
- Price calculations with tax and shipping
- Checkout flow with form validation
- Mobile-first approach with Tailwind CSS
- Adaptive layouts for all screen sizes
- Touch-friendly interactions
- Fast loading with optimized images
- Intelligent caching with 5-minute TTL
- Client-side data persistence
- Optimized API calls with fallback mechanisms
- Loading states and error boundaries
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing code style and formatting
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
This project is for educational purposes only. Please ensure you comply with:
- Flipkart's Terms of Service
- Robots.txt guidelines
- Rate limiting best practices
- Local laws and regulations
Always respect website policies and implement appropriate delays between requests.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Join our discussions in the repository
- FastAPI for the excellent Python web framework
- Next.js for the powerful React framework
- Tailwind CSS for the utility-first CSS framework
- Radix UI for accessible component primitives
- Flipkart for providing the data source
β Star this repository if you find it helpful!
Made with β€οΈ by Muhammad Zaid