Template for API that uses PostgreSQL-database. Written in Python with FastAPI, asyncpg as database client, SQLModel as ORM
Included Alembic for database migrations
Users' passwords hashing with BCrypt and users authorization with access JWTs
-
Rename
.env.example
to.env
and fill fields- Fields:
DATABASE_URL (str): PostgreSQL-database URL JWT_SECRET (str): secret for JWTs signature ACCESS_TOKEN_EXPIRE (int): access JWTs expire time in seconds
-
Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Run app:
python src/main.py
- Build Docker image:
docker build . --tag api
- Run Docker image:
docker run -d api
- Run database migrations:
docker exec {container id} alembic upgrade head