When making a jigsaw puzzle game, it was mostly about distance checking plus rotation checking. So, each piece would know who it’s neighbors were. Then, when I dropped a piece after dragging it, I would check the distance to it’s neighbors. If one was within range, you then need to check are they rotated the same direction, thus they would connect on those sides. If so, then snap them together on the correct side.
I also had code to handle if you dropped it close to multiple pieces (ie, one that connects on the top and one on the side). It looked like that link the person was doing something very similar.