Skip to main content

FastAPI project generator with a root-level, Django-style app layout

Project description

fastapi-templatekit

Tests Coverage PyPI version Python versions PyPI downloads

A FastAPI TemplateKit with a root-level, Django-style app layout.

CLI

Create a new project without installing this template into that project's environment:

uvx fastapi-templatekit startproject myproject
cd myproject
uvx fastapi-templatekit startapp users

Create the project files directly in the current directory:

uvx fastapi-templatekit startproject myproject .

If generated files already exist, the CLI asks before overwriting them. Use --force to overwrite without a prompt:

uvx fastapi-templatekit startproject myproject . --force

Create the project at a custom path:

uvx fastapi-templatekit startproject myproject ../services/myproject

For local development from this repository:

uvx --from . fastapi-templatekit startproject myproject

Generated projects include a Typer management command to discover registered HTTP and websocket routes:

uv run myproject urls

Show available commands and details:

uvx fastapi-templatekit help

Add health probes to an existing generated project:

uvx fastapi-templatekit addhealthprobes

Create an app with optional websocket and database scaffolding:

uvx fastapi-templatekit startapp users
uvx fastapi-templatekit startapp users --with-websockets --with-database

Generated projects keep the main router beside main.py:

myproject/
├── pyproject.toml
├── fastapi_templatekit.toml
├── myproject/
│   ├── __init__.py
│   ├── main.py
│   ├── config.py
│   └── router.py
└── users/
    ├── __init__.py
    ├── router.py
    ├── endpoints/
    │   ├── __init__.py
    │   └── api.py
    ├── schemas/
    │   ├── __init__.py
    │   └── validator.py
    ├── service/
    │   ├── __init__.py
    │   └── users_service.py
    ├── models/          # created only with database/tables enabled
    │   └── __init__.py
    └── websocket/       # created only with websockets enabled
        ├── __init__.py
        └── router.py

Structure

.
├── api/           # top-level router registration
├── health/        # example domain app at project root
├── main/
│   ├── config.py  # settings and config live here
│   └── app.py     # FastAPI declaration lives here
└── pyproject.toml

This follows the same domain-first idea from fastapi-best-practices, but without a src/ directory. Feature apps and the shared API router live directly under the project root, similar to Django apps.

Run

uv run uvicorn main.app:app --reload

WebSockets

WebSocket routes are mounted under the same API prefix, so the default endpoint is:

/api/v1/ws/{room_name}

There is also a built-in browser test page at:

/api/v1/ws/test

This app uses fastapi-websockets with the package's environment-based channel-layer loader. For websocket-related environment configuration, refer to https://github.com/Amogha-Hegde/fastapi-websockets.

Tests force FASTAPI_WEBSOCKETS_BACKEND=inmemory so they do not depend on a running database.

Example session:

connect ws://127.0.0.1:8000/api/v1/ws/demo
receive {"event":"connected","room":"demo",...}
send {"sender":"alice","message":"hello"}
receive {"event":"message","room":"demo","sender":"alice","message":"hello"}

Add a new app

Create a root-level package such as users/ or orders/, define its router there, and include it from your project's main router.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_templatekit-0.1.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_templatekit-0.1.1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_templatekit-0.1.1.tar.gz.

File metadata

  • Download URL: fastapi_templatekit-0.1.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastapi_templatekit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d9479fbd7b05bcd8383cb9167acfc3d078b6eb0d93a487284f05269a5e8183ef
MD5 91a5d1274be8fc9d0c0663d8d871a4b7
BLAKE2b-256 c0e776bce1cf6c370a1e66b4ee19771a01ce20a8ea7eabf8b624ba26b443a271

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_templatekit-0.1.1.tar.gz:

Publisher: publish.yml on Amogha-Hegde/fastapi-templatekit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastapi_templatekit-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_templatekit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7fdce6b36ea7a34086c6ccf9fea81bdcf4a81bde1cd9a404a56d5eb98d7dac0
MD5 65bf7fc27e40da5131f731793d0b7f05
BLAKE2b-256 f838adf9f8e48ac8794d7c8e23067196d8f7a62b67f014448e6abb63b8567105

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_templatekit-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Amogha-Hegde/fastapi-templatekit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page