There *are* open-source controller designs, like the VESC and derivatives, that will have schematics, code, etc. I don't have any direct links, but there's a few threads here on ES, if you search titles and/or first posts of threads for "open source".
Other sites also have open-source controllers, including the original VESC (vedder esc) site(s).
They won't be much like typical ebike controllers, but they'll show you what the circuits and software are like to make your own controller (presumably what you are wanting to do).