Building GitHub Profile Analytics using React || PART 1

Dmitry Rastorguev
HackerNoon.com
4 min readFeb 12, 2018

--

This is a step by step article on how to build a basic analytics tool for GitHub profiles, using React. The emphasis was placed on achieving functionality quickly, therefore the end result does require further code refactoring and styling. The article is formed of two parts (Part 1, Part 2) and is based on the following GitHub repository. It is also hosted in this website. Please note that both the repository and the website will evolve beyond these two articles.

To begin load create-react-app (this is assuming npm and create react app are already installed)

create-react-app github_analytics

Once this has been completed , change directories withcd github_analytics and enter npm start to check that everything is working fine. You should see the following page in the browser.

Begin by deleting the following files: logo.svg, index.css, App.css. Change App.js name to App.jsx (don’t forget its imports in App.test.jsx and index.js). Also chance its content to the following:

Create sub-folder components in src. Here lets create our first component Button.jsx as follows:

Adjust App.jsx to the following:

This should result in The button was clicked! alert, when pressing on Search button.

Next we will need to run npm install axios -save. This installs axios, which allows to make HTTP requests. Once it has been installed, App.jsx will need to be changed to:

This results in data being automatically collected for my GitHub account.

Finally, we will replace Search button with a form to allow users to search GitHub by username. To do this, we first need to create Form.jsx component.

Similarly, App.jsx will need to be replaced as follows:

Your page should look some similar to a screenshot below.

We are now able to to request any data from GitHub API and display it on our webpage. Therefore, this concludes Part 1. In Part 2 we will add 3 different sections: basic information, list of most popular and starred repos and, finally, analyse most common languages of user’s own repos and generate keywords to starred repos.

Feel free to track the progress of this project on GitHub and on its website.

--

--