- Python 3.9
- Docker
- Create a
.env
file by duplicating.env.example
. Put the values according to your system setup.- While setting up the DB, make sure to use
db
as the value for POSTGRES_HOST
- While setting up the DB, make sure to use
- Create a file to capture logs while development. The file path should be
logs/app.log
inside the project root directory. - You can run you application using a single command:
Note: The
docker compose up --build
--build
is only need when you make any dependencies changes in the project.
- Create a
.env
file by duplicating.env.example
. Put the values according to your system setup.- While setting up the DB, make sure to use
localhost
as the value for POSTGRES_HOST
- While setting up the DB, make sure to use
- Create a file to capture logs while development. The file path should be
logs/app.log
inside the project root directory. - Start a virtual environment
Note: if you dont have pipenv then install it using
pipenv shell
pip install pipenv
- Install necessary packages for development purposes locally using pipenv
pipenv install --dev
While doing development its good to follow best practices used in the industry. We have taken care of it by adding some tools for checking the sanity of your code when you make any commit to GitHub. To install these development tools, follow the steps mentioned below:
-
Install pre-commit and commit-linter to ensure that every time you make a commit the checks should be triggered.
pip install pre-commit pip install commit-linter
-
Start a virtual environment (Skip if you have installed application in local environment)
pipenv shell
Note: if you dont have pipenv then install it using
pip install pipenv
-
Install necessary packages for development purposes locally using pipenv (Skip if you have installed application in local environment)
pipenv install --dev
Note: Whenever the checks are running, make sure the you have started the virtual environment
To test the functionality of your code and test cases. Run the test cases using the below mentioned commands after creating virtual environment using pipenv.
- Run all the test cases
pytest .
- Run test cases of specific module
pytest tests/<module_name>
-
- Run a specific test cases of
pytest tests/<module_name>::<function_name>
Whenever you want to make any changes in the DB schema please follow the below provided steps
- Add or make changes to the models you want to update or create
- Create a new migration file using the below command
Note: For local environment, just run
docker-compose exec app pipenv run alembic revision --autogenerate -m "<details of the migration file changes>"
alembic revision --autogenerate -m "<details of the migration file changes>
- Run the migration to reflect the changes in the DB using the below command
Note: For local environment, just run
docker-compose exec app pipenv run alembic upgrade head
alembic upgrade head
- Database setup approach - Link