This project aims to provide a solution for scenarios that require a system to process price data and offer price recommendations.
The goal is to develop a pricing engine that determines the optimal price for our products. This engine should balance our profit needs with market competitiveness. We base our Cost of Goods Sold (COGS) data on supplier price lists and reverse bids, where suppliers submit multiple bids to secure contracts by offering the lowest possible prices. As the lead engineer, your task is to develop this pricing engine.
Product Price
= Purchase_Price + MarginPurchase Price
= Average product price from the supplier
- The
Price Engine
calculates the purchase price from Logistic data. - Determine the
minimum margin
,margin requested
,margin current price
, andmargin from historical data
. - Compare all margins and choose the highest one that is neither greater than the
product price requested
nor below theminimum margin
.
Ensure the following are installed on your machine before starting:
- Node.js
- npm (Node Package Manager)
- Docker
-
Clone this repository to your local machine.
-
Navigate to the project directory.
-
Install the dependencies by running the following command:
npm install
-
Double-click the
createImageMysql.bat
file to create an instance of MySQL on Docker. -
Execute the
ddl.sql
file to generate the data structure and dummy data into the database. -
Start the server by running the following command:
node app.js
-
Open your browser and visit
http://localhost:3000
to access the application. -
Generate a token using the endpoint
POST /login
with the included body:{ "username": "admin", "password": "admin" }
Remember to regenerate the token every hour.
-
If you make any code changes that affect the application, you must close and rerun the application:
node app.js
The project is organized as follows:
app.js
: Entry point of the application.models/
: Contains the data models for the application.managers/
: Contains the application logic.managers/PriceEngine.js
: The main object responsible for calculating and providing selling price recommendations.ddl.sql
: Script to create a table and insert dummy data into the database.createImageMysql.bat
: Script to run MySQL on Docker.PriceEngine.postman_collection.json
: Postman collection file to test the API. You can import it into the Postman application.
The following API endpoints are available:
-
GET /price-suggestion?id=[productId]&price=[price requested]
: Get a selling price recommendation from PriceEngine. -product id
: ID of Product Data -Price
: Product Price that the customer offers in RFQ -
POST /login
: Generate a token from username and password.body : { "username": "admin", "password": "admin" }
Contributions are welcome! If you have any suggestions or improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.