top | item 34531239

(no title)

justsomeuser | 3 years ago

- Server: Node.js + SQLite

I know JS very well, so writing HTTP handlers is quite fast.

Node runs on V8, which is probably the fastest runtime for dynamic code.

SQLite makes development easier as it’s just a file, gives you ACID.

- Frontend: React/Mobx/Tailwind SPA hosted on firebase hosting.

I think the concept of JSX (write your HTML with JS) is good as it gives you a real language instead of a restricted templating DSL.

Tailwind for the fast iteration speed.

Firebase hosting for the simple CLI and fast CDN.

- OS and hosting: Docker running on Google Container Linux

Docker so that the OS level dependencies of my server are defined somewhere.

Container Linux as it auto updates and has all the GCP logging and monitoring built in.

GCP for the incremental disk snapshots for simple backup of the SQLite state.

If I had to scale the service I would add more CPU cores and faster disk. I would also move the parts that need scaling to Go/Rust, and design the code to make use of the cores.

A few principles I use when choosing tech:

- Avoid distributed state (network boundaries) when possible (SQLite instead of SQL server, function calls instead of micro services).

- Use tools for their primary purpose. No shoehorning. Issues arise when you try to use something for what it was not designed exactly for. If you have >3 tools in your stack that you are shoehorning, things are more likely to break in the future.

- Things should still work in 10 years with minimal updates. Lindy effect. Bet on older tools if possible as they are more likely to be around and maintained.

- Good enough vs optimal: stop trying to find the perfect tech. Web tech is sometimes messy and imperfect. Opinion over what is right changes.

discuss

order

unsupp0rted|3 years ago

> I think the concept of JSX (write your HTML with JS) is good as it gives you a real language instead of a restricted templating DSL.

I never got this reasoning. In Vue the idea is:

* Write html templates in HTML

* Call javascript from the template to do javascript things (i.e. computed properties and methods)

This has always made the most sense to me, conceptually.

Sure Vue gives you a DSL for looping template elements (v-for) or showing template elements (v-if), but almost all the typical javascript action happens inside typical javascript calls.

nojvek|3 years ago

JSX shines if you use TS. Mostly because tsx has excellent code completion, type checking and refactoring tools.

It eliminates entire classes of human errors.

ccorcos|3 years ago

I’m keen on this approach for my next project.

Can you share any Dockerfiles / scripts you use to get going with this?

justsomeuser|3 years ago

Sorry I do not, although I have been meaning to publish the "skeleton" template repo's I have locally.

There are two template repos I use: `web-ui` and `server`

The both have a `sh` dir with common commands in .sh files (watch tailwind, watch esbuild, browsersync to serve and live reload during dev).

You config Google Container Linux with a `cloud-config.yaml`, which can take a bit of time to tailor at first, but after that every project uses the same config with small changes. I use Caddy to terminate HTTPS (it will auto generate and renew certs).

If you have a contact I can message you when I put them on Github.

jcuenod|3 years ago

What do you use for auth?

justsomeuser|3 years ago

Just a normal create-user/login form. Or Firebase Auth if Google and other sign in's need to be supported.