Hey, so from asking around I found out that it is possible to let my web application, which is hosted on the same server as the PostgreSQL database is on can be communicated with by using the /run/postgresql unix socket.
What I wonder is, how do I find this stuff out? I could not find anything on google about what path to use for the communication, all I found out is that I need a unix socket. So if I did not ask someone more experienced, I probably would have never figured it out.
Though, if you are familiar with the latest Filesystem Hierarchy Standard, you will note that /var/run is deprecated in favour of /run and it will redirect to that path on modern systems. And, in fact, Nixpkgs patches PostgreSQL to use the modern path directly.
Alternately, you could grep NixOS for examples. For example, knowing that database connection string is commonly called DSN, you could search for dsn.+postgres and it would give you two examples. There are more if you search just for postgres but you will need to wade through more noise. Of course, this requires some prerequisite knowledge as well.