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.16.tar.gz (25.5 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.16-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_starter_kit-0.1.16.tar.gz
  • Upload date:
  • Size: 25.5 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.16.tar.gz
Algorithm Hash digest
SHA256 23d045743f25b36c9a8139844de945ddad746758875e1043dabc6242296d9c5c
MD5 55be92e451112d5681c825b8ef1e1535
BLAKE2b-256 f926e3e8bd779432660497bc6c5ab6689aced474fb469bb007f714d9303503e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_starter_kit-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 0f8690d15699e153ca7eb66474641c7a40cb9c9b4679475e8444e0f85fede9cf
MD5 7da5eb86174c83a34e4861d27a31ea78
BLAKE2b-256 9e6cab4ef47980038074dbc21a9a6ef4302ca80cc3d00b960da9ee741f319de6

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