Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mirzadelic/fastapi-starter-project
FastAPI Starter Project with SQLModel and Alembic
https://github.com/mirzadelic/fastapi-starter-project
alembic docker fastapi sqlmodel
Last synced: 3 months ago
JSON representation
FastAPI Starter Project with SQLModel and Alembic
- Host: GitHub
- URL: https://github.com/mirzadelic/fastapi-starter-project
- Owner: mirzadelic
- Created: 2021-12-06T23:03:00.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-27T15:39:23.000Z (about 2 years ago)
- Last Synced: 2024-08-01T00:42:33.864Z (6 months ago)
- Topics: alembic, docker, fastapi, sqlmodel
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 107
- Watchers: 3
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-fastapi - fastapi-starter-project - A project template which uses FastAPI, SQLModel, Alembic, Pytest, Docker, GitHub Actions CI. (Projects / Boilerplate)
- awesome-fastapi - fastapi-starter-project - A project template which uses FastAPI, SQLModel, Alembic, Pytest, Docker, GitHub Actions CI. (Projects / Boilerplate)
README
# FastAPI Starter Project
Project includes:
- `fastapi`
- `sqlmodel`
- `alembic`##
## Models
Check db/models and migrations, there is one example.
## Using docker
Setup env variables in `app/core/.env` using `app/core/.env-example`
#### Install and run
```bash
docker-compose up -d web# you can track logs with:
docker-compose logs -f --tail=100 web
```Go to: http://localhost:8000/api/docs/
#### Migrations
Create migrations
```bash
docker-compose exec web alembic revision --autogenerate -m "Example model"
```Apply migrations
```bash
docker-compose exec web alembic upgrade head
```#### Tests
Run tests
```bash
docker-compose exec web pytest .
```## Without docker
#### Install
```bash
cd app/
pip install -r requirements/development.txt
```Setup env variables in `app/core/.env`.
#### Run
```bash
cd app/
python app/server.py
```Go to: http://localhost:8000/api/docs/
#### Migrations
Create migrations
```bash
alembic revision --autogenerate -m "Example model"
```Apply migrations
```bash
alembic upgrade head
```#### Tests
Run tests
```bash
pytest .
```## Environment Variables
To run this project, you will need to add the following environment variables to your app/core/.env file
`BASE_URL` - default: http://localhost:8000
`RELOAD` - default: false
`DB_HOST` - default: localhost
`DB_PORT` - default: 5432
`DB_USER` - default: postgres
`DB_PASS` - default: postgres
`DB_BASE` - default: db
`DB_ECHO` - default: false