Skip to content

This project was made for YOU, so you can rate how I code. It's a client-side application that queries the GitHub API with a little bit of NASA imagery sprinkled on top.

License

Notifications You must be signed in to change notification settings

GoldenMaximo/4-Code-Review

Repository files navigation

4-Code-Review (GitHub Repo Search App)

A client-side application that queries the GitHub API with a little bit of NASA imagery sprinkled on top.

DEMO:

Built with:

Installation

Make sure to have Git and Node.js 10.0.0 (or higher) installed.

  1. Clone it or fork it.

  2. Once you have your local copy, install its dependencies with a package manager (here we're going to be using npm):

npm install

Alternatevely you can use pnpm, the package manager used to create this project.

  1. (OPTIONAL) Get yourself a NASA API key or use my own (available upon request @ gfmaximo97@gmail.com).

  2. Create a .env file with the following properties:

NEXT_PUBLIC_GITHUB_SEARCH_ENDPOINT=* (E.g.: https://github.com/gitapi/search/)
NEXT_PUBLIC_NASA_PLANETARY_ENDPOINT=* (E.g: https://api.nasa.gov/planetary/)
NEXT_PUBLIC_NASA_APOD_KEY=*

The planetary endpoint could very well be fixed. However, setting all endpoints on .env is a project pattern I impose.

Running

After having installed the dependencies and having configured .env, you can then build the application with:

npm run build

Then after the build is done, start the application with:

npm run start

This will start the server at localhost:3000

Testing

This project uses Cypress to automate end-to-end tests.

All the test cases were written and configured on cypress/integration.

Before testing, make sure that you have configured the cypress.json file with the following parameters:

  • port - Port where the application runs (default is 3000).
  • githubSearchEndpoint - GitHub's search API (E.g.: https://github.com/gitapi/search/).
  • nasaPlanetaryEndpoint - NASA's API with access to the APOD microservice (E.g: https://api.nasa.gov/planetary/)
  • (OPTIONAL) projectId - Id of the project for monitoring and integration with Cypress services, it's registered on my account (@ gfmaximo97@gmail.com), you can choose to leave it or delete it. Makes no difference.
    {
        "projectId": "p21ze9",
        "env": {
            "port": "3000",
            "githubSearchEndpoint": "https://github.com/gitapi/search/",
            "nasaPlanetaryEndpoint": "https://api.nasa.gov/planetary/"
        }
    }

Also, make sure that the port you have set on cypress.json matches the ports set on the package.json scripts and that you have previously set the NEXT_PUBLIC_NASA_APOD_KEY property on .env.

After having configured everything, you can run the tests with:

npm run e2e

or if you want to run it solely on the console:

npm run e2e:headless

Performance

Performance metrics were measured with the help of DevTools Lighthouse & Vercel Analytics.

Overall Lighthouse score of the / page:

Overall Lighthouse score of the /search page:

Detailed performance snapshot of the entire flow of the app:

Vercel desktop performance analytics:

Mobile performance analytics:

Performance by page:

These are small samples collected with a very limited number of devices, the real performance scores may differ for better or for worse.

Mobile & PWA

This project supports PWA:

Mobile responsiveness:

CI/CD

CI

Continuous Integration is done using GitHub Actions together with Cypress, you can check out the project's runs @ its Cypress Dashboard.

CD

Continuous Delivery is done using Vercel for GitHub.

Security

Project security oversight is done by Snyk. Good doggo, barks whenever there's a security issue and bites the hell out of vulnerabilities.

As of right now there is only one known vulnerability in the project caused by next-pwa, Snyk does not have a fix for it yet. So if you want to hack the project, I just gave you a clue...

Known issues

Things to keep in mind for further development

  • Pages must have .page.tsx exention.
  • Do not create ./components level components unless you plan to use them in more than one page or component.
  • Texts are stored in texts object variables with alphabet letters as key and text as value, it sucks but I haven't found anything better yet. Alternative pattern suggestions are welcome.
  • As mentioned previously above, all endpoints must be declared on the .env file.
  • Testing could be better, the project lacks unit testing and has extremely limited coverage of edge cases by the current integration/e2e testing done with Cypress.
  • Commits must be done following Conventional Commits.
  • If more than one person ever works in this project, ideally I would prefer that all GIT management be done following Trunk-based development.
  • Cypress CI queries for a package-lock.json that matches the project's package.json during the CI build phase. Meaning that, while you could use pnpm and yarn to manage dependencies, you'll always have to make sure that the project's package-lock.json is up to date. It's a hassle to the point it made me abandon pnpm/yarn and just use npm instead.
  • There should be a skeleton of the layout during loading and page transitions. Or at least a loading spinner on all loading items.

Things to keep in mind for auditing

  • Brave Browser and other privacy-oriented browsers will block stuff from NASA's embedded videos, filling up the console with "blocked by client" errors.
  • Chromium-based browsers with autofill enabled will warn about "Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform". I haven't found which package causes this.

Useful links that weighed heavily on key technical decisions / Project direction & patterns.

About

This project was made for YOU, so you can rate how I code. It's a client-side application that queries the GitHub API with a little bit of NASA imagery sprinkled on top.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published