It probably would take you years of work to make your desktop environment from scratch.
I assume you are still talking of some X11 based environment (but by the time you'll have something, Wayland might have replaced X11).
If you want to make an X11 based desktop, study carefully the various X11 related protocols. Then dive into conventions like EWMH.
It would be more reasonable, after having spent months to study the X11 protool and EWMH, to start from an existing free software desktop environment and adapt it to suite your needs. You'll need to understand the role of the window manager (try first to use -one at a time- several existing WMs, e.g. icewm, ratpoison, twm and existing desktops -xfce, lxde, ....- ....)
Be aware that there is a big lot of legacy in X11....
Did you consider installing some source based Linux distribution like gentoo? You'll get all the source code that you need!