fastapi-foundry
fastapi-foundry is a command-line tool that scaffolds new FastAPI projects in seconds.
One command gives you a ready-to-run FastAPI application with a clean src/ layout,
a modern uv-compatible pyproject.toml, environment-based
configuration and a sensible .gitignore, so you can skip the boilerplate and start
building your API.
uvx fastapi-foundry init myproject
Features
- One-command setup:
fastapi-foundry init <name>creates a complete project. - Runs immediately: the generated app starts with
uv syncanduvicorn, no edits needed. - Modern packaging:
src/layout,pyproject.tomland theuv_buildbackend. - Safe by default: never overwrites an existing directory and rejects unsafe project names.
- Friendly names:
my-apibecomes themy-api/folder with an importablemy_apipackage. - Minimal dependencies: generated projects depend only on FastAPI and Uvicorn.
Requirements
- Python 3.12 or newer
- uv (recommended) or pip
Install uv if you don't have it yet:
# macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Installation
Option 1: Run without installing (recommended)
uvx downloads and runs the latest version in a temporary environment:
uvx fastapi-foundry init myproject
Option 2: Install as a global command
uv tool install fastapi-foundry
Then use it from any directory:
fastapi-foundry init myproject
Upgrade later with:
uv tool upgrade fastapi-foundry
Option 3: Install with pip
pip install fastapi-foundry
Quick start
1. Create a project
uvx fastapi-foundry init myproject
Created FastAPI project: myproject
Next steps:
cd myproject
uv sync
uv run uvicorn myproject.main:app --reload
2. Install dependencies
cd myproject
uv sync
3. Run the application
uv run uvicorn myproject.main:app --reload
4. Open it in your browser
| URL | Description |
|---|---|
| http://127.0.0.1:8000 | API root, returns {"message": "Hello from FastAPI"} |
| http://127.0.0.1:8000/docs | Interactive Swagger UI documentation |
| http://127.0.0.1:8000/redoc | ReDoc documentation |
Generated project structure
myproject/
├── pyproject.toml # Project metadata and dependencies (FastAPI, Uvicorn)
├── .env # Environment variables
├── .gitignore # Python, uv and tooling ignores
├── README.md # How to install and run the project
└── src/
└── myproject/
├── __init__.py
├── main.py # FastAPI application
├── config.py # Settings read from environment variables
└── database/
├── __init__.py
└── connection.py
The generated main.py:
from fastapi import FastAPI
from . import config
app = FastAPI(title=config.APP_NAME, debug=config.DEBUG)
@app.get("/")
def root() -> dict[str, str]:
return {"message": "Hello from FastAPI"}
Configuration
Generated projects read their settings from environment variables in config.py:
| Variable | Default | Description |
|---|---|---|
APP_NAME |
project name | Title shown in the API docs |
DEBUG |
false |
Enables FastAPI debug mode (true, 1 or yes) |
To load the values from the generated .env file, start the server with --env-file:
uv run uvicorn myproject.main:app --reload --env-file .env
Project names
The project name is used for both the folder and the Python package, so it must:
- start with a letter
- contain only letters, digits, hyphens (
-) and underscores (_) - not be a Python keyword or clash with a standard library or FastAPI module (for example
jsonorfastapi)
Hyphens are converted for the package name:
uvx fastapi-foundry init my-fastapi-app
This creates the my-fastapi-app/ folder containing the my_fastapi_app package, which you run with:
uv run uvicorn my_fastapi_app.main:app --reload
If the target folder already exists, fastapi-foundry stops with an error instead of overwriting your files.
Command reference
fastapi-foundry --help # Show available commands
fastapi-foundry init --help # Show help for the init command
fastapi-foundry init <name> # Create a new project in the current directory
Roadmap
fastapi-foundry is in early development. Planned features include:
- Database setup with SQLAlchemy and Alembic migrations
- Settings management with Pydantic Settings
- Generators for models and routes
- Authentication scaffolding
- Docker support
Contributing
Issues and pull requests are welcome on GitHub.
To set up a development environment:
git clone https://github.com/udarakalpana/fastapi-foundry.git
cd fastapi-foundry
uv sync
uv run pytest
Run the CLI from your local checkout:
uv run fastapi-foundry init myproject
Tip: create test projects outside the repository folder so they don't get mixed into its Git history.
License
fastapi-foundry is released under the MIT License.
Metadata
Release files for fastapi-foundry 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_foundry-0.1.1.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_foundry-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / fastapi_foundry-0.1.1.tar.gz
| Download URL | fastapi_foundry-0.1.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e750ad013d8e5c35a372b30f76dd1375e169049a2866a2a1df6270a446618d40
|
|
BLAKE2b-256 checksum How to use checksums |
d30763ac12423edde4b668201c6cab65bf1f7818efb98384e8fe819bf0baabf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fastapi_foundry-0.1.1-py3-none-any.whl
| Download URL | fastapi_foundry-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
176922ea4d4aaf08d7da1334e475452e4d946df7b1714e6011c86e831758821c
|
|
BLAKE2b-256 checksum How to use checksums |
ce4b2b55a5511088063dcfaac41c8d526b0a6c9794475381c86317923ddea5e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|