There are a number of ways of configuring connecting to a PostgreSQL database, as documented Database Connection Control Functions
Set process environment variables
and perhaps more.
Keyword/value Connection strings
URIs that look like URLs
Tools such as psql can accept the above, but also offer traditional Unix dash parameters to indicate overrides to what might be in the environment
The Java JDBC API uses connection strings very much like the above URIs
I have been migrating my thinking, over the last number of years, to use URIs wherever possible, as that provides a singular structure that tends to be able to passed easily as strings.
I have found one scenario that has been a "pain in the neck", namely when there was some confusion as to whether the database server supported hosts versus Unix Domain Sockets, and did a Blog Post: PostgreSQL URIs versus Unix Domain Sockets.