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.0.tar.gz (15.9 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.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_templatekit-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 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.0.tar.gz
Algorithm Hash digest
SHA256 7ebe34e037bf450d8c2a7f678536dd2744205667c055977c144af1304896c518
MD5 54f348f5fe41a64100851a1c8762c4c3
BLAKE2b-256 7f58e2f155a4343e3a2672547d7dc29d80ca227147adec4a90699f6ba5cf4fae

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_templatekit-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_templatekit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e766536a153b0005ce6ec0160158b21fe7c861dc0a97a75d1a74da88e8f36442
MD5 681b3393e17649a2d16401e4d961ea65
BLAKE2b-256 d3b49f5721e808166e1cdc42d722c10b513151525e7079105da1cb7251eb7ff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_templatekit-0.1.0-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