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.2.tar.gz (48.2 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.2-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_fusion_core-0.1.2.tar.gz.

File metadata

  • Download URL: fastapi_fusion_core-0.1.2.tar.gz
  • Upload date:
  • Size: 48.2 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.2.tar.gz
Algorithm Hash digest
SHA256 28c3cd3c9e085902a4cdd347d6e52a79a8117b5d8dbc4e7cb1003a9ff9a51769
MD5 1010370016b2c397f5f32431d5424329
BLAKE2b-256 8057be74f4f1343d03c75335fb64a3431b4bf39296a5b5d68a8f73cb026871a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_fusion_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 be5a7918fec226a384b78dbb95a52a2bffd383c744c2960dfa533fa57281ceec
MD5 a8c56f53ddbfb14e7e79ab9d666eb60a
BLAKE2b-256 6ef4079a8e7bd81ade803efcfc3c44313e9ce9473a626bdc0f49ec7d7576cb7f

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