A neutron is composed of two down quarks (-1/3 each electric charge) and one upquark (+2/3 electrical charge). This gives it a total charge of 0.
By emitting a boson, a down quark can become an up quark. Then you have one down quark, two up quarks, and a proton with +1 electrical charge.
Meanwhile, the electrically charged boson itself decays into a negatively charged electron and an antielectron-neutrino.
So the end result is that the neutron turned into a proton, emitting an electron and an antielectron-neutrino in the process, but the intermediate steps are essential.
I have a Feynman diagram for the opposite process (I’m currently on vacation so I can’t redraw it), from an Quora answer I gave:
Just swap p with n, u with d, and replace with , with , and with (that is, replace the electron-neutrino with an antielectron-neutrino).