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.
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.
- Node.js (v14 or higher)
- React Native development environment (follow the official React Native setup guide)
- MongoDB Atlas account (for storing food data)
-
Clone the repository: git clone https://github.com/rd273001/FoodOrder.git
-
Navigate to the project directory: cd FoodOrder
-
Install dependencies for both client and server:
- Navigate to "client" directory:
cd client
and runnpm install
ORyarn install
- Navigate to "server" directory:
cd server
and runnpm install
ORyarn install
-
Create a
.env
file in theserver
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 -
Create a
.env
file in theclient
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
- Start the development server:
- Navigate to server directory: cd server
- run
npm start
oryarn start
- In a new terminal window, start the React Native development server:
- Navigate to client directory: cd client
- run
npm start
oryarn start
- Run the app on your preferred platform (Android or iOS): npx react-native run-android # For Android npx react-native run-ios # For iOS
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 }