We have a "/stock" endpoint that returns current amounts of items.
Item amounts are already tracked if someone flattens all of the transactions for each item.
By "flatten" we mean, there might be a transaction that donates 3 bananas and 5 cans of beans. Then 2 cans and 1 banana were "purchased" or "thrown own". If you combine (+3 -1) bananas and (+5 -2) cans of beans, you'll get a current stock of 2 bananas and 3 cans of beans.
There is a suggestion to have a nightly job that handles this.
Please look into how to set that up, or come up with a model-based query that relies only on the transactions.