A boilerplate FastAPI application with a structured project layout.
- Structured project layout
- CORS middleware enabled
- Example API endpoints for items
- Pydantic models for data validation
- Environment variable support
.
├── app/
│ ├── __init__.py
│ ├── models/
│ │ ├── __init__.py
│ │ └── item.py
│ └── routers/
│ ├── __init__.py
│ └── items.py
├── .env
├── main.py
├── README.md
└── requirements.txt
- Clone the repository
- Install uv (a faster Python package installer and resolver):
curl -sSf https://astral.sh/uv/install.sh | bash- Create and activate a virtual environment with uv:
uv venv
source .venv/bin/activate # On Linux/macOS
# OR
.venv\Scripts\activate # On Windows- Install dependencies using uv:
uv pip install -r requirements.txtUsing uv:
uv run uvicorn main:app --host 0.0.0.0 --port 12000 --reloadUsing uvicorn directly (after installing with uv):
uvicorn main:app --host 0.0.0.0 --port 12000 --reloadOr simply run with uv:
uv run python main.pyOnce the application is running, you can access the API documentation at:
- Swagger UI: http://localhost:12000/docs
- ReDoc: http://localhost:12000/redoc
GET /: Root endpoint with welcome messageGET /health: Health check endpointGET /items/: Get a list of itemsGET /items/{item_id}: Get a specific itemPOST /items/: Create a new itemPUT /items/{item_id}: Update an existing itemDELETE /items/{item_id}: Delete an item