Colour code changes the baseline number of bonus abilities the weapon has, whites have nothing, green 1, blue 1, purple 2 and orange 3. Purples and Oranges will also have a Synergy bonus. Greens, blues or white at my level are all the same stat wise. EGO rating and colour look to have a modifier that increases the number of slots the weapon starts with, but that's not conclusive. You can upgrade any weapon to the full four slots. It costs a fuckton of salvage to get the final unlock though, 12k salvage. Synergies are something I've yet to get to grips with as I haven't had the faction to buy one yet. But I would assume that a Synergy is created using the same type of mod in up to 4 slots on the weapon like a set bonus, so if the weapon itself has say Synergy: Veteran, with details for slot 1 and slot 2, then it'll activate once you've got 2 Veteran type mods in the weapon.
A few examples of how mod slots aren't and are affected by colour and EGO rating. I have a 254 legendary shotgun with 2 slots (nothing added). A 515 white pistol with 3 slots (nothing added). A 515 green pistol with 2 slots (nothing added). A 491 blue sniper with 3 slots (1 slot added).