NOTICE: if you have question of name on commits does not match, that's is because my Mac's ownername/username is 'qiuxin' - my wife's name, didn't notice until now :p
- Requirements:
- Node is installed
- You have local/remote MySQL server
-
How to use
- clone this repo:
https://github.com/xianliflc/software-developer-coding-challenge.git
- cd
path/to/software-developer-coding-challenge/
- run
npm install
- import schema and test data with
dump.sql
- update
config/config.js
with properhost, user, password
, for now only default port3306
is supported - run
node index.js
to start the server - For functions showcase, please
cd electron_app
and runnpm install
, and then runnpm start
, make sure main server of auction system is running, and it's trying to connect port http://localhost:8080/api which is auction server is listening.- click top-left menu to show all available users, the default user is
user 1
- click each car in the list, you can see three buttons
- All Bids: click get all bids on the selected car
- Winning Bid: click to get the winning bid on the selected car
- Add Bid: enter a number in the input field on the right of the button (no $, only integer or float), then click this button
- All response should be rendered in each car's section
- click top-left menu to show all available users, the default user is
- clone this repo:
-
Technology stack
- Node.js w/Express
- MySQL
- Electron w/MaterializeCSS and Jquery
-
Main Functions of an auction system:
- Record a user's bid: able to bid and get it recorded by
POST api/bids/:car_id
- Get winning bid on a certain car:
GET api/bids/:car_id/winner
- Get bids history on a certain car
GET api/bids/:car_id
- Record a user's bid: able to bid and get it recorded by
-
API:
add bid Request:
- car_id (required) must be positive integer
- bidding_value (required) must be positive number >=1
- user_id (required) must be positive integer
POST /api/bids/3 HTTP/1.1 Host: localhost:8080 Content-Type: application/json { "user_id" : 4, "bidding_value" : "13.33" }
Response:
{ "success": true, "data": { "message": "success" } }
get the winning bid on a certain car Request
- car_id (required) must be positive integer
GET /api/bids/1/winner HTTP/1.1 Host: localhost:8080
Response
{ "success": true, "data": { "car_id": 1, "winner": [ { "bidding_value": 13.33, "user_id": 3 } ] } }
get all bids on a certain car Request
- car_id (required) must be positive integer
GET /api/bids/1 HTTP/1.1 Host: localhost:8080
Response
{ "success": true, "data": { "car_id": 1, "bids": [ { "user_id": 1, "bidding_value": 10, "created_at": "2018-12-01T02:18:47.000Z" }, ... { "user_id": 12, "bidding_value": 13.33, "created_at": "2018-12-01T20:02:27.000Z" }, { "user_id": 3, "bidding_value": 13.33, "created_at": "2018-12-01T21:12:31.000Z" } ] } }
get all cars (only used for showcase)
GET /api/car HTTP/1.1 Host: localhost:8080
get all users (only used for showcase)
GET /api/user HTTP/1.1 Host: localhost:8080
-
TODO:
- add memcached as caching layer
- move data layer from containers to Dao or using ORM