There is a frontend application, a backend server, a daemon service (for writing data to database) and a mysql database instance.
#1. A user uploads a CSV through web UI which makes an POST /upload
API call.
#2. POST /upload
saves uploaded file to a configured upload directory and returns HTTP 201 status code with a jobId on success.
#3. The file uploaded in the upload directory gets automatically picked up by a deamon service (which continuously watches the upload directory) for processing. The deamon process parses the file and writes to the mysql database. On successful file processing, the file is removed from the upload directory. However, if the error occur either on parsing or writing, the file is moved to another directory called error directory.
#4. Web app polls GET /upload
with jobId to get the status of the file processing. The status could be fail
, success
or in-progress
.
#5. GET /upload
endpoint returns in-progress
when file (related to jobId) is found under upload directory, fail
when file is found under error directory or success
when file is present neither in upload directory nor in error directory.
#6. Once the file processing is done successfully, the payroll report table is automatically reloaded with new data by fetching the latest contents from GET /report
.
First of all, make sure you have node and npm installed on your system. It can be installed by simply running following command on Mac terminal:
brew install node
To check whether you have got node and npm, run following commands:
node -v
npm -v
Refer. https://nodejs.org/en/download/package-manager/ for node installation instructions on other OS.
-
Go to
cd wave-payroll-frontend
. -
Install all dependencies of frontend application first. Run
npm i
. -
Start application
npm start
. -
Open http://localhost:3000/ on your browser.
-
Go to
cd wave-payroll-backend
. -
Install dependencies by running
npm i
. -
Update
config.json
and provideuploadDir
anderrorDir
paths. (create two empty directory and update paths) -
Start server.
Either
npm start
Or
pm2 start app.js
It is recommended to use pm2 to make sure our server remain alive forever.
To install pm2, run npm install pm2 -g
.
-
Go to
cd wave-payroll-backend
. -
Start service.
Either
node ./api/lib/save_to_db_deamon.js
Or
pm2 start ./api/lib/save_to_db_deamon.js
Note: The backend and daemon service combined logs can be viewed by running following command:
pm2 logs
MySql database instance is already up and running on AWS. No need to do any special setup there.
That's it! Start playing. Go to http://localhost:3000/.