/FoodOrder

This is a cross-platform mobile application for ordering food, built with React Native for the frontend and Node.js with Express.js for the backend. The application allows users to search for food items, filter them by name, price, and type, and view detailed information about each item.

Primary LanguageJavaScript

Food Order

This is a React Native application for ordering food, built with React Native for the frontend and Node.js with Express.js for the backend. The application allows users to search for food items, filter them by name, price, and type, and view detailed information about each item.

Technologies Used

React Native    React    Node.js    Express.js    MongoDB    Styled-Components    JavaScript

Project Structure

The project is organized into two main directories:

  • client/: Contains the React Native application code.
  • server/: Contains the Node.js server code and API endpoints.

Requirements

Setup

  1. Clone the repository: git clone https://github.com/rd273001/FoodOrder.git

  2. Navigate to the project directory: cd FoodOrder

  3. Install dependencies for both client and server:

  • Navigate to "client" directory: cd client and run npm install OR yarn install
  • Navigate to "server" directory: cd server and run npm install OR yarn install
  1. Create a .env file in the server directory and add your MongoDB Atlas connection string: MONGODB_URI=your_mongodb_atlas_connection_string(ex: mongodb+srv://<username>:<password>@cluster0.sbdsigv.mongodb.net/<database_name>?retryWrites=true&w=majority) PORT=3000

  2. Create a .env file in the client directory and add BASE_URL(or you can add it in contsants file in utils or commons folder if no secret variables) BASE_URL=http://192.168.29.129:3000/api/foods (http://your-ip:3000/api/foods)

  • For local URL: you can check it with ipconfig command and see the IPv4 Address under Wireless LAN adapter Wi-Fi (Note: localhost is not used)
  • For deployed URL: BASE_URL=http://deployed-url/api/foods
  1. Start the development server:
  • Navigate to server directory: cd server
  • run npm start or yarn start
  1. In a new terminal window, start the React Native development server:
  • Navigate to client directory: cd client
  • run npm start or yarn start
  1. Run the app on your preferred platform (Android or iOS): npx react-native run-android # For Android npx react-native run-ios # For iOS

Endpoints

The server exposes the following endpoints:

  • GET /: Retrieves a list of food items. Supports query parameters for filtering by name (?name=), price (?price=), and type (?type=).

  • POST /addfood: Adds a new food item to the database. Requires body as: { name: String, price: Number, type: String }