Purchase Data Analytics is a proof of concept application for demonstrating the reverse use of customer data. The application allow informants to import purchase data made available to customers by S Group, and grocery shopping receipts. The receipts complete otherwise sparse purchase data with nutritional details. Lastly, the data is visualized for the informant to evaluate its usefulness and meaningfulness.
Visualizations make use of AmCharts and hFigures.
The implementation uses SQLite database for simplicity and Clojure Luminus framework to
minimize the custom code base.
You will need Leiningen 2.0 or above installed.
Application demo with some sample data is available here. Feel free to play with it as much as you like.
First, create the database by runnning:
lein run migrate
To start a web server for the application, run:
lein run
or to run the application in a specific port:
lein run 8000
The application serves the following API calls (each call is provided with an example result):
- GET /api/purchases
get all the purchases of every user. - GET /api/purchases/<id>
get the purchases belonging to a particular user. - GET /api/purchases/<id>/totals
get the purchase totals of a particular user. - GET /api/purchases/<id>/date/<date>
get the purchases of specific date (date in format YYYY-MM-DD). - GET /api/purchases/<id>/top5
get the top purchases of a single user (sorted by costs). - GET /api/purchases/<id>/top5-count
get the top purchases of a single user (sorted by amounts). - GET /api/nutrition/<id>
get the nutrients from a particular user's purchases. - GET /api/nutrition/<id>/month
get the nutrients from a particular user's purchases, grouped by months. - GET /api/nutrition/<id>/week
get the nutrients from a particular user's purchases, grouped by weeks. - GET /api/nutrition/<id>/date/<month>/<nutrient>
get the top nutrients from a particular user's purchases, for a given month, and sorted by . - GET /api/nutrition/<id>/categories
get the nutrients from a particular user's purchases including all the purchases. - GET /api/nutrition/<id>/total
get a summary from a particular user's purchases including all the purchases.
Note: the repository does not contain file 'all_prods.json' which is necessary for recognizing receipts. Please [contact the author](mailto:petteri.ponsimaa@gmail.com) for instructions how to get it.
This project is licensed under MIT License.