DEV Community

Cole Rau
Cole Rau

Posted on • Edited on

1

Photo Rover - Flatiron School Final Project

App Overview

Home Page

Source Code

Photo Rover is a web app that uses NASA's Mars Rover Photos API to receive a daily-updating collection of photos from Mars. The photos are taken by NASA's Curiosity rover. A lot of photos feature Martian geology. The rover is also fond of selfies.

In Photo Rover, a user can view pictures of Mars by selecting a specific Earth date. If they like a photo, they can save it to their library. A link to their saved photo is persisted in a SQLite database.

The app uses a React/Redux frontend, Redux Thunk to send asynchronous API calls, and a Ruby on Rails JSON API backend to handle user accounts and their respective actions.

App Execution Flow (Initial Photo Retrieval)

  • In the React frontend, we start in index.js, where the Redux store is configured, and App.js is rendered.
  • In App.js, all the routes are set up with React Router. When App.js mounts, an action is dispatched to receive photos of Mars from yesterday. The action sends a GET request to NASA's database. The action uses fetch and waits for a resolved promise to send to the reducer.
  • The reducer takes the list of photo objects from the action and stores them in state. Each photo object has its own link to retrieve itself from the Internet.
  • App.js then receives the updated state that contains the photo objects. It renders PhotosList.js and sends it props containing the photo objects.
  • PhotosList.js receives the props and iterates through them, passing each photo object to the Photo.js component.
  • Photo.js takes the photo object it received from props and passes the image URL from the object to an HTML img element. This causes the photo to render on the web DOM.
  • The photo is rendered with a button that, upon being clicked by a logged-in user, will cause that photo to be associated with that user. The user can retrieve that photo by going to their Saved Photos library and clicking "Refresh Saved Photos".

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay