Could be literally almost anything. Without plugging it up and getting a code to check it will be difficult to locate.
If it only happens when your fan kicks on it's probably electrical. Check all your battery cables and fuses. If there is a short somewhere your ECU may be freaking out because power isn't supposed to be where power is.
If all of that checks out start checking a little deeper like spark plugs and wires. Something may just not be firing right at lower revs if things aren't happening right it may kill it, where are higher revs it may burn fast enough to keep running. Your fan uses more power, and if your car is stressed already that may be the last straw.
Honestly just check all of your basic components, filters, fuses, fluids, easy to get to stuff. If none of that works it could be anything in the wiring harness or insidey bits. If your fuel injectors aren't flowing right all of the other parts may just not have enough anything to go. Try some fuel injector cleaner, slick 50, seafoam, etc.
Your best bet may just to be to head to someone who can plug it up and see if any codes come up. Something like this could just be a loose spark plug or a huge problem. Without more information I have no idea. Usually if something gets past visible parts I head to my mechanic.