The Delivery App Backend is a Node.js-based application designed to support online delivery shops (e.g., restaurants, fast food) in managing their menu, handling incoming orders, and supporting multiple currencies for item prices.
- Menu Management: Easily manage a menu with multiple categories and items.
- Currency Support: Support multiple currencies for item prices (on the menu) using external APIs.
- Order Handling: Handle incoming orders and provide order details.
- Merchant Dashboard: View incoming orders through a simple web page.
To meet the requirements of an online delivery shop, the backend includes the following features:
-
Menu Management:
- The application supports a menu with a minimum of 4 categories (e.g., Appetizers, Drinks, Main Dishes, Desserts).
- Each category includes at least 2 items.
-
Currency Support:
- Item prices are stored in Euro (EUR).
- The API is designed to support more currencies using publicly available APIs (using Fixer.io) for currency conversion.
-
Order Handling:
- Incoming orders are processed and managed within the system.
- Item availability and order validation are ensured.
-
Merchant Dashboard:
- A web page is provided for merchants to view incoming orders.
- Node.js and npm installed
- MongoDB database
- Access to a currency conversion API (e.g., Fixer.io)
-
Clone the repository:
git clone [https://github.com/nmermigas/delivery-app.git]
-
Navigate to the project directory:
cd delivery-app
-
Install dependencies:
npm install
To run this application locally, you'll need to set up the necessary environment variables in an .env
file that is already located in the server folder. Here's how to do it:
-
MONGO_URL: This variable should contain the MongoDB connection URL. You will need to set up a MongoDB database and obtain the connection URL.
Example
.env
file content:MONGO_URL=mongodb://username:password@localhost:27017/database_name
Replace username, password, localhost, 27017, and database_name with your actual MongoDB credentials that I have provided you with.
-
API_KEY: This variable should contain the API key required for currency conversion.
Example
.env
file content:API_KEY=your_api_key_here
Replace your_api_key_here with the actual API key provided to you.
To start the backend server, run the following command in the root directory:
npm run server
The backend API will be accessible at http://localhost:8000 by default.
/v1/menu
GET: Get the menu with all the items. So: http://localhost:8000/v1/menu It is suggested to hit this endpoint through an API Test/Dev tool like Postman.
POST: Add a new item to the menu. So : http://localhost:8000/v1/menu It is suggested to hit this endpoint through an API Test/Dev tool like Postman.
-
The acceptable categories are only: "Appetizers", "Drinks", "Main Dishes", "Desserts".
-
Example of a post request in JSON format:
{
"itemName": "Carbonara",
"category": "Main Dishes",
"description": "Italian Dish",
"price": 12.99,
}
/v1/orders
GET: Get a list of incoming orders in a webpage. So: http://localhost:8000/v1/orders
POST: Place a new order. So: http://localhost:8000/v1/orders It is suggested to hit this endpoint through an API Test/Dev tool like Postman.
- Example of a post request in JSON format:
{
"items": [
{
"itemName": "Pizza",
"quantity": 3
},
{
"itemName": "Caprese Salad",
"quantity": 1
},
{
"itemName": "Garlic Bread",
"quantity": 7
},
{
"itemName": "Soda",
"quantity": 3
}
]
}
To run the tests, run the following command in the root directory:
npm run test
This README provides an overview of the backend application, its features, requirements, and how to get started with it.