Skip to main content

Um pacote para gerar projetos FastAPI com estrutura básica.

Project description

Fast Hard

Fast Hard is a Python package that generates a FastAPI project with a basic structure, similar to create-react-app for React. It sets up a ready-to-use FastAPI application with essential dependencies, folder structure, and configurations.


Features

  • Generates a FastAPI project with a standard folder structure.
  • Installs essential dependencies:
    • FastAPI
    • Uvicorn
    • SQLAlchemy
    • Pytest
    • Email-validator
    • Alembic (for database migrations)
  • Includes a basic .env file for environment variables.
  • Sets up Alembic for database migrations.
  • Provides a simple main.py with a "Hello World" endpoint.
  • New commands for flexible folder structure:
    • fast-hard create_mvc <project_name>: Creates a project and adds an MVC folder structure.
    • fast-hard create_use_cases <project_name>: Creates a project and adds a folder structure for use cases.
  • Choose your database:
    • SQLite
    • MySQL
    • PostgreSQL
    • MongoDB

Installation

You can install fast_hard via pip:

pip install fast_hard

Usage

Create a New Project

To create a new project, use the following command:

fast-hard create_project <project_name> --structure <structure> --database <database>
  • <project_name>: The name of your new project.
  • --structure: Choose the folder structure (mvc or use_cases).
  • --database: Choose the database (sqlite, mysql, postgresql, or mongodb).

Example:

fast-hard create_project my_new_project --structure mvc --database mysql

This will generate a new FastAPI project with the following structure:

my_new_project/
├── app/
│   ├── __init__.py
│   ├── main.py
│   ├── models/
│   ├── schemas/
│   ├── routes/
│   ├── tests/
│   ├── config/
│   └── alembic/
│       ├── env.py
│       ├── script.py.mako
│       └── versions/
├── requirements.txt
├── .env
├── .gitignore
├── alembic.ini
└── README.md

Add an MVC Structure

To add an MVC structure to an existing project (or create a new one if it doesn't exist), use:

fast-hard create_mvc <project_name>

This will add the following folders under the app directory:

my_new_project/
├── app/
│   ├── controllers/
│   ├── views/
│   └── models/

Add a Use Case Structure

To add a use case structure to an existing project (or create a new one if it doesn't exist), use:

fast-hard create_use_cases <project_name>

This will add the following folder under the app directory:

my_new_project/
├── app/
│   ├── use_cases/

Run the Project

To run the project, navigate to the project directory and start the FastAPI server:

cd my_new_project
pip install -r requirements.txt
cd app
uvicorn main:app --reload

Open your browser at:

http://127.0.0.1:8000/

You should see the message:

{
  "Hello": "World"
}

Database Configuration

The .env file will be configured based on the chosen database:

SQLite

DATABASE_URL=sqlite:///./test.db

MySQL

DATABASE_URL=mysql+pymysql://user:password@localhost/dbname

PostgreSQL

DATABASE_URL=postgresql://user:password@localhost/dbname

MongoDB

DATABASE_URL=mongodb://localhost:27017/

Make sure to update the .env file with your actual database credentials.


Link PyPI

Fast Hard on PyPI


Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.


License

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

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

fast_hard-0.1.3.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

fast_hard-0.1.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file fast_hard-0.1.3.tar.gz.

File metadata

  • Download URL: fast_hard-0.1.3.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for fast_hard-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3df6457ec6fab0830b651af799ecf3a20410c41c57763ad6bba620e89d9320f0
MD5 6824e647d6258d8494b9da936e160548
BLAKE2b-256 b3ee23ba729b0401345a157e2bdfa001a505e48a122a3414bb8a3f38a82ce78f

See more details on using hashes here.

File details

Details for the file fast_hard-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fast_hard-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for fast_hard-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 befdad49e61584322cf537f842ec281b24444887e5550c8694cb30b50272739a
MD5 3d5197538629b5fa2cd8fdfb997926c8
BLAKE2b-256 3ee4436f96b1ba12540f0f0c78bdf737ca06dc028654286cc3ebedd8b481c79a

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