As mentioned, the barrel is at the heart of accuracy. Get a bad barrel, and all the tricks to the gun or the ammunition won't make it shoot any better. Also check the crown.
Next thing is to handload the ammunition for the gun. Ammunition development can be tedious, but is absolutely necessary if you want the optimal performance out of the gun.
Good trigger is next and accompanied by good sights.
There are a myriad of other things that can be done. Free floated barrel, reducing any play between the upper and lower receiver, sling,
Vigilantibus et non dormientibus jura subveniunt. Molon Labe!