- node 4.2.* or above (Make sure that the nodejs binary is named node and not nodejs)
- npm 2.4.* (compatible to node version)
- Clone the project
- Change to the cloned directory
- Use
npm install
to build the project
- Open a seperate shell / Terminal and use
npm start
to start the server (make sure that the port 3000 is free) - Open a browser to access the GUI - http://localhost:3000
- Use the form in the browser to submit the csv data
This project is built using NodeJS / ExpresssJS with sqlite as the database. sqlite was chosen to keep the prerequisites and build instructions short
The focus was on relational data modelling. The expenses details are split among the three master / primary tables employee
, tax
and expense_category
and a derived / secondary table expense
which has references to the three master tables
employee
table holds the name
and address
of the employee. tax
table contains the tax_name
, tax_rate
, effective_from
and ended_on
fields. Since the tax rate changes over the period, there can be mulitple rates for a tax between effective_from
and ended_on
dates. Moreover it is assumed that the date on which the taxRate is different, the old tax rate ends. expense_category
contains the unique categories. For each of the expense line an entry is made in the expense
table which refers to the employee
, tax
, expense_category
table entries apart from storing the pre_tax_amount
and tax_amount
##Backend The source files are under the server/ directory. controllers/ holds the files that deals predominantly with the business logic of parsing the expense file and calling the appropriate tables to populate the data. However parsing the expensesData and extracting unique values spills over to the individual model files too (employee, expense_category, tax & expenses)
##Frontend Frontend is a rudimentary piece which just does the bare minimum that is needed. index.html is the home page and on processing the request the result.html is loaded. error.html is for error handling. There is no frontend javascript logic. The html files can be found under view/ directory while the css can be found under public/stylesheets
#Limitations / Assumptions
##Assumption
- As stated under the problem statement (about the input data)
- Header is the first line of the input
- No empty lines above or below or inbetween the csv data
##Limitations / Improvements
- The whole data is loaded on to the memory and it is not optimized for memory
- Basic sorting algorithm used
- Models have both the spill over of business logic (parsing expense data) and sqlite specific commands. Migrating to another db would need attention to the Model files
- Fancy front end
- Seperation of front end from back end
Tax_Amount
is stored in expense table even though it has a reference to tax table. This can be considered bending the relational design. However retrospective tax amendments are rare and hence for easy retrieval and calculation, the tax_amount is also included in the expense table- Add configuration files
- CI / CD
- Negative test cases
- Duplicate submission. At present if the data is submitted again the tables are populated again with the same data