I'm interested in creating a super minimalist version of FastAPI, but the codebase feels a bit overwhelming to me. What core concepts should I learn, and what approach should I take to start building it? Thanks!
5 Answers
If you're thinking of this for professional use, definitely go for Starlette, since it's the web foundation for FastAPI. But if it's more for personal learning, Starlette is still a good choice; its codebase is simpler and captures the ASGI spec effectively.
FastAPI is built on the Starlette library, so I recommend starting there.
Consider checking out this PyCon tutorial. It's about 1.5 hours long, with part of it focused on exercises. It will help you grasp concepts like WSGI, and how frameworks such as Flask and Django operate, alongside understanding the role of tools like Werkzeug in Flask and Starlette in FastAPI. After that, dive into PEP 3333 and the ASGI documentation. Then you’ll be primed to create your own version!
Check out the ASGI specification so you can design something that conforms to it. Honestly, if you're still getting familiar with FastAPI, it’s a bit puzzling why you'd try to create a smaller version—what would you even know to slim down?
You might begin with the ASGI docs and build a basic server with just a few lines of code. Start with simple routing using a dictionary, and then maybe switch to regular expressions or a radix tree later on. It's a great little weekend project!

Just doing it for fun!