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-start <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.17.tar.gz (25.8 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.17-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_starter_kit-0.1.17.tar.gz
  • Upload date:
  • Size: 25.8 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.17.tar.gz
Algorithm Hash digest
SHA256 2c88332bd6f2b5959a8f8bc7a2b4086b64778f0dc83e34adca93bd7473c65bc0
MD5 18ef07a5d37eb678697aa9a811715115
BLAKE2b-256 254da7fccc777559a25ac8f1ff98a65b9955e568184769fca5a32705c22674ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_starter_kit-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 0e3e2205589d97946f6a7f7ee8888ae6fbac230905b9b58e46c5a40adfc6fcd7
MD5 3a8b4228d443151737169f7d5a112f60
BLAKE2b-256 21a9ddbe8aecd1b2be673aede5a32a281ce483e044a23e5585fa62f68ce38baf

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