Punchbowl-Weather displays the current weather using the free OpenWeather API. The user may choose from a list of preset locations.
The application uses a Ruby on Rails backend API located in the backend directory and a Next.js frontend located in
the frontend directory.
For this challenge, you will be extending the weather application by adding new models and API endpoints in the backend and updating the frontend to use those endpoints. Setup and challenge instructions (Step 0, Step 1, Step 2, Step 3, Step 4) are below. Please complete all steps.
This is not a timed exercise, but expect it to take 2-3 hours to complete. You are free to take as much or as little time as you would like. You will be graded on completing and returning the project by the deadline, completing the required steps, and the overall quality.
To return your code challenge:
- Remove the
node_modulesdirectories - Archive your project as
.zipor.tar.gzfile. - Email your archived project to your recruiting contact. You may need to upload your archive to a file sharing service like Dropbox or Google Drive.
This application requires:
- Ruby v3.1+
- Node v16+
- yarn (or npm)
See the Ruby on Rails Installation Guide for more information about installing Ruby.
The is a monorepo with the following directories:
backend– Rails 7.0 API applicationfrontend– Next.js v11 application (React, Typescript, and TailwindCSS)
Run the following steps in the backend directory.
bundle install
yarn installRun migrations to initialize the sqlite database.
bin/rails db:migrateValidate your installation by running the tests.
❯ bin/rake test
Running 6 tests in a single process (parallelization threshold is 50)
Run options: --seed 52093
# Running:
...S..
Finished in 1.020407s, 5.8800 runs/s, 9.8000 assertions/s.
6 runs, 10 assertions, 0 failures, 0 errors, 1 skips
You have skipped tests. Run with --verbose for details.Run the Rails server on port 3001 using following command.
❯ bin/rails server -p 3001
=> Booting Puma
=> Rails 7.0.4 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.5 (ruby 3.1.2-p20) ("Birdie's Version")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 84298
* Listening on http://127.0.0.1:3001
* Listening on http://[::1]:3001
Use Ctrl-C to stopRun the following steps in the frontend directory.
yarn installRun the development server on port 3000 using the following command.
yarn run devAt this point, you should be able to connect to the weather app at:
This monorepo is not currently a git repository. Set up a local git repository and track your changes in this challenge.
The locations data is static at Location::LOCATIONS. Update the Location model to read and write
data to the database. Add a rake task to insert the static data into the database.
Add an API endpoint to the backed to return the location data from the Location model. Make the
necessary changes in the model, controller, and tests.
Update the frontend to use the new Locations API.
- The sidebar should show all of the locations from the API

- The application should be able to show the current weather
for all locations.

Allow a user to mark a city as a favorite. Make the necessary changes or additions to models, controllers, and tests. The front-end for this feature is partially built with sections commented out. Update the front-end to display the favorites with a star in the sidebar and a button on the page to mark the currently selected location as a favorite.
For this step, don't worry about authentication. You can assume User.first is the current user. Focus on the
feature itself rather than prerequisites or boilerplate to support the feature in a real-world environment.
Suppose that our weather app is very popular with a large number of concurrent users and only a limited number of supported locations. The third-party OpenWeather API is rate-limiting us which is causing our API to throw errors. Can you create a solution in Rails or Next.js that will resolve the API rate-limit issues while also improving our app or API performance?