Challenges

Repo for All the Assignments I have to submit for Internship Application !😅

View on GitHub

ProgrammingChallenge

This is to help us understand your programming style and expertise. Getting Started :

For this round, you have to write a simple API server, which fetches data from Github and serializes it in a certain format, and visualizes it in form of charts.

It involves a few steps:

  1. Creating a simple back-end API for which you need to make a REST API call to Github’s API service and fetch the data
  2. Creating a small front-end application on Django/FastAPI

Challenge Duration - 3 days

Backend API

You will need to write a simple API that returns the top 10 repositories of an organization in Github by stars.

API Details

We will send a POST request to your API at /repos with JSON payload containing Github organization name

For deepvue-tech, this will look like this:

{
  "org": "deepvue-tech"
}

and the API should return a response in the following format (JSON):

{
  "results": [
    { "name": "rick", "stars": 100 },
    { "name": "morty", "stars": 98 },
    { "name": "jerry", "stars": 2 }
  ]
}

Metrics

Response Time: Share your findings on response time and the code that you use for the same.

Front-End App

You will need to create a simple Django/FastAPI app with a single view /dashboard having two charts:

Extras

  1. It is okay to Google or Bing (if that’s your thing)
  2. Think through the edge cases, especially for organizations with a large number of repos
  3. Write good, useful docstrings and comments

Bonus

  1. Add interactivity in graphs/charts to analyze the data coming from APIs
  2. Deploy this as a microservice on a cloud and share the link Submission
  3. Once you are done, email us the solution and findings/notes/logs in a zip file titled -fullstack-intern-hiring-challenge.zip

Solution

Front-end

Dashboard

image

After Clicking One of the button, Corresponding form shows up for input image

After Clicking on Display Button - Form data is sent to JS where request is made and sent to Api Endpoint, Meanwhile Loading screen Comes up ! image

After Recieving Response from API endpoint, Data is send to Charts (using chartsjs lib), And then Chart is displayed into a <_canvas_> ![image](https://user-images.githubusercontent.com/72795959/188396835-8ee7c6b0-3d0a-4bcb-aea3-ce0d076eeb41.png)

Same Goes for Line Chart

image

As view was selected to daily, Therefore, x-axis conatins Dates i.e, 2022-09-03 ! (for Monthly It would be months i.e, 2022-09 and for yearly It would be 2022) image

Backend

REST API /repos

Getting Organization name and Number of Top Repositories to Display image

Getting Time Takken by One Request (ttbor), Calculating Number of pages (n) (due to pagination) to reach & Looping over pages to store values in result. image

Sorting Result according to number of Starts & Adding a Final list to send a response image

Adding result, time takken by 1 request by github, Time takken by all requests Github, Time takken to send my response (after sorting etc) image

REST API /«org»/«repo»/commits

Getting Values of since, until & view from payload, Where Getting value of org & repo from path parameter itself. image

Adding Header, Constructing url, Getting Time takken by one & all responses respectively(ttbor, ttbar) & Calculating Number of pages (n) (due to pagination) to reach & Looping over pages to store values in result. image

Looping over pages by creating new request until last page is reached & storing data of every request to result image

Adding Result to final (response to be send) with response times. image

Findings

API’s /repos: Response time Inscreases Exponentially according to the Organization (If organization have alot of repositories). Due to pagination complexity goes to O(n), Whereas it does not Depends on How many Top repositories you need, Because, It will still need to go through all the repositories.

Running locally:

Download docker-compose and Run:

docker-compose up

Note: This Assumes that you have docker installed into your system.

Verecel Deployment (Limited) : https://github-api-chart.vercel.app/

Note: it is Deployed on Free tire so it’s functionality is very limited (i.e, not request more than 10sec of reposonse time with will returned, it will throw an error of 404)