Hacker News new | ask | show | jobs
by wonger_ 1157 days ago
Well done, very clean and functional. I'm really curious about the implementation, since I'm also working on a static web app. It's been hard to deal with browser APIs manually.

- Could you give a brief overview of how the project is built, or what libraries are used? I found two in the source, React and Workbox. I've never heard of Workbox before, and I'm still figuring out how service workers are used. But it seems like a big part of the source.

- What factors made you choose Google Drive for syncing? And was it easy to set up?

2 comments

Thank you for trying it and asking questions. Let me reply to them below.

> Could you give a brief overview of how the project is built, or what libraries are used? I found two in the source, React and Workbox. I've never heard of Workbox before, and I'm still figuring out how service workers are used. But it seems like a big part of the source.

For building, I used Next.js with static generation, not using Server-side rendering. But it's not an important part because it doesn't rely on Next.js features so much.

About Workbox, the app uses them with next-pwa (https://github.com/shadowwalker/next-pwa) for providing caching strategies and offline behavior as Progressive Web App. For example, the app registers several precached files via Workbox. Precached files are fetched and cached by the service worker and these caches can be used while offline. Also, Workbox can configure runtime caching strategies. You can see details in Workbox documentation (https://developer.chrome.com/docs/workbox/).

The app also uses the Service Worker to connect IndexedDB as a local database and send HTTP requests to synchronize data with Google Drive. By using the Service Worker, these methods don't block the user interaction from the main thread and Service Worker can run in the background to synchronize data even if the browser window is suddenly closed. So the Service Worker is used for not waiting for HTTP requests/responses and improving performance.

> What factors made you choose Google Drive for syncing? And was it easy to set up?

Using Google Drive as a database is not easy to implement, but I chose Google Drive in terms of data ownership. The users can delete the data by themselves if they want and the app can't connect users' data without receiving the HTTP request from the user. These points are good for privacy laws and reduce the security risk.

It also keeps infrastructural costs low. It's also an important factor in providing the application free of charge.

The bad point of Google Drive is high latency, but the latency issue wouldn't be a big problem because the HTTP requests/responses wouldn't block user interactions in this app.

Have you though of integrating it with self-hosted solutions like Nextcloud etc?
I haven't, because I also wanted to reduce the time to maintain infrastructures.