Fastapi Clean Architecture boilerplate.
- Python 3.11
- Pipenv for managing package / requirements
Docs url will be put in here in advance
Copy .env.example
to .env
then install requirements:
pipenv install
# or
pip install -r requirements.txt
Start development server
pipenv run uvicorn app.main:app --reload
# or
uvicorn app.main:app --reload
We use alembic to manage database migrations.
pipenv run alembic revision -m "{your migration message}"
# or
alembic revision -m "{your migration message}"
Then the migration file will be generated at ./migrations/versions/{timestamp}_create_todos_table.py
directory
pipenv run alembic upgrade head
# or
alembic upgrade head
pipenv run alembic downgrade -1
# or
alembic downgrade -1
Test files will be placed on ./tests
directory. All controllers test should be placed on ./tests/api
directory.
Create database called my_test_db
on your local machine.
To run test you can use pytest
command to do the job
# run all tests
pipenv run pytest
# or
pytest
# run specific test file
pipenv run pytest ./tests/path_to_your_test_file.py
# or
pytest ./tests/path_to_your_test_file.py
# run with verbose
pipenv run pytest -v
# or
pytest -v
# run with complete log
pipenv run pytest --capture=no
# or
pytest --capture=no
docker build -t fastapi-clean-architecture .
docker run -d -p 8000:8000 fastapi-clean-architecture --env-file .env