Skip to main content

A toolkit for building FastAPI projects with apps - internal and external pluggable apps

Project description

fastappkit

A toolkit for building FastAPI projects with apps — internal and external pluggable apps

License: MIT Python 3.11+

fastappkit brings Django-like app architecture to FastAPI, enabling modular development with both project-specific internal apps and reusable external pluggable apps.

What is fastappkit?

fastappkit is a toolkit for building FastAPI projects with a modular app architecture. It enables:

  • Internal apps — project-specific feature modules (like Django apps)
  • External apps — reusable, pluggable packages (like WordPress plugins)
  • Unified migrations — coordinated database schema management
  • Automatic router mounting — seamless integration of app routes
  • App validation and isolation — ensure apps don't conflict with each other

✨ Key Features

  • Clean project structure with automatic app discovery
  • Shared migrations for internal apps, isolated migrations for external apps
  • Automatic router mounting with configurable prefixes
  • Fail-fast validation and error handling
  • Support for both monorepo and multi-repo workflows
  • Simple CLI for project and app management

📦 Installation

Install fastappkit using pip or poetry:

pip install fastappkit

or

poetry add fastappkit

🏃 Quick Start

1. Create a new project

fastappkit core new myproject
cd myproject

This creates a complete FastAPI project structure with:

  • Core application setup (including core/models.py with SQLAlchemy Base class)
  • Database configuration
  • Migration system
  • App directory structure

Note: Dependency versions in pyproject.toml are set to * by default. Update them according to your needs, especially for production deployments.

2. Create an internal app

fastappkit app new blog

This creates a new internal app in apps/blog/ with models, router, and registers it in fastappkit.toml.

3. Run migrations

fastappkit migrate all

This runs all migrations in the correct order: core → internal apps → external apps.

4. Start the development server

fastappkit core dev

Your FastAPI application is now running at http://127.0.0.1:8000!

📚 Documentation

Comprehensive documentation is available at Read the Docs (coming soon).

For now, see docs/Usage.md for detailed usage instructions.

🎯 Core Concepts

Internal Apps

Internal apps are project-specific modules that live in your project's apps/ directory. They share the same migration system and database connection.

fastappkit app new blog
# Creates apps/blog/ with models, router, etc.

Key points:

  • Internal apps import Base from core.models for SQLAlchemy models
  • The register() function can return Optional[APIRouter] - return a router for fastappkit to mount, or mount it yourself and return None

External Apps

External apps are reusable packages that can be installed via pip and plugged into any fastappkit project.

fastappkit app new payments --as-package
# Creates a standalone package structure

Key points:

  • External apps must use their own Base class (isolated metadata) - cannot import from core
  • The register() function can return Optional[APIRouter] - return a router for fastappkit to mount, or mount it yourself and return None
  • External apps must have fastappkit.toml manifest in the package directory

Migrations

fastappkit provides unified migration management:

  • Core migrations: Project-level schema changes
  • Internal app migrations: Shared migration directory for all internal apps
  • External app migrations: Isolated migrations per external app
# Create migrations for an internal app
fastappkit migrate app blog makemigrations -m "Add post model"

# Run all migrations
fastappkit migrate all

# Preview SQL before applying
fastappkit migrate preview

🛠️ CLI Commands

Project Management

fastappkit core new <name>          # Create a new project
fastappkit core dev                  # Run development server

App Management

fastappkit app new <name>            # Create an internal app
fastappkit app new <name> --as-package  # Create an external app
fastappkit app list                  # List all apps
fastappkit app validate <name>       # Validate an app

Migration Management

fastappkit migrate core -m "message"           # Create core migration
fastappkit migrate app <name> makemigrations -m "message"  # Create app migration (internal only)
fastappkit migrate app <name> upgrade [--revision <rev>]  # Upgrade app migrations (external only)
fastappkit migrate app <name> downgrade --revision <rev>  # Downgrade app migrations (external only, --revision required)
fastappkit migrate app <name> preview [--revision <rev>]  # Preview SQL for app migrations (external only)
fastappkit migrate all                        # Run all migrations
fastappkit migrate preview [--revision <rev>]  # Preview SQL for core + internal app migrations
fastappkit migrate upgrade [--revision <rev>]  # Upgrade core + internal app migrations
fastappkit migrate downgrade <rev>            # Downgrade core + internal app migrations (<rev> required)

📖 Example Project Structure

myproject/
├── core/
│   ├── config.py          # Settings (loads from .env)
│   ├── models.py          # SQLAlchemy Base class (DeclarativeBase)
│   ├── app.py             # create_app() factory
│   └── db/
│       └── migrations/    # Core migrations
├── apps/                   # Internal apps directory
│   └── blog/
│       ├── models.py       # Imports Base from core.models
│       └── router.py
├── fastappkit.toml        # Project configuration
├── .env                   # Environment variables
└── main.py                # Entry point

🔧 Configuration

fastappkit uses fastappkit.toml for project configuration:

[tool.fastappkit]
apps = [
    "apps.blog",
    "apps.users",
    "external_package_name"
]

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

📄 License

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

🙏 Acknowledgments

📞 Support


Made with ❤️ for the FastAPI community

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

fastappkit-0.1.8.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

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

fastappkit-0.1.8-py3-none-any.whl (73.8 kB view details)

Uploaded Python 3

File details

Details for the file fastappkit-0.1.8.tar.gz.

File metadata

  • Download URL: fastappkit-0.1.8.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastappkit-0.1.8.tar.gz
Algorithm Hash digest
SHA256 1e9e6cd1dc8af4511a82fd51945baaa0c4633bf3e8575da205737d64a61997fe
MD5 95c0c17ac3a1b5016de47b97c57f2edc
BLAKE2b-256 79e16910dd8e79a69bc3605ef86b8cc06b466e0f50f9501f4bea5ce66845bd79

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastappkit-0.1.8.tar.gz:

Publisher: publish.yml on vanylabs/fastappkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastappkit-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: fastappkit-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 73.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastappkit-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5ecbc73ad0e9727118fcf1297b78b77e90745dcbf5e8218c71648a97a6dc74e3
MD5 0fd931980d9965253a371ecf009cb6d6
BLAKE2b-256 292394387fe3e38c1e7a3e3b6d7c12356faae1e9aae1df3a77bf77620bd57a26

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastappkit-0.1.8-py3-none-any.whl:

Publisher: publish.yml on vanylabs/fastappkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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