Please send your PRs to JWoC_Dev branch and NOT to master
.
Either visit backend API and use Swagger or use the scripts present in scripts
folder.
For using the scripts, set appropriate environment variables first.
Master
branch is linked with the main server by Midgard. Any commits pushed to this branch will be instantly deployed in production.
A manual deployment can also be triggered after going to the URL.
NOTE: Any changes that require change in environment variables or require migration should be done manually after logging into the server.
This is the common backend for Tech-Ambit web and android application.
.
├── app
│ ├── __init__.py
│ ├── main
│ │ ├── config.py
│ │ ├── controller
│ │ │ ├── auth_controller.py
│ │ │ ├── __init__.py
│ │ │ └── user_controller.py
│ │ ├── __init__.py
| | ├── logging_config.py
│ │ ├── models
│ │ │ ├── __init__.py
│ │ │ └── user.py
│ │ ├── service
│ │ │ ├── auth_helper.py
│ │ │ ├── __init__.py
│ │ │ └── user_service.py
│ │ └── util
│ │ └── __init__.py
│ └── test
│ └── __init__.py
|── .env
├── manage.py
├── Makefile
├── Pipfile
├── Pipfile.lock
├── README.md
└── requirements.txt
Collect all similar endpoints in the app/controller
folder. Use different files for logically dissimilar endpoints.
NOTE: Most of the general config is loaded into the environment from the .env file which should be created from the provided .env.template
Please use pipenv.
To install pipenv run pip install pipenv
.
Use a separate virtual environment by running pipenv shell --three
and then run pipenv install
to install dependencies.
NOTE: Run pipenv install --dev
to install all dependencies including development.
To install a new dependency, use pipenv install <pkg-name>
. This will update Pipfile and Pipfile.lock
NOTE: use the flag --dev
if it is a development dependency.
To upgrade a package, use pipenv install --selective-upgrade <pkg-name>
.
Whenever a new dependency is added, be sure to run
pip freeze > requirements.txt
Mention dependency change in the commit message.
We serve most of the common commands collected in a Makefile.
make install
make tests
make run
make all
To build the container, make sure that the Dockerfile is present and run docker build -t common-backend:latest .
To run the application from the docker container, run docker run common-backend ARG
where ARG
can be db
, run, test
, shell
or runserver
.
For more information, run docker run common-backend --help
.
If this is the first time that flask-migrate is being installed or run alongside existing database, use the
following command to create a head stamp in your database:
python manage.py db stamp head
It is recommeneded to perform Database upgrades, whenever database schema is updated, using the below commands:
python manage.py db upgrade
Remove the last database update using the below commands:
python manage.py db downgrade
Whenever a database model's schema is update, run the following command to generate migrations for it.
python manage.py db migrate