←back to thread

WikiTok

(wikitok.vercel.app)
1459 points Group_B | 1 comments | | HN request time: 0s | source
Show context
aizk ◴[] No.42936923[source]
Hi! I'm the dev here! I built this on a whim at after seeing someone ask for it on twitter. It was 12:30 at night but I couldn't pass down the opportunity to build it.

The code is very simple, there's no backend at all actually, I believe because wikipedia's api is very permissive and you can just make the requests in the frontend. So you just simply request random articles, get some snippets, and the image attached!

I used Claude and cursor do 90% of the heavy lifting, so I am positive there's plenty of room for optimizations. But right now as it stands, it's quite fun to play with, even without anything very sophisticated.

Here is the source code. https://github.com/IsaacGemal/wikitok

replies(18): >>42936962 #>>42936974 #>>42937696 #>>42937871 #>>42937989 #>>42938002 #>>42938007 #>>42938164 #>>42938260 #>>42938330 #>>42939286 #>>42939520 #>>42940031 #>>42940626 #>>42942340 #>>42944933 #>>42945717 #>>42947803 #
tomashubelbauer ◴[] No.42938330[source]
Shoutout to APIs that do not enforce CORS preventing requests be made from FE without a need for a BE. There's so many toy apps I started building that would have just worked if this was more common, but they have CORS restrictions requiring me to spin up a BE which for many one-off tools and personal tools just isn't worth doing and maintaining. Same with OAuth.
replies(9): >>42938463 #>>42938484 #>>42938836 #>>42939162 #>>42939366 #>>42939679 #>>42939693 #>>42939990 #>>42944599 #
aizk ◴[] No.42938463[source]
The only caveat I feel is that the speed of the API is definitely not comparable to something more purpose built for this kind of scale, but overall I'm happy as it works well enough that I don't have to think about it too hard.
replies(2): >>42938559 #>>42949475 #
mikedelfino ◴[] No.42938559[source]
I think Github Actions could be used for scheduled builds, so that the initial load would have random articles right in. Further requests could then be made in advance so users would not notice any delay from the API.
replies(1): >>42939936 #
aizk ◴[] No.42939936[source]
Do you have any examples of that I can look at as a reference? I'm used to github actions just being my CI/CD build step checking tool.
replies(2): >>42942098 #>>42945694 #
1. mikedelfino ◴[] No.42945694{5}[source]
Edit to the other comment: the cron job wasn't being triggered at first, but turns out it's just slightly delayed. The example has been updated hourly since then.

You can use a schedule trigger [1] on GitHub Actions.

The whole gist is that the initial data can be injected into the static files during the build step, or even saved as separate JSON files that the app can load instead of reaching out to the API. As long as you're willing to refresh the static data from time to time, of course.

I created a basic example at https://schedbuild.pages.dev/ with a rough, manual implementation of a build step. Frameworks like Next.js offer a more sophisticated approach that can render the entire HTML, allowing users to load the static page with the initial data already rendered without Javascript, and subsequent interactions taking over from there more seamlessly.

In my opinion this is a reasonable alternative to setting up a backend just for this.

[1] https://docs.github.com/en/actions/writing-workflows/choosin...