Hey! Here I am, sorry for the delay luca! I look to discord and it lloks like that keeping a centralized database is the common choice with the help of the events. Just copy-paste from a reply of @theBusBoy#9837 on Discord:
Answering the “why” question of it writing to the db: In Flow’s resource paradigm, assets are stored within an individual’s storage. Let’s say I deploy a contract to make widgets, mint 100 of them, and then distribute them to users. I can’t just query the account that minted the 100 widgets to find the current whereabouts of them (without writing what I currently believe to be an anti-pattern that stores tokenID → userAddress on-chain in metadata).
So, we need to keep track of where these 100 widgets are and can’t make one query to track then currently, right? This is where cadence events come in. Every time a widget is transfered from account A to account B, an event is emitted that might say something like “token 12345 transferred to address B”. We get to define what data is passed in the event we’ve created, so we could also track from address etc.
These events are named, so that when we look at blocks we’re able to filter based on events that we want to know. The worker within api/src/workers exists to look for events of the desired type on every block and then to update the central database (postgres in the KittyItems example) with the information fired off from the saleoffer event.