Skip to main content

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).

  1. Run the server (see step 4)
  2. 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


๐Ÿงช 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_fusion_core-0.1.1.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

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

fastapi_fusion_core-0.1.1-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

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

Hashes for fastapi_fusion_core-0.1.1.tar.gz
Algorithm Hash digest
SHA256 824b609afdaa86f04b772547e61299359758e85d09180db7678c957360bdf1d7
MD5 3e2649c0bd5d547d2ff14de8c78d3122
BLAKE2b-256 6ae1311d38171de0c0a1e5ee47e9acdc2a468a1ebb744218c8061bd10ae6b4e1

See more details on using hashes here.

File details

Details for the file fastapi_fusion_core-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_fusion_core-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4befdb127783cd982092b613a50f831e6771cd1fd9e0f63d5df269e6cb8d68c8
MD5 ae582b6cd428c22951c766c88cc1bff9
BLAKE2b-256 988954b5b2b9a6c5fe03336b9ff188b7066891a64fd0dafd75a8e0836dea9e6e

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