Skip to content

Ahmadbakry11/github_api

Repository files navigation

Github Repos Search Engine

Here I am providing 4 points to make it easier for the reviewer.

  • The stack I am using
  • The solution appraoch
  • How to run the application
  • Pending stuff, which I couldn't acheive due to lack of time.But I planning to complete.

  1. Stack

    • I am using ruby and ruby on rails to architect the app.
    • I am using Ruby version 3.0.3
    • I using rails version 6.0.4 and ruby version
    • I am using postgresql database
    • I am using RSpec as a testing framework
  2. Solution approach

    • To deal with githubapi, I had two approches:

      1. To use Octokit github wrapper
      2. To talk directly to the github api and fetch required resourcses using one of the HTTP client service including Faraday
      3. For me, I found it more convenient and more flexible to talk directly to the github api instead of calling an api wrapper that calls the api itself.So, I decided to fetch resources from the search endpoint using Faraday HTTP client.And by the way, Octokit is built using Faraday.
      4. I create a class (PORO) called GithubApi which has only the responsibilty for talking to the github api.So, I am not calling the api directly, I am using like a gateway or a proxy for that.
      5. I created a tableless class (ReposSearch) or model to validate the search form and in case it is valid, the search param is sent to the repos controller index action.
      6. ReposController/index calls the GithubApi class with the given search term and it handles the request and get back the response.
      7. I am using Kaminari gem for paginating the response.
      8. The search result always return 1000 results as a maximum inclusing the pagination.So, I am displaying 100 pages as a maximum with 10 results per page.
      9. I think it was out of the task scope to filter the results using any other fileds like date, topics, etc.
      10. While testing the GithubApi class, I am testing against the actual response from the github api itself.
      11. In the ReposSearch table less class, I am testing against if the term is valid and consequently the ReposSearch is valid too or not.
      12. Github website does not make a validation for the search form or against requesting more resources than the limit.I mean here, it does not send back an error message to the persons who search for anything, just renders the home page with the search form and so I did.
      13. While testing the repos index spec, the response is always HTML and so I was testing against html unique response for each request.I find that bad, but I did not have enough time to find smarter solution.I always use rails as an api only for the backend and in case I am building the frontend I use react.It is so good to make request specs using rspec and test the frontend using a nice tool like Jest for example.
      14. Also, I find that it is not good not mocking and stubbing the external api response by using Webmock and vcr, but I did not have enough time to integrate them.
  3. How to run the app:

    • open your bash profile in case of mac or bashrc file in case of linux and try to configure those env variables for the mysql user, password and socket or you can do that from the terminal

      
      export PGU='your db user name'
      export PG_PASS='your db password'
      
    • put your ruby version by editing the .ruby_version file.

    •  cd /your/directory
      
    • bundle install
      
    • rails db:create
      rails db:migrate
      rails s
      
    • For testing, in the same directory, run

      rspec
      

      OR

      bundle exec rspec
      
  4. Pendin tasks

    • There is only one request spec, which I did not have time to complete. The repos_searches_spec post request

Thanks

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published