## Fast Template
Easily generate a template for your [FastAPI](http://fastapi.tiangolo.com) applications, complete with JWT authentication and Google sign-in.
### Installation
You can install Fast Template via `pip`:
```sh
pip install fast-template-python
```
Or using `poetry`:
```sh
poetry add fast-template-python
```
### Usage
To initialize a project in an existing folder:
```sh
fast-template init project_name .
```
To create a new project:
```sh
fast-template init project_name
```
Once the template is set up, you'll need to create a `.env` file as required by the `settings.py` file (feel free to modify it to suit your needs).
An example of a `.env` is:
```
POSTGRES_URL = postgresql+asyncpg://postgres@localhost/your_db_name
ACCESS_TOKEN_SECRET = Your-Access-Token-Secret
REFRESH_TOKEN_SECRET = Your-Refresh-Token-Secret
RESET_PASSWORD_SECRET = Your-Reset-Password-Secret
SECRET_KEY = Your-Secret-Key
JWT_ALGORITHM = HS256
MAIL_USERNAME = yourname@yourmail.com
MAIL_FROM_NAME = Your-Name
MAIL_PASSWORD = yourmailpassword
MAIL_FROM = yourname@yourmail.com
MAIL_PORT = 000 # 587 for gmail
MAIL_SERVER = your_mail_server # smtp.gmail.com for gmail
REDIS_HOST = localhost
REDIS_PORT = 6379
GOOGLE_CLIENT_ID = YOUR_GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET = YOUR_GOOGLE_CLIENT_SECRET
GOOGLE_REDIRECT_URI = https://yourdomain.com/auth/google/callback
```
#### Migrations
You can set up database migrations using Alembic:
```sh
alembic init —template async migrations
```
For more information on using Alembic, check the [official tutorial](https://alembic.sqlalchemy.org/en/latest/tutorial.html#creating-an-environment).
### Features
#### Authentication
- JWT-based authentication is built-in.
- Google sign-in is fully integrated, right down to the database layer.
#### Extensible Folder Structure
The folder structure is designed to be modular and scalable, inspired by Philip Okiokio ([LinkedIn](https://www.linkedin.com/in/philip-okiokio/), [GitHub](https://github.com/philipokiokio)). It promotes loose coupling and clean separation of concerns.
Each operation is handled by three main layers:
1. **Router Layer**: Defines FastAPI routes.
2. **Service Layer**: Contains the business logic.
3. **Database Layer**: Manages database interactions.
The data flow is structured as follows:
```
Router Layer → Service Layer → Database Layer
```
The service layer handles the data exchange between the router and the database, while the router serializes requests and passes them to the service.
The folder structure on running
```sh
fast-template init totrac
```
is
```md
TOTRAC
├── database
│ ├── db_handlers
│ │ ├── __init__.py
│ │ ├── auth_db_handler.py
│ ├── orms
│ │ ├── __init__.py
│ │ ├── auth_orm.py
├── job_manager
│ ├── email
│ │ ├── mailer.py
│ ├── job_runner.py
├── root
│ ├── templates
│ │ ├── auth
│ │ │ ├── info_email_template.html
│ ├── utils
│ │ ├── abstract_base.py
│ │ ├── base_models_abstract.py
│ ├── app_routers.py
│ ├── app.py
│ ├── arq_worker.py
│ ├── constants.py
│ ├── database.py
│ ├── logging.py
│ ├── redis_manager.py
│ ├── settings.py
├── routers
│ ├── __init__.py
│ ├── auth_router.py
│ ├── miscellaneous_router.py
├── schemas
│ ├── __init__.py
│ ├── auth_schemas.py
│ ├── error_messages_schema.py
│ ├── file_upload_schema.py
│ ├── response_info_schema.py
├── services
│ ├── utils
│ │ ├── auth_utils.py
│ │ ├── exceptions.py
│ │ ├── file_downloader.py
│ │ ├── file_uploader_utils.py
│ │ ├── google_auth_utils.py
│ │ ├── token_utils.py
│ ├── auth_services.py
│ ├── miscellaneous_services.py
├── venv
├── __init__.py
├── .gitignore
├── make_db_migrations.py
├── Makefile
├── pyproject.toml
├── Readme.md
├── requirements.txt
```
#### Pre-configured Services
The root folder contains core services required for the backend, including:
1. Database setup
2. Redis caching
3. Email templates
4. Background workers (using ARQ)
5. Logging configuration
6. Application settings
#### Schema and Database Layers
- **Schema**: Pydantic models for serialization/deserialization, organized by feature (e.g., authentication schemas are in the `auth` folder).
- **Database**: Handlers and ORM integration using [SQLAlchemy](http://sqlalchemy.org).
### Work in Progress
This package is a work in progress, created to streamline the setup of backend projects.
### 🐛 Bugs/Feature Requests
Contributions are welcome! Feel free to open a pull request or an issue for feature requests or bug reports.
Raw data
{
"_id": null,
"home_page": null,
"name": "fast-template-python",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "fastapi, template, python, fast-template-python",
"author": "Peter Akande",
"author_email": "akandepeter86@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/15/7a/5695517f3624fb5b0a997e6e059fafcb62b056a945e942b8928b462c8081/fast_template_python-0.1.4.tar.gz",
"platform": null,
"description": "## Fast Template\n\nEasily generate a template for your [FastAPI](http://fastapi.tiangolo.com) applications, complete with JWT authentication and Google sign-in.\n\n### Installation\n\nYou can install Fast Template via `pip`:\n\n```sh\npip install fast-template-python\n```\n\nOr using `poetry`:\n\n```sh\npoetry add fast-template-python\n```\n\n### Usage\n\nTo initialize a project in an existing folder:\n\n```sh\nfast-template init project_name .\n```\n\nTo create a new project:\n\n```sh\nfast-template init project_name\n```\n\nOnce the template is set up, you'll need to create a `.env` file as required by the `settings.py` file (feel free to modify it to suit your needs).\nAn example of a `.env` is:\n```\nPOSTGRES_URL = postgresql+asyncpg://postgres@localhost/your_db_name\n\nACCESS_TOKEN_SECRET = Your-Access-Token-Secret\nREFRESH_TOKEN_SECRET = Your-Refresh-Token-Secret\nRESET_PASSWORD_SECRET = Your-Reset-Password-Secret\n\nSECRET_KEY = Your-Secret-Key\n\nJWT_ALGORITHM = HS256\n\nMAIL_USERNAME = yourname@yourmail.com\nMAIL_FROM_NAME = Your-Name\nMAIL_PASSWORD = yourmailpassword\nMAIL_FROM = yourname@yourmail.com\nMAIL_PORT = 000 # 587 for gmail\nMAIL_SERVER = your_mail_server # smtp.gmail.com for gmail\n\nREDIS_HOST = localhost\nREDIS_PORT = 6379\n\nGOOGLE_CLIENT_ID = YOUR_GOOGLE_CLIENT_ID\nGOOGLE_CLIENT_SECRET = YOUR_GOOGLE_CLIENT_SECRET\nGOOGLE_REDIRECT_URI = https://yourdomain.com/auth/google/callback\n```\n\n#### Migrations\n\nYou can set up database migrations using Alembic:\n\n```sh\nalembic init \u2014template async migrations\n```\n\nFor more information on using Alembic, check the [official tutorial](https://alembic.sqlalchemy.org/en/latest/tutorial.html#creating-an-environment).\n\n### Features\n\n#### Authentication\n- JWT-based authentication is built-in.\n- Google sign-in is fully integrated, right down to the database layer.\n\n#### Extensible Folder Structure\nThe folder structure is designed to be modular and scalable, inspired by Philip Okiokio ([LinkedIn](https://www.linkedin.com/in/philip-okiokio/), [GitHub](https://github.com/philipokiokio)). It promotes loose coupling and clean separation of concerns.\n\nEach operation is handled by three main layers:\n1. **Router Layer**: Defines FastAPI routes.\n2. **Service Layer**: Contains the business logic.\n3. **Database Layer**: Manages database interactions.\n\nThe data flow is structured as follows:\n\n```\nRouter Layer \u2192 Service Layer \u2192 Database Layer\n```\n\nThe service layer handles the data exchange between the router and the database, while the router serializes requests and passes them to the service.\n\nThe folder structure on running\n```sh\nfast-template init totrac\n```\nis\n```md\nTOTRAC\n\u251c\u2500\u2500 database\n\u2502 \u251c\u2500\u2500 db_handlers\n\u2502 \u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u2502 \u251c\u2500\u2500 auth_db_handler.py\n\u2502 \u251c\u2500\u2500 orms\n\u2502 \u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u2502 \u251c\u2500\u2500 auth_orm.py\n\u251c\u2500\u2500 job_manager\n\u2502 \u251c\u2500\u2500 email\n\u2502 \u2502 \u251c\u2500\u2500 mailer.py\n\u2502 \u251c\u2500\u2500 job_runner.py\n\u251c\u2500\u2500 root\n\u2502 \u251c\u2500\u2500 templates\n\u2502 \u2502 \u251c\u2500\u2500 auth\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 info_email_template.html\n\u2502 \u251c\u2500\u2500 utils\n\u2502 \u2502 \u251c\u2500\u2500 abstract_base.py\n\u2502 \u2502 \u251c\u2500\u2500 base_models_abstract.py\n\u2502 \u251c\u2500\u2500 app_routers.py\n\u2502 \u251c\u2500\u2500 app.py\n\u2502 \u251c\u2500\u2500 arq_worker.py\n\u2502 \u251c\u2500\u2500 constants.py\n\u2502 \u251c\u2500\u2500 database.py\n\u2502 \u251c\u2500\u2500 logging.py\n\u2502 \u251c\u2500\u2500 redis_manager.py\n\u2502 \u251c\u2500\u2500 settings.py\n\u251c\u2500\u2500 routers\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 auth_router.py\n\u2502 \u251c\u2500\u2500 miscellaneous_router.py\n\u251c\u2500\u2500 schemas\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 auth_schemas.py\n\u2502 \u251c\u2500\u2500 error_messages_schema.py\n\u2502 \u251c\u2500\u2500 file_upload_schema.py\n\u2502 \u251c\u2500\u2500 response_info_schema.py\n\u251c\u2500\u2500 services\n\u2502 \u251c\u2500\u2500 utils\n\u2502 \u2502 \u251c\u2500\u2500 auth_utils.py\n\u2502 \u2502 \u251c\u2500\u2500 exceptions.py\n\u2502 \u2502 \u251c\u2500\u2500 file_downloader.py\n\u2502 \u2502 \u251c\u2500\u2500 file_uploader_utils.py\n\u2502 \u2502 \u251c\u2500\u2500 google_auth_utils.py\n\u2502 \u2502 \u251c\u2500\u2500 token_utils.py\n\u2502 \u251c\u2500\u2500 auth_services.py\n\u2502 \u251c\u2500\u2500 miscellaneous_services.py\n\u251c\u2500\u2500 venv\n\u251c\u2500\u2500 __init__.py\n\u251c\u2500\u2500 .gitignore\n\u251c\u2500\u2500 make_db_migrations.py\n\u251c\u2500\u2500 Makefile\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 Readme.md\n\u251c\u2500\u2500 requirements.txt\n\n```\n\n#### Pre-configured Services\nThe root folder contains core services required for the backend, including:\n1. Database setup\n2. Redis caching\n3. Email templates\n4. Background workers (using ARQ)\n5. Logging configuration\n6. Application settings\n\n#### Schema and Database Layers\n- **Schema**: Pydantic models for serialization/deserialization, organized by feature (e.g., authentication schemas are in the `auth` folder).\n- **Database**: Handlers and ORM integration using [SQLAlchemy](http://sqlalchemy.org).\n\n### Work in Progress\nThis package is a work in progress, created to streamline the setup of backend projects.\n\n### \ud83d\udc1b Bugs/Feature Requests\n\nContributions are welcome! Feel free to open a pull request or an issue for feature requests or bug reports.\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Easily generate a template for your Fastapi applications, complete with JWT authentication and Google sign-in",
"version": "0.1.4",
"project_urls": null,
"split_keywords": [
"fastapi",
" template",
" python",
" fast-template-python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "77f64cb5c378f3ff58824623314519f869379cf6ca2afe4e55bb94d8729d57f9",
"md5": "4d3eaacd66e74454de056bc0810456bb",
"sha256": "b60102d16aa50269deef18d81e6761546c889851843b680e121d2077bfa9782d"
},
"downloads": -1,
"filename": "fast_template_python-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4d3eaacd66e74454de056bc0810456bb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 36583,
"upload_time": "2024-10-18T23:37:53",
"upload_time_iso_8601": "2024-10-18T23:37:53.053076Z",
"url": "https://files.pythonhosted.org/packages/77/f6/4cb5c378f3ff58824623314519f869379cf6ca2afe4e55bb94d8729d57f9/fast_template_python-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "157a5695517f3624fb5b0a997e6e059fafcb62b056a945e942b8928b462c8081",
"md5": "0e55edd0ae37138a44c1ef23de0362fa",
"sha256": "861939349bc5c1196915db7abf5296bac6300ec55f7595b945b070240ed26fa8"
},
"downloads": -1,
"filename": "fast_template_python-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "0e55edd0ae37138a44c1ef23de0362fa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 24048,
"upload_time": "2024-10-18T23:37:54",
"upload_time_iso_8601": "2024-10-18T23:37:54.979188Z",
"url": "https://files.pythonhosted.org/packages/15/7a/5695517f3624fb5b0a997e6e059fafcb62b056a945e942b8928b462c8081/fast_template_python-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-18 23:37:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "fast-template-python"
}