Kaleo Rails Engineer Candidate Interview Project
Thanks for taking the time to complete this exercise. We're excited that you're considering joining our amazing team.
This Rails application is a basic skeleton of an app that serves an API about questions and answers. It already includes 4 basic models:
- Question
- Answer
- User
- Tenant
A Question can have one or more answers, and can be private. Every Answer belongs to one question. Each Question has an asker (User), and each Answer has a provider (User).
A Tenant is a consumer of the API you are going to write. A db/seeds.rb file is included to preload the database with test data when you setup the DB.
You need to accomplish the following tasks:
- Add a RESTful, read-only API to allow consumers to retrieve Questions and Answers as JSON. The response should nest Answers inside their Question and include the id and name of the Question asker and Answer provider.
- Don't return private Answers in the API response.
- Require every API request to include a valid Tenant API key, and return an HTTP code of your choice if the request does not include a valid key.
- Track API request counts per Tenant.
- Add an HTML dashboard page as the root URL that shows the total number of Users, Questions, and Answers in the system, as well as Tenant API request counts for all Tenants. Style it enough to not assault a viewer's sensibilities.
- Add tests around the code you write as you deem appropriate. Assume that the API cannot be changed once it's released and test accordingly.
- You are welcome to add any models or other code you think you need, as well as any gems.
Extra credit features you might consider:
- Allow adding a query parameter to the API request to select only Questions that contain the query term(s). Return an appropriate HTML status code if no results are found.
- Add a piece of middleware to throttle API requests on a per-Tenant basis. After the first 100 requests per day, throttle to 1 request per 10 seconds.
Project Setup
brew install redis
gem install foreman
bundle install
bundle exec rake db:setup
foreman start
These steps are for osx, you may need to change the .env variables if you already installed redis and changed the default configurations
Testing
redis-server
rake
You must have the redis server running the in background to test the throttler
Submitting your project
Provide us the URL to your Github fork and we'll clone it to evaluate it. Expect to discuss your design decisions during the interview.