Skip to documentation
Python + FastAPI

Framework guides

Python + FastAPI

Create an API with health endpoints and tests.

On this page

Choose your starting point

Before you start

Node.js 20.19 or newer to run Forjex, plus Python 3.11 or newer with pip and venv.

Create your project from a folder where you keep your work. Forjex creates a new subfolder and refuses to overwrite an existing one. No GitHub or Vercel account is required to create and run the starter.

Create your Python + FastAPI project

1

Generate the starter

Run this command from your terminal. It downloads and runs the Forjex CLI.

pnpm dlx forjex create my-python-app --template python

Forjex creates the files. Install the language tools listed above, then follow the commands in the next step.

The package-manager buttons select how you run Forjex. Node starter dependencies are installed with npm by the CLI. After creation, interactive mode offers to continue into GitHub, optional CI/CD, and deployment. Choose No or use --no-setup to finish locally.

2

Run your application

cd my-python-app
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
uvicorn main:app --reload

On Windows, activate the environment with .venv\Scripts\activate instead of source .venv/bin/activate.

Open http://127.0.0.1:8000 for the API response, or http://127.0.0.1:8000/docs for interactive API documentation.

3

Make your first change

Edit main.py. Run the application again to see your changes.

Use the entry point and test starter as a starting point for your own application.

4

Run the checks

pytest

Run this before sharing your work. A successful local build or test does not deploy the application.

What gets created

  • FastAPI application with / and /health endpoints
  • Interactive API documentation at /docs
  • Pytest tests with the FastAPI test client
  • requirements.txt for local dependency installation
Project structure
├── .gitignore
├── main.py
├── README.md
├── requirements.txt
└── test_main.py

This is the complete default local file tree before installing dependencies. It includes the README and a language-specific .gitignore.

Already have a project?

Skip the create command. Open your existing Python + FastAPI project folder and run:

npx forjex forge

Choose Use the existing project in this directory. The CLI uses your local application files for repository setup; it does not replace them with a starter. Review existing workflows and configuration before enabling generation.

Follow the existing-project guide →

Connect GitHub and ship

Creation offers to continue into GitHub, optional CI/CD, and deployment. To continue later, run npx forjex forge from the generated project folder and choose the existing-project path. You can create a GitHub repository, add CI/CD, and push your code.

Use a host that supports your language and runtime. These backend starters do not include a Vercel deployment setup.

Prefer a visual setup? The browser wizard also offers this framework.