Let’s start with the basics. The major factors in causing spoiled food are heat, excessive cold, air, light, moisture, smells, and pests. Keep in mind what the environment of the area you’re storing food is, and make adjustments accordingly.
Always follow the first in, first out rule. Anything new goes in the back, pushing older items forwards so you don't forget to eat them before they go bad, and use the same principle for any leftovers. According to USDA guidelines, leftovers kept in the fridge can safely be eaten within three to four days while frozen leftovers are safe to eat for up to four months.
When you have lots of different perishable items like fruits and vegetables on hand and no plan for how to use them, it’s easy to let something go bad. Plan your meals for the week ahead of time, and find multiple uses for each ingredient so you don’t end up with a forgotten half an onion or five grapes slowly moldering.
This handy guide goes into far more detail on how to store specific foods and for how long: https://food.unl.edu/free-resource/food-storage/