Where and how?
Crafting and upgrading can be performed at vendors or through the crafting panel of Menu. You will need a Crafting Spec and necessary components to craft or upgrade an item.
Crafting Spec's color indicates the rarity of the item you are crafting. Common and Uncommon items can be crafted from the start of the game. To craft Rare items, you'll need the True Craftsman perk, for Epic items - the Grease Monkey perk, and for Legendary items the Edgerunner Artisan perk.
Components can be looted, bought from vendors or obtained by disassembling items of the corresponding rarity (e.g. Epic Components for disassembling Epic items).
Quality of crafted items
Stats and quality of the crafted items are determined by your Engineering Skill level.
Whenever you gain an Iconic item, you will automatically receive Crafting Specs of that same item for different rarities and improved stats.
Improve your weapon
You can increase your weapon's stats upgrading it with the help of components.
Check Database in-game to find out more!