Alvin Novian
Back to index

nyaritempat.com

Background

Recently, me and 2 of my friends have the same itch of building something for fun, doesn’t matter the scale of the project, but we want it to be useful at least for ourself and personally I want it to be a place where I learn or experiment something new as well

We live in a little town in the West Java of Indonesia called Purwakarta, two of us is working fully remotely and the other is working hybrid (half remote, half on-site)

One of the problem that we all feel is that sometimes working remotely from home is a bit boring, but finding a good place to Work From Cafe (WFC) is quite a hassle too, because there’s certain criterias for a cafe in order for us to be comfortable working in there for a full day (e.g. good availability of electricity contact, good wifi) and sometimes it’s a bit hard to find that kind of information via google maps

Thus we create nyaritempat.com, a simple site to find, share and review cafes that is suitable for WFC

How nyaritempat.com works?

It’s pretty simple, anyone (user or guest) can submit a new cafe in any location or edit existing cafe on that site, but currently it still require admin approval, and all contributor’s name will always be shown, you can contribute with a user account or with a guest account

Anyone could search a place based on the location or based on the occasion they want to do, although currently it’s only focused for one occasion: WFC. In the future, we want to cover any other common occasion too (e.g. for hangout, for event, family dinner, etc)

That’s it, very simple

Development

We’ve started it by exploring the design first, we aimed for minimal clean design, because we want to keep the code to be small and simple

That’s also how we choose the tech stack for this fun project, we want it to be easy to deploy, small, cheap and fast enough

Deployment

I manage the deployment flow and try to self-host everything, we use cloudflare’s zero trust tunnel to connect a computer at home and serve all the website from that computer, so we don’t need to pay for a VPS / Hosting / Compute service

I made a simple fastify server to handle incoming webhook from GitHub which will trigger a simple bash file that will act as a simple CI (clone, build and test), we made staging environment for testing as well, we choose SQLite for the database to make it easy to manage and deploy and easy to make multiple instance of deployment as we don’t expect the application to have complex table relation or big data either

But I’m really curious about the possibility to achieve high-availability with this self-host setup, because the electricity in my home is not really stable and blackout is quite frequent (compared to AWS server 😅)

I think it would be cool if I can spawn multiple devices (such as a phone or a laptop, which can run on a battery) as the backup server, but that would mean I need to be able to distribute SQLite as well (I found LiteFS to be an interesting project) or probably just simply migrate to PostgreSQL to achieve high-availability, but the latter is less cool and less exciting

Frontend

We use preact, because it has roughly the same API as react but much smaller bundle size and faster render performance. We use wouter to handle FE routing because it has roughly the same API as react-router but much smaller bundle size and good enough for this use case

We use react-query for easy async state management and for the UI we choose to use tailwind and radix-ui because it’s easier and faster to develop for us

And we use vitest & react testing library for unit-testing

Backend

We choose to use fastify because we feel it’s fast enough and we want to stick to use typescript for both FE & BE, and prisma to manage the SQL migration and maintain DB type structure for ease of development & documentation

We use sharp to handle image processing, nodemailer & gmail to send email because gmail is free and we think the limitation is sufficient for this little project, we also use vitest for unit-testing

Code Management

At first, we opted to leverage npm workspaces to manage all those code so it’s easier to clone & deploy, so it’s structured to be something like:

workspaces
├── api
├── architectural-decision-records
├── github-webhooks
└── web

However, we later adjusted it to be a simple monolith when we were trying to support SSR (Server-Side Rendering) but keeping the folder structure separated, we build the SSR solution ourself, we don’t use existing framework like Nextjs, Remix or something alike. We did this just because it’s fun to learn how modern front-end SSR works under the hood, and to avoid the unnecessary complexity and bloat often introduced by the framework

And the architectural-decision-records (ADR) folder is just a bunch of markdown files to record our detailed reasons & considerations of all the tech stack that we choose, it’s just for fun and we’re learning to use it properly. I was inspired by how Oxide Computer use RFD to document all of their ADRs and discussion, and I think it’s really useful especially if you work on a bigger project or building a long-term product

Map

In this project I also learned how to build a Slippy Map to make the Map Viewer, previously I always use Leaflet.js for this kind of thing, but then when I checked the build size, Leaflet was adding about 134 KB to the compiled output, which is huge

Since our goal is to make the codebase as small as possible thus I try to build my own version of Slippy Map and I learned a lot of thing about it and ended up making a Map.tsx component which cover all of our need for the map (simply just viewing map with a simple marker) and the size is only 14.26 KB which is more smaller than Leaflet (89% reduction), and the gzipped size is only 5.37 KB, so it’s a huge win!

Build size comparison

Future Development

I’m really happy doing this project, even though the website is kinda simple but there are a lot of learning opportunities and experimentation that we did here and it’s also a good excuse for us to just get together, hangout and just catch up with each other, at least that’s how I feel

So I will continue this fun project as a platform to just experiment some other things or just to explore the alternative and keeping a small, fast and great quality codebase!