Ahmedsaed / gdsc-cert

Certificate management web app. Create, Verify and Share Certificates.
https://gdsc-certificates.web.app/
MIT License
5 stars 1 forks source link

Update: Move image generation to the client side #3

Closed Ahmedsaed closed 6 months ago

Ahmedsaed commented 7 months ago

It took me quite a while to understand the logic behind the image generation in this project. I honestly don't know why did the original maintainer took that approach.

The original approach

  1. When an admin (GDSC Lead) creates a new certificate, certificate info is sent to the database
  2. A request is sent to a cloudflare (cf) worker
  3. The cf worker sends a request to the repository dispatch route
  4. which triggers the build and deploy workflow.
  5. The build process pulls all data from the Firebase database and generates the certificate images from them.
  6. The website code alongside the certificate images are all pushed to the deployment server

This explains why it's instructed in the website to wait for 2 minutes as this approach roughly takes about 2 minutes to complete. But I really doubt it surviving for a long time under heavy usage.

It's also worth noting that the original maintainer might have adapted a slightly different approach since there hasn't been any signs of dispatch triggered actions on their repository.

I am currently thinking of another approach which moves the image generation to the client side. Here is how it should work.

The new approach

  1. when an admin (GDSC Lead) creates a new certificate, certificate info is sent to the database.
  2. when a user opens the certificate link, the data for this certificate is pulled from the server.
  3. Then the image is generated on the client side and becomes available to download

I am not entirely sure if the new approach is applicable but if it's done then would wouldn't have to rely on cloudflare workers or GitHub actions. However, one downside of this approach is that URL preview won't work.