hand sketched logo of electrons orbiting a nucleus

How to Make an App

Stuff you might need:

  • Database
  • Auth
  • Storage
  • Server

Database

This is where you store your data.

You can think of it as a bunch of spreadsheets. Each spreadsheet is called a "table". Each row in the spreadsheet is called a "record". Each column in the spreadsheet is called a "field".

At least thats when the database is a "relational" database. There are other types of databases, but we'll stick with relational for now.

Relational Databases

Relational databases are the most common type of database. They are called "relational" because they store data in a way that makes it easy to relate different pieces of data to each other.

For example, you might have a table of "users" and a table of "posts". Each post might have a "user_id" field that tells you which user wrote the post. This is called a "foreign key".

If you want to have a "many-to-many" relationship, you need a "join table". For example, if you have a table of "users" and a table of "groups", and you want to know which users are in which groups, you need a "join table" that has a "user_id" and a "group_id" field.

But you probably dont want to host your own database. You probably want to use a "database as a service" like:

ORM (Object-Relational Mapping)

An ORM is a library that helps you interact with your database. It lets you write code that looks like this:

const user = await prisma.user.findUnique({
  where: {
    id: 1,
  },
  include: {
    posts: true,
  },
});

Instead of code that looks like this:


SELECT * FROM users WHERE id = 1;

Popular ORMs:

GraphQL vs REST

graphql orm?

REST vs GraphQL

Local First

Remember jquery/backbone? You needed to imperatively make DOM updates. Toggling classes, adding/removing elements, etc. It was a decent amount of cruft for general apps. React etc changed this to declarative updates. You state what the DOM should look like and the library resolves the DOM for you.

What if you could do the same with REST apis? These are imperative database updates. You need to make the request, wait for the response, then update the local state. What if you could declaratively update the local state and the library resolves the database for you? This is possible with some local first databases.

And is not without downsides

  • RxDB - NoSQL, no free tier for React-Native
  • WatermelonDB - BYOB (bring your own backend)
  • Replicache - BYOB (bring your own backend)

Replicache

  • generous free tier
  • used by tldraw?
  • works with react-native

RxDB

TypeSafe APIs?

tRPC is a new way to build APIs. It's like GraphQL, but it's simpler and more powerful. zodios

Reading

Database Clients

realtime/streaming database

https://www.tinybird.co/

Auth

https://clerk.com/

References

🌱 Projects

Current things that bring me joy to work on