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).
- 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.
- 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.
- 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.
- Automatically generate ERD diagrams from SQLAlchemy models or directly from your database schema using ERAlchemy.
- Automatically generate class diagrams using PlantUML.
- Generate flowcharts and other diagrams using Mermaid.js via CLI.
- Custom Endpoints: Automatically generate new FastAPI endpoints with a simple command.
- SQLAlchemy Models: Generate basic SQLAlchemy models with one command.
-
Install the package using pip:
pip install fastapi-boilerplate-generator
-
Install the dependencies from
requirements.txt
:pip install -r requirements.txt
python manage.py runserver
python manage.py create-endpoint <endpoint_name>
- Example:
python manage.py create-endpoint users
python manage.py create-model <model_name>
- Example:
python manage.py create-model User
python manage.py makemigrations
python manage.py auto-generate-erd
python manage.py generate-class-diagram
python manage.py generate-mermaid-diagram
from fastapi import APIRouter
router = APIRouter()
@router.get("/")
async def get_users():
return {"message": "Users endpoint working"}
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)
You can configure your database connection inside your FastAPI app:
DATABASE_URL = "postgresql+psycopg2://username:password@localhost/dbname"
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
Contributions are welcome! Please submit a pull request or open an issue if you find any bugs or want to suggest new features.
This project is licensed under the MIT License. See the LICENSE file for more details.