I want to build a single-asset staking contract

I want to build a single-asset staking smart contract.

Users will be able to deposit a token, and get the same token back over time (as a way to distribute the supply to believers of the project)

I need some guidance on where to start. I can create a Smart contract into Which I can deposit, and unstake, but I dont know how to calculate the rewards over time, and distribute them automatically

This seems like a good starting tutorial: Creating a Inheritable Staking contract in Solidity | by Percy Bolmér | ITNEXT

You could also look at any DeFi project that uses staking for inspiration like PancakeSwap or OlympusDAO.