- Python 3.9
- MySQL
- Airflow
- RabbitMQ
Regarding the available endpoints, you can view them in the Swagger documentation at this link
You can also view the list of endpoints made available by the API through the Swagger documentation stored in the documentation folder
Regarding the form of authentication accepted by the API, we have three ways of using it, the first is through basic authentication (Username and password), the second is through Token authentication that allows you to log in and create a token that can be used during requests and the third is Session Authentication, native to Django
Until now, the messaging system is only available for installation on-premises, I intend to automate its installation with Docker in the next updates
-
Clone the repository on your device
-
Move to the project repository
-
Create the .env.coordinates file, in this file configure the database and API information to the microservice (Guide yourself through the environment variables section)
-
Create the .env.rental file, in this file configure the database and API information to the main API (Guide yourself through the environment variables section)
-
Run the docker compose file to install the application in development mode, in this form, the basic settings have already been set and some initial data will be generated for you to test the API
docker-compose up -d --build
- Clone the repository on your device
- Go to the project directory
- Create a virtual environment on your device
python -m venv venv
- Run the virtual environment, if you are using the Windows operating system, use the following command
venv/Scripts/activate
But if you use Linux OS or MAC use the command below
source venv/bin/activate
- Install the libraries saved in the requirements.txt file, if you are using the PIP package manager you can use the following command
pip install -r RentalAPI/requirements.txt pip install -r CoordinatesAPI/requirements.txt
-
Create the .env.coordinates file, in this file configure the database and API information to the microservice (Guide yourself through the environment variables section)
-
Run the file to start the database
python CoordinatesAPI/init_db.py
- Run the file to create an access key to be used in the main API, copy the token printed in the terminal
python CoordinatesAPI/create_access_token.py
- Run the microservice application
flask --app CoordinatesAPI/address run
-
Create the .env.rental file, in this file configure the database and API information to the main API (Guide yourself through the environment variables section)
-
Create the database according to the settings established in the .env.rental file
-
Make sure you have mysql installed on your machine and create the “vehicle rental” table using the command below
CREATE SCHEMA
rental-of-vehicles
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ;
- Run the following command to create the API tables
python RentalAPI/manage.py migrate
- Start the API through this command
python RentalAPI/manage.py runserver
-
Go to the Project directory
-
Create a virtual environment on your device
python -m venv rabbitmq_venv
- Run the virtual environment, if you are using the Windows operating system, use the following command
rabbitmq_venv/Scripts/activate
But if you use Linux OS or MAC use the command below
source rabbitmq_venv/bin/activate
- Install the libraries saved in the requirements.txt file, if you are using the PIP package manager you can use the following command
pip install -r Consumers/requirements.txt
-
Create the .env.consumers (Guide yourself through the environment variables section), regarding the email password, read Google's documentation on how to create an application password.
-
Run as many instances as you want of the WhatsApp email consumer,If you replace the templates in step 7 you need to replace the third parameter that represents the subjects with the set of names of your templates separated by ";"
python consumers/consumer.py 'e-mail' 'email_queue' 'appointment;devolution;late_devolution;devolution'
python consumers/consumer.py 'whatsapp' 'whatsapp_queue' 'appointment;devolution;late_devolution;devolution'
You need to make sure you have Airflow running on your machine and then place the file in the dags folder and create a config.py in the dag folder with the next configs.
Parameters | Characteristics |
---|---|
API_URL | Main API URL |
ACCESS_TOKEN | Access key created in the main API for use by external software (MESSAGING_SYSTEM_ACCESS_TOKEN) |
Parameters | Characteristics | Example |
---|---|---|
SECRET_KEY_COORDINATES | ||
COORDINATES_DATABASE_URI | Path to sqlite database file | sqlite:database.db |
GOOGLE_MAPS_SECRET_KEY | Google secret key to access the geocoding service |
Parameters | Characteristics | Example |
---|---|---|
SECRET_KEY_RENTAL | ||
COORDINATES_API_KEY | Microservice access key, paste the access key created in step 8 if you are running on-premises or just ignore if you are using docker-compose | |
COORDINATES_URL | URL to access the microservice | If you are running locally on port 5000, the value will be: http://127.0.0.1:5000/v1/distance/addresses or if you are running using docker set it to http://distance-microservice:5000/v1/distance/addresses |
DEBUG | Boolean value | 0 |
DJANGO_ALLOWED_HOSTS | Local installation: localhost 127.0.0.1 [::1] | |
SQL_ENGINE | Database used | Mysql config (Local installation/ Docker-default): django.db.backends.mysql |
SQL_DATABASE | Name of the database | Docker-default: rental-of-vehicles |
SQL_USER | Name of the database user | Docker-default: rental_database_user |
SQL_PASSWORD | Password of the user | Docker-default: rental_database_password |
SQL_HOST | Local installation/ Docker-default: 127.0.0.1 | |
SQL_PORT | Port used | Commonly used port for mysql (Docker-default): 3306 |
MESSAGING_SYSTEM_ACCESS_TOKEN | Key to provide third-party software access to some specific endpoints of the Main API, in this project this Key is used for the messaging system |
Parameters | Characteristics | Example |
---|---|---|
PORT | 465 | |
PASSWORD | Password for use in the application provided by the email provider after activation in the settings | |
Email that will be used to send messages | my_email@email.com |