IF you are good with electronic and such then you could very well build your own gun.
WE M4 are you referring to the GBBR?
Generally most M4's are a "Version 2" gear box, so they all are more or less the same gear box shell, you can transfer it into different bodies. Think of the shell as the heart, where as the gun is the body.
Generally what the community recommends, is you buy a nice body, thus being VFC. King Arms are also decent on the exterior, and classified more as a "budget friendly" gun.
If you want to build your own gear box you can look up "Lonex Gear box shell V2," but then you'd need a donor body. You have many options, just depends on your wallet

.
Hard choice.. but buying new is generally the path I would go 99% of the time, then when something breaks, I take it apart, examine what broke, and then go from there to see what I should do.
I also no nothing about AEG's