Skip to content

vtri950/FoodFinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍽️ FoodFinder

A full-stack web application for comparing restaurant menu items and prices from Swiggy. Browse restaurants, filter by category, compare menu prices, and find the best deals.

✨ Features

  • Live Data Scraping: Fetch fresh restaurant data from Swiggy in real-time
  • Smart Caching: 6-hour cache with force refresh option
  • GPS Location Detection: Auto-detect your location or enter a pincode
  • Distance Filtering: Filter restaurants by distance from your location
  • Menu Price Comparison: Compare prices of similar items across restaurants
  • Hierarchical Categories: Browse by main categories and subcategories
  • Advanced Filtering: Filter by rating, price, vegetarian options
  • Responsive UI: Modern interface with real-time updates

🛠️ Tech Stack

Frontend

  • React.js - UI framework
  • Axios - HTTP client
  • CSS3 - Modern styling

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • Mongoose - MongoDB ODM
  • Axios - Swiggy API integration

Database

  • MongoDB - Document database with TTL indexes

📁 Project Structure

FoodFinder/
├── client/                 # React frontend
│   ├── src/
│   │   ├── components/
│   │   │   ├── Header.js
│   │   │   ├── NewFilterPanel.js
│   │   │   ├── MenuComparison.js
│   │   │   └── RestaurantList.js
│   │   ├── App.js
│   │   └── index.js
│   └── package.json
│
├── server/                 # Node.js backend
│   ├── config/
│   │   └── database.js     # MongoDB connection
│   ├── models/
│   │   ├── Restaurant.js   # Restaurant schema
│   │   └── ScrapeCache.js  # Cache schema with TTL
│   ├── routes/
│   │   ├── restaurants.js  # Query endpoints
│   │   └── scrape.js       # Scraping endpoints
│   ├── services/
│   │   └── swiggyService.js # Swiggy API integration
│   ├── utils/
│   │   ├── cuisineHelper.js
│   │   └── clearCache.js   # Cache management utility
│   ├── server.js           # Main entry point
│   └── package.json
│
└── README.md

🚀 Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (v4.4 or higher)
  • npm or yarn

Installation

  1. Clone the repository

    git clone <repository-url>
    cd FoodFinder
  2. Install Backend Dependencies

    cd server
    npm install
  3. Install Frontend Dependencies

    cd ../client
    npm install
  4. Configure Environment Variables

    Edit server/.env:

    PORT=5000
    MONGODB_URI=mongodb://localhost:27017/foodfinder
    NODE_ENV=development
  5. Start MongoDB

    # On Ubuntu/Linux:
    sudo systemctl start mongod
    
    # On macOS with Homebrew:
    brew services start mongodb-community
    
    # On Windows:
    # Start MongoDB service from Services panel

Running the Application

Terminal 1 - Backend:

cd server
npm run dev

Backend will run on http://localhost:5000

Terminal 2 - Frontend:

cd client
npm start

Frontend will run on http://localhost:3000

📖 API Documentation

Scraping Endpoints

POST /api/scrape

{
  "pincode": "560001",
  "includeNearby": true,
  "forceRefresh": false
}

GET /api/scrape/status Returns database statistics

Restaurant Endpoints

GET /api/restaurants

Query Parameters:

  • mainCategory - Main food category
  • subcategory - Subcategories (can be array)
  • minRating - Minimum rating (0-5)
  • maxPrice - Maximum price per person
  • isVeg - Vegetarian only (true/false)
  • search - Search query
  • userLat / userLng - GPS coordinates
  • maxDistance - Distance filter in km
  • sortBy - Sort field (rating/priceForTwo/distance)
  • sortOrder - asc/desc

GET /api/restaurants/menu-comparison Returns menu items with prices for comparison

GET /api/restaurants/meta/categories-with-menu Returns categories that have menu data

GET /api/restaurants/meta/available-subcategories/:category Returns available subcategories for a category

🎯 How It Works

  1. User enters pincode or uses GPS auto-detect
  2. Backend scrapes Swiggy's API for restaurant and menu data
  3. Data is cached for 6 hours (TTL index auto-expires old data)
  4. User filters by category, rating, price, distance, etc.
  5. Menu comparison shows price differences across restaurants

🔧 Cache Management

The app uses a 6-hour cache with MongoDB TTL indexes:

View cache status:

cd server
node utils/clearCache.js --status

Clear all cache:

node utils/clearCache.js --all

Clear specific pincode:

node utils/clearCache.js --pincode=560087

⚠️ Important Notes

Rate Limiting

  • Swiggy may block excessive requests
  • Use force refresh sparingly
  • 2-second delay between restaurant menu scrapes

Legal Compliance

  • This tool is for educational purposes
  • Review Swiggy's Terms of Service
  • Use scraped data responsibly

SSL Certificates

  • Corporate proxies may cause SSL errors
  • SSL verification is disabled for axios requests

🐛 Troubleshooting

Port 5000 already in use:

lsof -ti:5000 | xargs kill -9

MongoDB not running:

sudo systemctl start mongod
sudo systemctl status mongod

Cache not expiring:

  • TTL index is automatically configured
  • MongoDB checks every 60 seconds
  • Use clearCache.js utility for manual cleanup

📝 License

ISC

👨‍💻 Author

vtri950

Built with ❤️ using React, Node.js, and MongoDB


Happy Restaurant Hunting! 🍕🍔🍜

About

Restaurant menu price comparison app - Swiggy data scraper

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages