A premium, production-ready FastAPI boilerplate with built-in multi-database support and GraphQL.
Project description
FastAPI Fusion Core
A high-performance, scalable FastAPI boilerplate with multi-database support (PostgreSQL, MySQL, MongoDB), GraphQL integration, and a premium architecture.
๐ Key Features
- ๐ก๏ธ Custom Response System: Unified JSON response structure for success and errors.
- ๐ Multi-Database Integration:
- PostgreSQL: Async support via SQLAlchemy + asyncpg.
- MySQL: Async support via SQLAlchemy + aiomysql.
- MongoDB: Async support via Motor.
- ๐ GraphQL Support: Modern GraphQL API using Strawberry with authentication integration.
- ๐ Robust Authentication: JWT-based auth with Redis session management.
- โก Advanced Error Handling: Global exception handlers for Pydantic validation, HTTP exceptions, and custom business logic errors.
- ๐ Swagger & ReDoc: Automated API documentation.
- ๐๏ธ Premium Architecture: Clean separation of models, schemes, services, and routers.
๐ ๏ธ Project Structure
app/
โโโ api/ # REST API Routers & Services
โ โโโ auth/ # Login, Register, Profile
โ โโโ products/ # MongoDB CRUD Reference
โ โโโ utils/ # Database utility routes
โโโ core/ # Global configurations & Middleware
โ โโโ error/ # Error types and message codes
โ โโโ middleware/ # Logging & Exception handling
โ โโโ response/ # Base schemas & Response builder
โโโ database/ # DB Drivers & Session management
โโโ depends/ # FastAPI Dependencies (Auth, DB, etc.)
โโโ graphql/ # Strawberry GraphQL Schema & Context
โโโ models/ # SQLAlchemy & MongoDB Models
โโโ utils/ # Helper utilities
๐ฆ Getting Started
1. Installation
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Mac/Linux
# .venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
2. Configuration
Create a .env.development or .env.production file using variables mapped to app/config.py:
PROJECT_NAME="FastAPI Fusion"
API_VERSION="1.0.0"
ENVIRONMENT="development"
# PostgreSQL (Example)
POSTGRES_USER=myuser
POSTGRES_PASSWORD=secret
POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_DB=fastapii
# MySQL
MYSQL_USER=...
MYSQL_PASSWORD=...
# MongoDB
MONGODB_URI=...
# Redis & JWT Core
REDIS_DB_HOST=127.0.0.1
APP_JWT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----..."
APP_JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----..."
3. Database Initialization
To automatically spawn the necessary tables defined in your SQLAlchemy models (PostgreSQL & MySQL), use the internal setup endpoint.
(Ensure your fastapii or specified DB catalog natively exists in Postgres before hitting this endpoint. Run createdb fastapii inside Postgres).
- Run the server (see step 4)
- Visit
http://localhost:8000/utils/create-tables
4. Running the Server
uvicorn app.main:app --reload
5. Running the Tests
A comprehensive test suite is scaffolded using pytest, pytest-asyncio, and httpx.
# Install test dependencies
pip install -r requirements-dev.txt
# Run the test suite
pytest tests/ -v
๐ API Documentation
- Swagger: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- GraphQL IDL: http://localhost:8000/graphql
๐งช Advanced Usage Examples
MongoDB CRUD (REST)
Access the MongoDB-backed product management at /api/products. This implementation uses Motor for asynchronous operations.
GraphQL Query Example
query {
me {
username
role
}
products {
name
price
}
}
๐ค Contribution
Designed for high-performance enterprise applications. Feel free to extend the models or add new services in the app/api directory.
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_fusion_core-0.1.1.tar.gz.
File metadata
- Download URL: fastapi_fusion_core-0.1.1.tar.gz
- Upload date:
- Size: 47.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
824b609afdaa86f04b772547e61299359758e85d09180db7678c957360bdf1d7
|
|
| MD5 |
3e2649c0bd5d547d2ff14de8c78d3122
|
|
| BLAKE2b-256 |
6ae1311d38171de0c0a1e5ee47e9acdc2a468a1ebb744218c8061bd10ae6b4e1
|
File details
Details for the file fastapi_fusion_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_fusion_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 42.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4befdb127783cd982092b613a50f831e6771cd1fd9e0f63d5df269e6cb8d68c8
|
|
| MD5 |
ae582b6cd428c22951c766c88cc1bff9
|
|
| BLAKE2b-256 |
988954b5b2b9a6c5fe03336b9ff188b7066891a64fd0dafd75a8e0836dea9e6e
|