Starter template for FastAPI projects with JWT authentication and role-based access
Project description
FastAPI Starter Kit ๐
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, andschemas - Pre-configured middleware for exception logging
- Dependency management via
dependencies.py
- Modular with
- Utilities
- Token generation and validation
- Password utilities
- Notification and email service hooks
- Development-ready
.envconfiguration- 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:
- Fork the repository
- Create a new branch for your feature/fix
- Make your changes
- Write tests if applicable
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c88332bd6f2b5959a8f8bc7a2b4086b64778f0dc83e34adca93bd7473c65bc0
|
|
| MD5 |
18ef07a5d37eb678697aa9a811715115
|
|
| BLAKE2b-256 |
254da7fccc777559a25ac8f1ff98a65b9955e568184769fca5a32705c22674ad
|
File details
Details for the file fastapi_starter_kit-0.1.17-py3-none-any.whl.
File metadata
- Download URL: fastapi_starter_kit-0.1.17-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e3e2205589d97946f6a7f7ee8888ae6fbac230905b9b58e46c5a40adfc6fcd7
|
|
| MD5 |
3a8b4228d443151737169f7d5a112f60
|
|
| BLAKE2b-256 |
21a9ddbe8aecd1b2be673aede5a32a281ce483e044a23e5585fa62f68ce38baf
|