apps/www
directory.
useEffect
hooks for fetching data in client components. Fetching data for server components is straightforward in Next.js, but things get complicated in client-side components, where error handling can become tedious. Fortunately, the Vercel team provides a library called swr
, which takes care of these complexities for you.
The frontend client also integrates with Reddit, as I mentioned earlier, to help discover new songs in case the LLM kept recommending the same tracks in a loop. I built a custom music player using Redux in this frontend client, which manages all your playlists. Inspired by the BlackHole application, it allows you to favorite songs and store your listening history in the browser.
Session handling and authentication with Reddit are managed using NextAuth, and token refresh after a day is automatically handled by NextAuth as well.
worker
a lot. It’s the term Cloudflare uses for their serverless functions. Essentially, a worker is a serverless function deployed on their edge network.apps/fns/reddit
This was my first time creating an API service, so I made many mistakes. I am new to backend development. Initially, I tried creating different endpoints using Express and deployed them as separate servers. However, this was overkill since I was merely proxying requests from one service to another.
Then, I decided to try Hono. It also features OpenAPI specs, allowing me to follow Swagger standards for making requests directly from the browser instead of using Postman. Additionally, it made development easier by automatically generating documentation as I built the API. So, I switched to Hono. Setting it up was much easier compared to Express.
At first, I was unaware of PRAW, the Python client that manages Reddit OAuth endpoints. Because of this, I manually created the endpoints to interact with Reddit for fetching posts, comments, profile information, and communities.
apps/fns/ai
It primarily analyzes Reddit comments and generates search labels, which are then passed to the YouTube
worker to retrieve the video ID.
The AI worker uses Gemini in deployment mode, but you can also use other Ollama models like deepseek
locally during development. You just need to make some minor changes in the code.
apps/fns/yt
This worker retrieves the video ID from Google’s YouTube API. It’s pretty self-explanatory.