Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akmamun/fastapi-sql-boilerplate
A FastAPI and SQLAlchemy Boilerplate for Rapid API Development with Async Database Support
https://github.com/akmamun/fastapi-sql-boilerplate
asynchronous asyncpg fastapi sqlalchemy
Last synced: 28 days ago
JSON representation
A FastAPI and SQLAlchemy Boilerplate for Rapid API Development with Async Database Support
- Host: GitHub
- URL: https://github.com/akmamun/fastapi-sql-boilerplate
- Owner: akmamun
- Created: 2023-11-28T09:02:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-01T18:13:05.000Z (about 1 year ago)
- Last Synced: 2024-10-16T20:01:50.626Z (3 months ago)
- Topics: asynchronous, asyncpg, fastapi, sqlalchemy
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI MicroService with Docker and Asynchronous SQLAlchemy
This repository provides a template for building a FastAPI microservice using Docker with asynchronous SQLAlchemy for efficient database operations.
### Installation Instructions
**Using Docker:**
- To run the service using Docker, use the following command:
```sh
sudo docker-compose up --build
```**Run Locally:**
- Create a [virtual environment](https://docs.python.org/3/library/venv.html)
- Install the Python dependencies with
```sh
pip install -r requirements.txt
```
- Copy the .env.example file as .env
```sh
cp .env.example .env
```
- Ensure that you fill in all the valid environment properties in the .env file.## Setup and Configuration:
Please note that when forking and intending to use it, follow instruction
- Delete the `example_app_name` folder
- Remove the line `from example_app_name.routes import routers` in `main.py`Your setup is now ready for smooth use.
### Run Locally
- To run the service locally, use the following command:
```sh
uvicorn main:app --reload
```### Run Docker Compose for Production Build
- Ensure that you have [Docker](https://docs.docker.com/engine/install) and [Docker Compose](https://docs.docker.com/compose/install/) installed## Project Structure
```
├── app_name
│ ├── controllers
│ │ └── __init__.py
│ ├── models
│ │ └── __init__.py
│ ├── repositories
│ │ └── __init__.py
│ ├── routes.py
│ └── tests
│ └── __init__.py
├── config
│ ├── config.py
│ └── db.py
├── db
│ └── alchemy_repository.py
├── docker-compose.yml
├── Dockerfile
├── example_app_name
│ ├── controllers
│ │ ├── __init__.py
│ │ └── item_controller.py
│ ├── models
│ │ └── item_models.py
│ ├── repositories
│ │ ├── __init__.py
│ │ └── item_repository.py
│ ├── routes.py
│ └── tests
│ └── __init__.py
├── helpers
│ ├── env.py
│ └── pagination.py
├── locust.py
├── main.py
├── README.md
├── requirements.txt
└── scripts
└── migrate.py
```