Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: render save service keys on web app ui #135

Conversation

Sayvai
Copy link
Contributor

@Sayvai Sayvai commented Sep 5, 2023

Render and Save Third Party Service Keys (API Keys and URL) on Web App UI

Description

There is a requirement to allow users to securely enter and save third-party service keys (and URLs) to be able to work with the overall app (once the backend scripts are later to be completed).

Implemented new feature to allow users to view the required configurable service keys (and urls) to set, on the web app UI.

The configurable required service keys data is dynamically derived from the backend master YAML config file (located in /scripts/similarity/config.yml), and its actual pre-saved secret key values derived from a localised programatically created git-ignored YAML secrets config file (located in /scripts/similarity/config.local.yml).

Whenever a key is no longer required by the app, then it is safe to remove key from the master config file, and in turn this key and any pre-saved secret value will no longer render on the web UI.

If a secret has yet to be set for any of the required keys, then the value will fallback to the default placeholder value defined in the master YAML config.

Related Issue

N/A

Type

  • Bug Fix
  • Feature Enhancement
  • Documentation Update
  • Code Refactoring
  • Other (please specify):

Proposed Changes

  • Add an additional UI section at top of UI page to allow users to view saved service keys data, and also allow them to update those keys.
  • Add new backend FastAPI endpoint (GET /api/service-keys/) to dynamically retrieve required service keys, as derived from the master YAML config file /scripts/similarity/config.yml, and replace placeholder service key values with actual secrets from localised git-ignored secrets YAML config file /scripts/similarity/config.local.yml.
  • Add new backend FastAPI endpoint (PUT /api/service-keys/) to dynamically update the service keys with new values, which writes to the new secrets to the localised git-ignored secrets YAML config file /scripts/similarity/config.local.yml.
  • Add wildcard *.local.yml to .gitignore file to ignore programmatically created YAML file which will pre-save the secrets.
  • Updated webapp/README.md with update to supported and tested Python version (3.11.5).
  • Updated package.json file by replacing pip3 and python3 with pip and python commands respectively.
  • Refactored web app UI React components.
  • Created a new frontend utils script file environment.ts to handle retrieving frontend environment and host URL information.
  • Created new types file service-keys.ts to add frontend typings for the third-party service keys.

Screenshots / Code Snippets (if applicable)

Annotated GIF demo of the new feature, showcasing the third-party service keys UI and backend secrets yaml config being created, and holding the secrets, while the master YAML config is safely left untouched.

Resume-Matcher-Web-App-UI-Feature-Add-Service-Keys-2

How to Test

  1. Run the web app (follow instructions from webapp/README.md), and wait for the frontend and backend servers to completely load
  2. Open http://localhost:3000/ in a new browser tab
  3. Replace the existing placeholder service key values from the top of the web app UI page with your own, or any other example values (see example GIF attached to this Pull Request above)

Checklist

  • The code compiles successfully without any errors or warnings
  • The changes have been tested and verified
  • The documentation has been updated (if applicable)
  • The changes follow the project's coding guidelines and best practices
  • The commit messages are descriptive and follow the project's guidelines
  • All tests (if applicable) pass successfully - N/A
  • This pull request has been linked to the related issue (if applicable) - N/A

Additional Information

⚠️ Because the actual secrets are programatically and safely saved to local file /scripts/similarity/config.local.yml, then any pre-existing Python project scripts which referenced to /scripts/similarity/config.yml to previously retrieve hardcoded secrets, should be refactored to check for existence of saved user secrets from secrets YAML config file /scripts/similarity/config.local.yml to programmatically retrieve secrets from there instead, otherwise fallback to master YAML config file /scripts/similarity/config.yml.

Implemented new feature to allow users to view the required configurable service keys (and urls) to set, on the web app UI.

The configurable required service keys data is dynamically derived from the backend master YAML config file (located in `/scripts/similarity/config.yml`), and its actual pre-saved secret key values derived from a localised programatically created git-ignored YAML secrets config file (located in `/scripts/similarity/config.local.yml`).

Whenever a key is no longer required by the app, then it is safe to remove key from the master config file, and in turn this key and any pre-saved secret value will no longer render on the web UI.

If a secret has yet to be set for any of the required keys, then the value will fallback to the default placeholder value defined in the master YAML config.
Add error handling on the backend api for when `similarity/config.yaml` does not exist, to which it responds with a 404 not found response.

As a result, also added error handling on the frontend ui code to handle the above 404 backend api response edge case to not render the Service Keys ui section.
@Sayvai Sayvai force-pushed the resume-matcher-fullstack-webapp branch from 245333a to 0830d6b Compare September 9, 2023 20:07
Logically abstracted out and renamed `Hero` component to its own folder, and corrected / renamed component filename.
@Sayvai Sayvai force-pushed the resume-matcher-fullstack-webapp branch from d58ad84 to 8216e49 Compare September 10, 2023 10:52
Pulled a bugfix for `requirements.txt` file from upstream fork origin repo main branch, which broke the webapp backend server run.

Root cause was that the qdrant-client dependency was set with a specific version; `qdrant-client>=1.1.1`, but the upstream reversion fix; `qdrant-client` without explicitly specifying a version resolved the webapp backend server run issue.
@Sayvai Sayvai force-pushed the resume-matcher-fullstack-webapp branch from 8216e49 to 60b70b0 Compare September 10, 2023 10:54
@srbhr srbhr merged commit f01e30d into srbhr:resume-matcher-fullstack-webapp Sep 10, 2023
srbhr added a commit that referenced this pull request Sep 16, 2023
* feat: add full stack web app 

Adds in a nextjs and fastapi webapp (experimental)

* feat: render save service keys on web app ui (#135)

* feat: render save service keys on web app ui

Implemented new feature to allow users to view the required configurable service keys (and urls) to set, on the web app UI.

The configurable required service keys data is dynamically derived from the backend master YAML config file (located in `/scripts/similarity/config.yml`), and its actual pre-saved secret key values derived from a localised programatically created git-ignored YAML secrets config file (located in `/scripts/similarity/config.local.yml`).

Whenever a key is no longer required by the app, then it is safe to remove key from the master config file, and in turn this key and any pre-saved secret value will no longer render on the web UI.

If a secret has yet to be set for any of the required keys, then the value will fallback to the default placeholder value defined in the master YAML config.

* chore: update next.js version and dependencies

* chore: error handling for missing keys config file

Add error handling on the backend api for when `similarity/config.yaml` does not exist, to which it responds with a 404 not found response.

As a result, also added error handling on the frontend ui code to handle the above 404 backend api response edge case to not render the Service Keys ui section.

* chore: ui refactor resume.tsx to hero.tsx

Logically abstracted out and renamed `Hero` component to its own folder, and corrected / renamed component filename.

* chore: sync requirements.txt from upstream

Pulled a bugfix for `requirements.txt` file from upstream fork origin repo main branch, which broke the webapp backend server run.

Root cause was that the qdrant-client dependency was set with a specific version; `qdrant-client>=1.1.1`, but the upstream reversion fix; `qdrant-client` without explicitly specifying a version resolved the webapp backend server run issue.

* chore: add debug troubleshooting steps to webapp readme (#141)

This change is to add new sections labelled `Debugging` and `Troubleshooting` to the `webapp/README.md` file.

The debugging section guides users on how to run the FastAPI backend server in VS Codes' debug mode, along with running the frontend server in isolation.

The troubleshooting section currently highlights one potential common issue that users may encounter when only running the frontend server in isolation (e.g. `npm run next-dev`).

---------

Co-authored-by: Sayvai <sayvai@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants