fapis — FastAPI Infrastructure Starter
Version 0.1.1
fapis is a CLI tool and template library to quickly scaffold production-ready FastAPI projects. It provides a clean, modern, and beginner-friendly base template that follows current best practices.
✨ What's New in 0.1.1
This release significantly simplifies the base template structure:
- ✅ Simplified Architecture - Removed unnecessary abstraction layers
- ✅ Modern Dependencies - Updated to Pydantic v2, FastAPI 0.109+, and Python 3.12
- ✅ Flatter Structure - Reduced from 4 to 2 folders in
app/ - ✅ Better Documentation - Comprehensive README with practical examples
- ✅ Enhanced Features - CORS support, uptime tracking, modern datetime handling
- ✅ Beginner Friendly - Easier to understand and extend
Key Changes
| Aspect | v0.1.0 | v0.1.1 |
|---|---|---|
| Pydantic | v1 (deprecated) | v2 (modern) |
| Python | 3.11 | 3.12 |
| App Folders | 4 (api, core, dependencies, infrastructure) | 2 (api, core) |
| Configuration | BaseSettings |
pydantic-settings |
| Lifecycle | Separate module | Inline context manager |
| README | Basic | Comprehensive guide |
🚀 Quick Start
Installation
# Install from PyPI
pip install fapis
# Or install from source for development
git clone https://github.com/Dirac1235/fapis.git
cd fapis
pip install -e .
Generate a New Project
# Create a new FastAPI project
fapis base ./my-awesome-api
# Navigate to the project
cd my-awesome-api
# Set up virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the development server
uvicorn app.main:app --reload
Visit http://127.0.0.1:8000/docs for interactive API documentation!
📦 What's Included
The base template includes:
- ✅ FastAPI 0.109+ with modern async support
- ✅ Pydantic v2 settings with environment variables
- ✅ CORS middleware pre-configured
- ✅ Health check endpoint with uptime tracking
- ✅ Logging configured and ready to use
- ✅ Testing setup with pytest and httpx
- ✅ Docker configuration for containerization
- ✅ Makefile with helpful development commands
- ✅ Type hints throughout the codebase
🗂️ Project Structure (Simplified!)
The generated project has a clean, minimal structure:
my-awesome-api/
├── app/
│ ├── __init__.py
│ ├── main.py # Application entry point with lifecycle
│ ├── api/ # API endpoints (add your routes here)
│ │ ├── __init__.py
│ │ └── health.py # Example health check endpoint
│ └── core/ # Core configuration
│ ├── __init__.py
│ └── config.py # Settings management with pydantic-settings
├── tests/
│ └── test_health.py # Example tests with pytest
├── .env.example # Environment variables template
├── .gitignore # Python gitignore
├── Dockerfile # Production-ready container
├── Makefile # Development commands
├── README.md # Project-specific documentation
└── requirements.txt # Python dependencies
No more unnecessary folders! Everything you need, nothing you don't.
🛠️ Development Workflow
Available Make Commands
make help # Show all available commands
make install # Install dependencies
make run # Run development server with auto-reload
make test # Run tests with pytest
make clean # Remove Python cache files
make docker-build # Build Docker image
make docker-run # Run Docker container
Adding Features
Add a new endpoint:
# app/api/users.py
from fastapi import APIRouter
router = APIRouter()
@router.get("/users")
async def get_users():
return {"users": ["Alice", "Bob"]}
Then register it in app/main.py:
from app.api import users
app.include_router(users.router, prefix="/api", tags=["users"])
Add database support:
- Add SQLAlchemy or your preferred ORM to
requirements.txt - Create
app/db/for models and connections - Initialize in the
lifespanfunction inmain.py
See the template README for more examples!
📚 Template Features
Environment Configuration
All settings are managed through .env file:
APP_NAME="My Awesome API"
VERSION="0.1.1"
DEBUG=true
HOST="0.0.0.0"
PORT=8000
CORS_ORIGINS="http://localhost:3000,http://localhost:8000"
Health Endpoint
Every generated project includes a health check endpoint:
curl http://localhost:8000/api/health
Response:
{
"status": "ok",
"timestamp": "2025-12-22T07:39:29.805384+00:00",
"uptime_seconds": 42.15
}
CORS Support
CORS is pre-configured and can be customized via environment variables:
# Configured via settings
CORS_ORIGINS="http://localhost:3000,https://myapp.com"
🐳 Docker Deployment
The template includes a production-ready Dockerfile:
# Build the image
docker build -t my-awesome-api .
# Run the container
docker run -p 8000:8000 my-awesome-api
Or use Docker Compose (create your own docker-compose.yml):
version: "3.8"
services:
api:
build: .
ports:
- "8000:8000"
env_file:
- .env
🤝 How the CLI Works
The CLI is simple and straightforward:
fapis <template> <destination>
Currently available templates:
base- Modern, minimal FastAPI starter (recommended)
Example:
fapis base ./services/my-service
The CLI will:
- Copy the template files to your destination
- Initialize a git repository (if git is available)
- Provide next steps for you to follow
📖 Links
- GitHub Repository: Dirac1235/fapis
- PyPI Package: pypi.org/project/fapis
- Template Source:
fapis/templates/infrastructure/base/ - Issues & Feedback: GitHub Issues
🎯 Why Use fapis?
- Beginner-Friendly: Simple structure that's easy to understand
- Production-Ready: Includes logging, health checks, CORS, Docker
- Modern: Uses latest FastAPI, Pydantic v2, and Python best practices
- Extensible: Clear patterns for adding features
- Well-Documented: Both the CLI and generated projects have great docs
- Type-Safe: Full type hints throughout
🔄 Migration from 0.1.0
If you have projects generated with v0.1.0, here are the key differences:
- Removed folders:
app/dependencies/,app/infrastructure/ - Removed files:
app/core/logging.py - Updated imports: Pydantic settings now from
pydantic-settings - New features: CORS middleware, uptime tracking, modern datetime
For new projects, use v0.1.1. Existing projects can continue using v0.1.0 or be manually updated.
📄 License
MIT License - See LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
git clone https://github.com/Dirac1235/fapis.git
cd fapis
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install in editable mode
pip install -e .
# Make your changes...
# Test the CLI
fapis base ./test-project
cd test-project
pip install -r requirements.txt
pytest -v
🌟 Show Your Support
If you find this project helpful, please give it a ⭐ on GitHub!
Built with ❤️ for the FastAPI community
Metadata
Release files for fapis 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 | Provenance | |
|---|---|---|---|---|
| fapis-0.1.1.tar.gz | 16.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fapis-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.7 kB
Release files / fapis-0.1.1.tar.gz
| Download URL | fapis-0.1.1.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9487b25fa3269abd041db72819fdcc8465d836185cb742946720b13ca270532d
|
|
BLAKE2b-256 checksum How to use checksums |
c7788cf1483bb9594cb42458f54a7f65133f7b162f1c33e60f2b02b03ebf22f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / fapis-0.1.1-py3-none-any.whl
| Download URL | fapis-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72873c75877729842aec04a46be2d8c4db1654a82c7521246ad2f0d4b6bf94b7
|
|
BLAKE2b-256 checksum How to use checksums |
2cb8de3aee6994f3bc1b8274b63c0fe3d5b833b186ed530ae698d20a8a1c2c75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for fapis 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.