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
.envfile for environment variables. - Sets up Alembic for database migrations.
- Provides a simple
main.pywith 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 (mvcoruse_cases).--database: Choose the database (sqlite,mysql,postgresql, ormongodb).
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
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.
Metadata
Release files for fast-hard 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fast_hard-0.1.3.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fast_hard-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.4 kB
Release files / fast_hard-0.1.3.tar.gz
| Download URL | fast_hard-0.1.3.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3df6457ec6fab0830b651af799ecf3a20410c41c57763ad6bba620e89d9320f0
|
|
BLAKE2b-256 checksum How to use checksums |
b3ee23ba729b0401345a157e2bdfa001a505e48a122a3414bb8a3f38a82ce78f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / fast_hard-0.1.3-py3-none-any.whl
| Download URL | fast_hard-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
befdad49e61584322cf537f842ec281b24444887e5550c8694cb30b50272739a
|
|
BLAKE2b-256 checksum How to use checksums |
3ee4436f96b1ba12540f0f0c78bdf737ca06dc028654286cc3ebedd8b481c79a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|