Home

Awesome

Tests Linters

fastapi-htmx-tailwind-example

Example application (IoT dashboard) built with FastAPI, HTMX, TailwindCSS, DaisyUI, Jinja, and MongoDB.

Goal

Create an extensive example project that integrates the following technologies:

Among others, the project showcases the following topics:

Non-goals and caveats:

Getting started

The following developer tools must be available:

The project's dependencies can be installed with poetry install.

The following poethepoet tasks are defined in the project:

These tasks can be executed with poetry run poe <task>.

Running the project

Just execute honcho start in the root directory. The command will spin up three processes:

The application will be available at http://127.0.0.1:10001/ (the port is configurable in .uvicorn.env).

When started with honcho start, the application will create some demo data. To prevent it from doing so, remove the CREATE_DEMO_DATA=true part from the Procfile's backend process definition.

Notes

Development

Use ruff for linting and formatting, mypy for static code analysis, pytest for testing, and poethepoet as the task runner.

As mentioned above, use honcho start to start the project, it automatically watches code changes and regenerates or restarts whatever is necessary for a convenient developer experience.

Contributing

All contributions and enhancements are welcome.

Note on TailwindCSS and DaisyUI

While TailwindCSS doesn't require npm, getting plugins (e.g. DaisyUI) working does. In order to work around this limitation, this project loads the full, minified DaisyUI stylesheet from a CDN, which is quite bad for performance. Production applications should use npm and configure TailwindCSS and the DaisyUI plugins as if it was a JavaScript project.

License - MIT

The project is open-sourced under the conditions of the MIT license.