Freewheels and cassettes for your Bafang are the same as for a standand bike, and available where bike parts are sold. Here's the difference between cassette and freewheel.
Internal parts? If you know your motor model number, you can probably find a clutch/gear assembly for it online. I bought a spare set of gears ($19) with my 250W Bafang ($79) back in 2016. Anything else, you might as well buy a new motor.