Mentorship System is an application that allows women in tech to mentor each other, on career development topics, through 1:1 relations for a certain period. This is the Backend REST API for the Mentorship System.
This API is being used by 3 frontend projects currently being developed:
- android: anitab-org/mentorship-android
- iOS: anitab-org/mentorship-ios
- flutter: anitab-org/mentorship-flutter
Table of Contents
To setup the project locally read these wiki pages and follow the instructions:
The project runs on Python 3.
- Create a virtual environment:
virtualenv venv --python=python3
- Activate the virtual environment: For Git Bash Users:
source ./venv/Scripts/activate
For Windows Command Line Users:
venv\Scripts\activate
- Install all the dependencies in
requirements.txt
file:
pip install -r requirements.txt
- Make sure you create
.env
using.env.template
and update the values of corresponding environment variables or make sure you exported the following environment variables:
export FLASK_ENVIRONMENT_CONFIG=<local-or-dev-or-test-or-prod-or-stag>
export SECRET_KEY=<your-secret-key>
export SECURITY_PASSWORD_SALT=<your-security-password-salt>
export MAIL_DEFAULT_SENDER=<mail-default-sender>
export MAIL_SERVER=<mail-server>
export APP_MAIL_USERNAME=<app-mail-username>
export APP_MAIL_PASSWORD=<app-mail-password>
export MOCK_EMAIL=<True-or-False>
If you're testing any environment other than "local", then you have to also set these other variables:
export DB_TYPE=<database_type>
export DB_USERNAME=<database_username>
export DB_PASSWORD=<database_password>
export DB_ENDPOINT=<database_endpoint>
export DB_NAME=<database_name>
- Run the app:
python run.py
-
Navigate to http://localhost:5000 in your browser
-
When you are done using the app, deactivate the virtual environment:
deactivate
The project runs on Python 3.
- Create a virtual enviorntment:
virtualenv venv
- Activate the virtual environment:
source venv/bin/activate
- Install all the dependencies in
requirements.txt
file:
pip3 install -r requirements.txt
- Make sure you create
.env
using.env.template
and update the values of corresponding environment variables. Make sure you exported the following environment variables if you didn't adapt.env.template
in the.env
file:
export FLASK_ENVIRONMENT_CONFIG=<local-or-dev-or-test-or-prod-or-stag>
export SECRET_KEY=<your-secret-key>
export SECURITY_PASSWORD_SALT=<your-security-password-salt>
export MAIL_DEFAULT_SENDER=<mail-default-sender>
export MAIL_SERVER=<mail-server>
export APP_MAIL_USERNAME=<app-mail-username>
export APP_MAIL_PASSWORD=<app-mail-password>
export MOCK_EMAIL=<True-or-False>
If you're testing any environment other than "local", then you have to also set these other variables in the .env file.
export DB_TYPE=<database_type>
export DB_USERNAME=<database_username>
export DB_PASSWORD=<database_password>
export DB_ENDPOINT=<database_endpoint>
export DB_NAME=<database_name>
Use: printenv
to print the environment variables and check all configurations.
- Run the app with
python run.py
or:
export FLASK_APP=run.py
flask run
-
Navigate to http://localhost:5000 or the current server in which you are running(will be shown when app is running) in your browser.
-
When you are done using the app, deactivate the virtual environment:
deactivate
or use:
source deactivate
-
Make sure you exported the following environment variables to
.env
file -
Build docker image
docker build -t mentorship-backend:latest .
- Deploy Docker container ports must be mapped to the host machine port using '--publish' so they're visible.
docker run --env "FLASK_APP=run.py" --publish 5000:5000 mentorship-backend:latest
To run the unitests run the following command in the terminal (while the virtual environment is activated):
python -m unittest discover tests
We use Black to format code automatically so that we don't have to worry about clean and readable code. To install Black:
pip install black
To run black:
black .
You can learn more about this project through the documentation in the docs folder and on our Wiki.
- Language: Python 3
- Framework: Flask
- Flask Extensions: Flask-RESTX, Flask-SQLAlchemy, Flask-JWT-Extended, Flask-Mail
Here are some links to documentation for this project:
- How to use Backend Swagger UI and test PR guide contains a few resources for you to understand how to use the Swagger user interface provided by this app.
- Features Overview has a high level understanding of the features this application has.
- Future ideas for the project.
- Troubleshoot guide contains common isssues other contributors may run into in their setup.
- Quality Assurance test cases has test cases for each endpoint we have which you can use to learn about how each feature should work.
- CI/CD Process which explains the processes and tools involved in deploying new code.
- Code Organisation which explains the code organisation and architecture within the repository.
- User Authentication which is JSON Web Token (JWT) based and tells about the user authentication in the application.
Understand more about our technical decisions made along with this project development in Technical Decisions Wiki page.
Please read our Contributing guidelines, Code of Conduct and Reporting Guidelines
Please follow our Commit Message Style Guide and Coding Standards while sending PRs.
The repository has the following permanent branches:
-
master This contains the code which has been released.
-
develop This contains the latest code. All the contributing PRs must be sent to this branch. When we want to release the next version of the app, this branch is merged into the
master
branch. This is the branch that is used in the deployed version of the app on Heroku.
You can reach the maintainers and our community on AnitaB.org Open Source Zulip. If you are interested in contributing to the mentorship system, we have a dedicated stream for this project #mentorship-system, where you can ask questions and interact with the community, join with us!
Mentorship System is licensed under the GNU General Public License v3.0. Learn more about it in the LICENSE file.