Thanks for this detailed comment. I would like to add that I have seen solutions which facilitate this architecture, but still have your application be on the web. One example is postgREST which generates a REST api from your database. Using a separate schema and views you can tightly control what gets exposed and how, but all security and logic still only happens in the database. Do you have any opinions on similar solutions?