esp8266 disconnect

i’m not good at English so sorry

now i have some problem

i want to use one power DC12V to supply arduino nano and my Electric gun

something like this 12V->Electric gun ->relay---------------------------
->LM2575-5 ->arduino nano ->relay<-------
->AMS1117-3.3->esp8266

i use C# program socket connect with esp8266 and send data to nano to control relay

i have already in parallel Diode(1N4007) between Electric gun to offset back emf

it’s fine without Electric gun but when i connect it and will make wrong

hope someone can help me or give me some suggest

Thank first .Frank