As I’ve been trying to update the tools I lean on for quick web things, I am really enjoying using FastAPI with Svelte. These are notes about the development setup that I currently like. Fair warning: this is not battle hardened yet. I’ve used it to make a couple of toys and like how it’s shaping up, though.

I’m mostly trying to capture the setup I like for local development in this post. While I have some ideas about how I want this to play with a real hosting setup, those are only half-developed at this point. I’m writing these details now half for future reference and half so I’ve got something I can point to and ask for commentary.

Backend

FastAPI is a relatively new python web framework. It’s a thin layer over Starlette. The end result is a very fast framework for asynchronous python web APIs. That’s only a small part of the appeal for me, though. It’s also very low boilerplate for APIs and includes OpenAPI doc generation and testing interfaces. (It does retain things like Jinja2 integration, to make it easy to serve markup while you’re iterating on an API.) I’m using it with the uvicorn server, mainly because that makes it very easy to have an interactive local debugger.

ORM

While FastAPI works acceptably with SQL Alchemy’s ORM, it really seems better matched with asynchronous database access. For that, I’m using Tortoise ORM. I had a hard time getting oriented with Tortoise at first, until I realized that its interface is inspired heavily by Django’s ORM. Django documents fill in more of the high level concepts than the current Tortoise ones do.

Frontend

I’m currently using Svelte for my front-end code. I’m not attached yet, but I like it so far. The pages it generates seem very lightweight, and the richness of the UI relative to the amount of code you have to write is excellent. There also doesn’t seem to be too much mysterious magic so far. Since I haven’t used any of the popular frontend packages for anything heavy (most of my work is stuck in the early jquery age with some bootstrap sprinkled in, up to this point) this one seems like a nice place to start. As a bonus, the JetBrains plugins for it are pretty good, and the high compatibility with static hosting makes adding a route to the dev server for the front-end very easy.

To get a head start on some nice widgetry, I’m using Smelte. Besides the look, using Smelte is an easy way to get Tailwind CSS integrated with Svelte.

IDE

I still subscribe to the JetBrains Toolbox because PyCharm Pro is my favorite editor and debugger for python. While WebStorm is great for javascript and svelte, installing the svelte plugin for PyCharm turns on the integration there. So I tend to work in PyCharm for the whole project. Though I still turn mainly to the Chrome dev tools for interactive debugging of front-end code. I’m not sure if there are some better facilities available in WebStorm or not.

Windows

While I work on Linux nearly all the time, it’s nice to be able to check out my repository and work from Windows also. VS Community Edition + Node.js installed on a Windows system make it feel almost as smooth as Linux for these tools.

Updates

I plan to return to this post and update things as I tweak my stack. Future posts will reference this one and describe work flow in more detail.

  • 10/5/2020 - Initial post