Skip to main content

FashGenAPI

FashGenAPI is a versatile package designed to simplify and accelerate your FastAPI project development. It provides essential tools for automatic generation of project structure, models, endpoints, documentation, diagrams, and database management, all integrated into a single command-line interface (CLI).

Features

1. Auto-Generated Documentation

  • Swagger & ReDoc: Automatically integrates Swagger UI and ReDoc for easy API documentation.
  • Custom Templates: Customize the look and feel of your API documentation with predefined templates.
  • Real-time updates: Auto-generates documentation when project components are modified.

2. Authentication and Authorization

  • JWT-based Authentication: Built-in support for JWT (JSON Web Token) to secure your API.
  • OAuth2: Easily integrate OAuth2 for external authentication providers.
  • Role-based Access Control (RBAC): Predefined user roles and permissions for easy management of access levels.

3. Database Migrations and ORM Integration

  • SQLAlchemy: Integrated SQLAlchemy ORM for smooth database interaction.
  • Alembic Migrations: Auto-generate database migration scripts.
  • Multiple Database Support: Configure PostgreSQL, SQLite, or other databases with ease.

4. Auto-Generate ERD (Entity-Relationship Diagrams)

  • Automatically generate ERD diagrams from SQLAlchemy models or directly from your database schema using ERAlchemy.

5. Class Diagram Generation (UML)

  • Automatically generate class diagrams using PlantUML.

6. Mermaid.js Diagram Generation

  • Generate flowcharts and other diagrams using Mermaid.js via CLI.

7. API Endpoint and Model Generation

  • Custom Endpoints: Automatically generate new FastAPI endpoints with a simple command.
  • SQLAlchemy Models: Generate basic SQLAlchemy models with one command.

Installation

  1. Install the package using pip:

    pip install fastapi-boilerplate-generator
    
  2. Install the dependencies from requirements.txt:

    pip install -r requirements.txt
    

CLI Usage

Run the FastAPI Server

python manage.py runserver

Create a New Endpoint

python manage.py create-endpoint <endpoint_name>
  • Example:
    python manage.py create-endpoint users
    

Create a New SQLAlchemy Model

python manage.py create-model <model_name>
  • Example:
    python manage.py create-model User
    

Database Migrations

python manage.py makemigrations

Generate ERD from SQLAlchemy Models

python manage.py auto-generate-erd

Generate Class Diagrams

python manage.py generate-class-diagram

Generate Diagrams using Mermaid.js

python manage.py generate-mermaid-diagram

Examples

Example of Generated Endpoint (users.py)

from fastapi import APIRouter

router = APIRouter()

@router.get("/")
async def get_users():
    return {"message": "Users endpoint working"}

Example of Generated SQLAlchemy Model (user.py)

from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String)

Configuration

Database Configuration

You can configure your database connection inside your FastAPI app:

DATABASE_URL = "postgresql+psycopg2://username:password@localhost/dbname"

JWT Configuration

To secure your API with JWT, define your secret key and expiration inside your configuration file:

JWT_SECRET = "your_jwt_secret"
JWT_ALGORITHM = "HS256"
JWT_EXPIRATION_TIME_MINUTES = 30

Contributing

Contributions are welcome! Please submit a pull request or open an issue if you find any bugs or want to suggest new features.


License

This project is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for FastGenAPI 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FastGenAPI 0.1.2
File Size Uploaded
fastgenapi-0.1.2.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for FastGenAPI 0.1.2
File Interpreter ABI Platform
FastGenAPI-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / fastgenapi-0.1.2.tar.gz

Download URL fastgenapi-0.1.2.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
56f36a3f1c8468ab4577bf72a66c53749a54a4948a60b95e746a7a2112ce3f1a
BLAKE2b-256 checksum
How to use checksums
12a919e59895437756d829bf4d95b783482de7772b12d1dffedd2a596c871bf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release files / FastGenAPI-0.1.2-py3-none-any.whl

Download URL FastGenAPI-0.1.2-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fe2f9943f6f3db6dc0c48d7ecba7b46734323cc17d360b467caf92bf6322faf
BLAKE2b-256 checksum
How to use checksums
348a32e56cc346ab405df8274bd06e70d6c4b2a437306b4cda365dacd995b483
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page