http://localhost/laravel/public/index.php/currencyExchangeRate
http://localhost/laravel/public/index.php/currencyexchange/trendsgraph
- Redis server needs to be running off localhost port 6379. (Queues in laravel use Redis)
- Node JS running a) cd to laravel\public\nodejs b) node nodejs
- Ensure the queue listener is running in the background. a) php artisan queue:listen or b) php artisan queue:work --daemon --sleep=3 --tries=3
Running the queue listen command is CPU intesive so its recommended that you use a daemon.(View laravel 5 documents: http://laravel.com/docs/5.0/queues). Setting up allowed attempts is also recommended.
I used Laravel 5 as the framework. This is my first encounter with the Laravel 5 framework. I usually use Zend Framework 2.
For this to be a real-time application I used 4 technologies. Redis, Nodejs, Chartjs, socketio which was the first time as well that I've dealt with all these technologies.
The areas covered in this application are:
- Receive the Json request.
- Ensure the request is correctly formatted.
- Ensure the same IP address hasnt made over X amount of requests within the hour(RateLimiter).
- Validate the request ensuring the data is correct data type.
- Once valid, the data is pushed to the queue(Redis)
- Once pushed to the queue it is then forwarded onto the handler to process the request.(Note 9 in a particular currency is considered a low Purchase)
- The request is then passed to a facade which passes the data to a currency exchange helper to determine any trends.(As I didnt have time the algorithm is atrociously basic here)
- The data is then passed to the facade again and formatted for the graph(Time-restraint meant that I just pass the array back)
- Once the above steps are performed then the app publish's the trends so that it can be used in the template to update the graph.(Time-restraint, ideally I wanted to move this to an event class)
- Socket.io Nodejs and Graphjs then work together to listen for a publish, when this happens an event occurrs and the updates the graph to display the data.(graph.js file needs a good bit of work to it. socket.io all the logic should be seperated out into their won functions for clarity and functionality purposes)
Ideally if I had more time I would've improved the sections mentioned above. I've also left some TODO's in the code where I would've of altercations.
Also would've implemented PHPunit tests. Testing the app CPU performance and how it handles x amount of requests per minute. Also testing the core functionality. TDD all the way.