Skip to main content

A CLI tool for scaffolding modern FastAPI projects

Project description

FastAPI CLI Tool

A powerful CLI tool for generating production-ready FastAPI applications with multiple template options.

Overview

This CLI tool provides three different templates to quickly bootstrap FastAPI applications:

  • Minimal: A basic FastAPI application with minimal dependencies
  • API Only: A modular API structure with authentication, database, and testing
  • Full-Stack: A complete production-ready application with all features

Installation

From PyPI (when published)

pip install fastapi-cli-tool

From Source

git clone https://github.com/Sohail342/fastapi-template
cd cli-tool
pip install -e .

Usage

Basic Usage

# Create a new FastAPI project
fastapi-cli create my-project

# Create with specific template
fastapi-cli create my-project --template fullstack

# List available templates
fastapi-cli templates

Available Templates

1. Minimal Template

  • Basic FastAPI application
  • Single file structure
  • Perfect for learning and simple projects
fastapi-cli create my-minimal-app --template minimal

2. API Only Template

  • Modular project structure
  • Authentication with JWT
  • Database integration with SQLAlchemy
  • Testing setup
  • API documentation
fastapi-cli create my-api-app --template api_only

3. Full-Stack Template

  • Everything in API Only template plus:
  • Production Docker setup
  • Database migrations with Alembic
  • Redis integration
  • Email support
  • Monitoring and logging
  • Pre-commit hooks
  • CI/CD ready
fastapi-cli create my-fullstack-app --template fullstack

CLI Commands

# Create new project
fastapi-cli create <project-name> [--template TEMPLATE]

# List available templates
fastapi-cli templates

# Show version
fastapi-cli --version

# Show help
fastapi-cli --help

Template Details

Minimal Template Features

  • Single main.py file
  • Basic FastAPI setup
  • Health check endpoint
  • Uvicorn development server

API Only Template Features

  • Project Structure:

    ├── app/
    │   ├── __init__.py
    │   ├── main.py
    │   ├── api/
    │   ├── core/
    │   ├── crud/
    │   ├── db/
    │   ├── models/
    │   └── schemas/
    ├── tests/
    ├── requirements.txt
    ├── .env.example
    └── README.md
    
  • Features:

    • JWT Authentication
    • SQLAlchemy ORM
    • Pydantic models
    • CRUD operations
    • Testing with pytest
    • Environment configuration

Full-Stack Template Features

  • Complete Production Setup:

    • PostgreSQL database
    • Redis caching
    • Docker & Docker Compose
    • Alembic migrations
    • Email support
    • Security headers
    • CORS configuration
    • Monitoring endpoints
    • Comprehensive testing
    • Development tools
  • Development Tools:

    • Black formatting
    • Ruff linting
    • MyPy type checking
    • Pre-commit hooks
    • Makefile commands

Development

Setup Development Environment

git clone <repository-url>
cd cli-tool
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
pip install -e .

Running Tests

pytest

Building Package

python -m build

Project Structure

cli-tool/
├── fastapi_template/
│   ├── __init__.py
│   ├── cli.py                    # CLI interface
│   └── templates/                # Template directories
│       ├── minimal/
│       ├── api_only/
│       └── fullstack/
├── tests/                        # CLI tool tests
├── pyproject.toml               # Package configuration
└── README.md                    # This file

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new features
  5. Run tests (pytest)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Template Customization

Each template can be customized by modifying the template files in the templates/ directory. The templates are designed to be:

  • Extensible: Easy to add new features
  • Configurable: Environment-based configuration
  • Maintainable: Clean code structure
  • Testable: Comprehensive test coverage

Requirements

  • Python 3.11+
  • For Full-Stack template:
    • PostgreSQL
    • Redis (optional)
    • Docker (optional)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues and questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Join our community discussions

Roadmap

  • Additional template options (GraphQL, microservices)
  • Plugin system for custom templates
  • Interactive CLI wizard
  • Database initialization scripts
  • Deployment configurations (AWS, GCP, Azure)
  • Frontend integration templates (React, Vue, Angular)

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_template_cli-0.1.2.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_template_cli-0.1.2-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_template_cli-0.1.2.tar.gz.

File metadata

  • Download URL: fastapi_template_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for fastapi_template_cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 64104aecbb650622d48ab88afcdba67c8998eea2a87cd05f6cfc0804efcc4f09
MD5 5584722f0ecd78e1b68a1c6704bee959
BLAKE2b-256 17e6feaf8752a68feeb39c03a496de712b0116db8117f646ac4acdfff7facae6

See more details on using hashes here.

File details

Details for the file fastapi_template_cli-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_template_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06737bac9d9254c9deab80a283f7807bebc8c43379a9e4aab4354fa582bae78b
MD5 f41520f029edeec22381581e34fcd983
BLAKE2b-256 42454496a15182ed9572d1a7dca624b1e4ba5dd902ee81e614c70cdb41bd35ff

See more details on using hashes here.

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