Skip to main content

Starter template for FastAPI projects with JWT authentication and role-based access

Project description

FastAPI Starter Kit ๐Ÿš€

Python Version License PyPI Version

FastAPI Starter Kit is a production-ready starter template for building FastAPI projects with authentication, role-based access, and pre-configured boilerplate code. It helps developers quickly bootstrap a FastAPI project following best practices.


๐ŸŒŸ Features

  • Authentication & Authorization
    • JWT authentication (login/logout, token refresh)
    • User registration with hashed passwords
    • Basic role-based access control
  • Database
    • SQLAlchemy ORM integration
    • Alembic migrations
  • Project Structure
    • Modular with routers, services, models, and schemas
    • Pre-configured middleware for exception logging
    • Dependency management via dependencies.py
  • Utilities
    • Token generation and validation
    • Password utilities
    • Notification and email service hooks
  • Development-ready
    • .env configuration
    • Logging setup (logs/app.log)
    • Test setup with pytest

โšก Getting Started

1. Install the package

pip install fastapi-starter-kit

2. Create a new project

  • This command scaffolds the project structure with all necessary folders, files, and initial configuration.
fastapi-starter <project_name>
cd <project_name>

3. Install project dependencies

pip install -r requirements.txt

4. Configure environment

A default .env file is automatically created when you generate the project.

It includes basic application, database, JWT, and logging configuration such as:

APP_NAME=FastAPI Starter Pack
APP_DESCRIPTION=A well-structured FastAPI starter with JWT auth
APP_VERSION=1.0.0
DEBUG=True

# Database
DATABASE_URL=sqlite:///./app.db

# JWT Settings
JWT_SECRET_KEY=<your_secret_key_here>
JWT_ALGORITHM=HS256
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
JWT_REFRESH_TOKEN_EXPIRE_MINUTES=1440  # 24H

# Logging
LOG_LEVEL=INFO
LOG_FILE=logs/app.log

LOGIN_URL=/auth/login

5. Initialize the database

alembic upgrade head

6. Run the application

Option: 1

python main.py

Option: 2

uvicorn main:app --reload

Your API will be available at http://127.0.0.1:8000.

๐Ÿ—๏ธ Project Structure

project_a/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ auth/
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ external_services/
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ routers/
โ”‚   โ”œโ”€โ”€ schemas/
โ”‚   โ””โ”€โ”€ utils/
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ app.db
โ”œโ”€โ”€ migrations/
โ”œโ”€โ”€ logs/
โ”œโ”€โ”€ .env
โ””โ”€โ”€ tests/

๐Ÿ› ๏ธ Contributing

Contributions, bug reports, and feature requests are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature/fix
  3. Make your changes
  4. Write tests if applicable
  5. Submit a pull request

๐Ÿ“œ License

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

๐Ÿ’ก Notes

  • Designed for rapid project setup with authentication and role-based access
  • Easily extensible to include more modules, APIs, and services
  • Logging, database, and middleware are pre-configured for best practices

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_starter_kit-0.1.15.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

fastapi_starter_kit-0.1.15-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_starter_kit-0.1.15.tar.gz.

File metadata

  • Download URL: fastapi_starter_kit-0.1.15.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for fastapi_starter_kit-0.1.15.tar.gz
Algorithm Hash digest
SHA256 7a0c6300992daf00ba510a2bf92cf27b4329833512590ea0eb943c254939cef3
MD5 a72d32be378d7455319dc66d2d94f656
BLAKE2b-256 58a755f8d41cf50378634b850d07ab67ac6c1f1dbcc9ee2f9f350706a4d26635

See more details on using hashes here.

File details

Details for the file fastapi_starter_kit-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_starter_kit-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 50d17e81a7d2796ec6c112aed1bb7777f43d794625bd00c242cff6804aca9743
MD5 32b0dc2343cf992edb1db2300109fffc
BLAKE2b-256 1b13937f4b64cb4efd99626908b001fd66fc42da6f4b4a1d488389f6bca26aa6

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