Backend calculations

I need to create a dynamic database, after complex backend calculations from a static database.
How should I implement to bubble?

Each User is connected to another user as a line. Each has a self scored points, and a team point.
teampoint = self point+ allmembers_blow point.
each user team point calculation starts from most bottom user, then his team point is added to 1 level above user team point.

bottom user4 self: 10, team:10+0=10
user3 self 50, team=50+10=60
user2 self:100, team =100+60=160
top user1 self:0, team= 160+0 =160

then, every 1min a dynamic tree is populated with a back-end code.
Every 1 min, Any user who has self >10 and teampoint>50 will get a badge.

Can I do this in Bubble?
Should I run this code in his browser with a click of button?

Or do I need an API to a separate backend application, lowcode or nocode? Then request results from Bubble to publish only?