Check out used tiny/mini/micro desktops on eBay. Loads of info here: https://www.servethehome.com/introducing-project-tinyminimicro-home-lab-revolution/
Only downside is going to be no GPU for the AI workload. Maybe some of the later AMD APUs could cut it. If not, all three major manufacturers have SFF variants that are pretty much the same hardware in a little bigger case. Those will accept smaller off the shelf GPUs.
Try to replicate software/apps you use everyday. Not to improve them, but to figure out how they work. In addition to learning how they work, you’ll learn the problems the original devs had to solve, and one way to solve them.