How to store surplus from a belt?
When the belt is not completely full when in nominal production, you can connect a red or green wire from the inserter to a belt tile which comes after the inserter. Set the connected belt's setting to "read belt contents" and the content read mode from "pulse" to "hold". Have the inserter activate when the resource the belt is holding is > 6 (if both lanes hold the same item type) or > 3 (if you only have items on one lane). That count will only be reached if the belt is "backing up":
(belt goes north)
When the source of the items on the belt is so productive that the belt is always completely full even when it's moving at maximum speed (good job!), then use a belt of one tier higher for the measuring tile. If the whole belt is already the highest tier you can currently build (great job!!), you can use a splitter to split it into two, place the measuring tile on one of the two branches, and rejoin them with a second splitter:
What I typically do is have an inserter(s) which moves items from the belt to a chest, then another inserter(s) which moves items back from the chest to the belt.
You will need to wrap the belt around the chest, or use multiple chests, in order to get this to work.
It works much better if you have a mod that adds bigger (in area) chests. Warehouses are 6x6. It's also trivial with diagonal inserters.
Keep in mind you don't want to do this for every production line. Creating too many of an item that won't be a bottleneck is just a waste of resources.
If what you want is for the excess resources to be put back on the belt when things are low (as opposed to storing them for another purpose), then you don't need any kind of decision mechanism — just have one inserter moving items from the belt to the chest and another moving items from the chest to the belt, and the chest will naturally empty/fill as needed. This is commonly called a buffer chest.
Here's a fancy buffer chest design I just threw together:
Simple buffer setups don't let items bypass the chests; here they can, so you aren't limited in throughput by how many items the inserters can handle (though the left side will steal some items when its chest isn't full and the belt is). The belt arrangement at the bottom sideloads items from the chest so that the main path gets priority (not emptying the chest unnecessarily).