- Description
- Structure and Backend Functionalities
- Install (Run) with Docker
- Installation without Docker
- Deploy on VPS
- Useful Links
The project IFTA FILLING is a managing tool for truck owners to keeps track of the IFTA Taxes for their trucking business. This project has been merged into the IFTA ya! solution that targets truck owner-operators instead of fleet managers.
-
- The User Model was customized to match the needs of the business. For example, a Stripe Id was added for auto payments, and username was changed to the email. Other fields needed for security features were also added.
- Stripe SDK was used to manage the User's payments.
- django.core.mail is in use to manage the email sending functionality. While to manage the PDFs creation, the package xhtml2pdf is in use.
The owner of the truck buys a subscription which allows him to use the managing tools for a limited amount of time (measure in quarters as this is the natural way of submitting IFTA taxes). After this step, IFTA Filling becomes available for any driver of the company to use and for the truck owner. However, each subscription plan also comes with a maximum amount of trucks and drivers that can be managed at the time. Truck owners can expand their subscription time by auto-payments or making a manual payment, for both cases Stripe SDK is used.
NOTE: A driver can work for several truck owners and can also drive several trucks during a quarter.
There are currently 3 services in use: the api (Django App), the db (the postgrSQL database), and the nginx (Nginx configuration). - api: The Django Dockerfile is in the root directory, and it has an entrypoint file that connects the backend to the database and runs migrations as well as collects the statics. - db: This is built from the postgres:13-alpine image. The default environment variables are set in the docker-compose.yml file. - nginx: The default configuration for nginx is inside the nginx folder in the nginx.conf file.
-
Clone the repo:
git clone repository_link
-
Configure the environment variables.
-
Copy the content of the example env file that is inside the truck_signs_designs folder into a .env file:
cd ifta_filing_django_api/settings cp simple_env_config.env .env
-
The new .env file should contain all the environment variables necessary to run all the django app in all the environments. However, the only needed variables for docker to run are the following:
DOCKER_SECRET_KEY DOCKER_DB_NAME DOCKER_DB_USER DOCKER_DB_PASSWORD DOCKER_DB_HOST DOCKER_DB_PORT DOCKER_STRIPE_PUBLIC_KEY DOCKER_STRIPE_SECRET_KEY DOCKER_EMAIL_HOST_USER DOCKER_EMAIL_HOST_PASSWORD
-
For the database, the default configurations should be:
DOCKER_DB_NAME=docker_iftafilling_db DOCKER_DB_USER=docker_iftafillings_user DOCKER_DB_PASSWORD=docker_superiftafillinguser! DOCKER_DB_HOST=db DOCKER_DB_PORT=5432
-
The DOCKER_SECRET_KEY is the django secret key. To generate a new one see: Stackoverflow Link
-
The DOCKER_STRIPE_PUBLISHABLE_KEY and the DOCKER_STRIPE_SECRET_KEY can be obtained from a developer account in Stripe.
- To retrieve the keys from a Stripe developer account follow the next instructions:
- Log in into your Stripe developer account (stripe.com) or create a new one (stripe.com > Sign Up). This should redirect to the account's Dashboard.
- Go to Developer > API Keys, and copy both the Publishable Key and the Secret Key.
- To retrieve the keys from a Stripe developer account follow the next instructions:
-
The DOCKER_EMAIL_HOST_USER and the DOCKER_EMAIL_HOST_PASSWORD are the credentials to send emails from the website when a client asks for a PDF report.
-
-
Run docker-compose:
docker-compose up --build
-
Congratulations =) !!! The App should be running in localhost:80
-
(Optional step) To create a super user run:
docker-compose run api ./manage.py createsuperuser
-
Clone the repo:
git clone {repository link}
-
Configure a virtual env and set up the database. See Link for configuring Virtual Environment and Link for Database setup.
-
Configure the environment variables.
-
Copy the content of the example env file that is inside the truck_signs_designs folder into a .env file:
cd truck_signs_designs/settings cp simple_env_config.env .env
-
The new .env file should contain all the environment variables necessary to run all the django app in all the environments. However, the only needed variables for the development environment to run are the following:
SECRET_KEY DB_NAME DB_USER DB_PASSWORD DB_HOST DB_PORT STRIPE_PUBLIC_KEY STRIPE_SECRET_KEY EMAIL_HOST_USER EMAIL_HOST_PASSWORD
-
For the database, the default configurations should be:
DB_NAME=iftadb DB_USER=iftauser DB_PASSWORD=SuperIfta123! DB_HOST=localhost DB_PORT=5432
-
The SECRET_KEY is the django secret key. To generate a new one see: Stackoverflow Link
-
The STRIPE_PUBLISHABLE_KEY and the STRIPE_SECRET_KEY can be obtained from a developer account in Stripe.
- To retrieve the keys from a Stripe developer account follow the next instructions:
- Log in into your Stripe developer account (stripe.com) or create a new one (stripe.com > Sign Up). This should redirect to the account's Dashboard.
- Go to Developer > API Keys, and copy both the Publishable Key and the Secret Key.
- To retrieve the keys from a Stripe developer account follow the next instructions:
-
The EMAIL_HOST_USER and the EMAIL_HOST_PASSWORD are the credentials to send emails from the website when a client asks for a PDF report.
-
-
Run the migrations and then the app:
python manage.py migrate python manage.py runserver
-
Congratulations =) !!! The App should be running in localhost:8000
-
(Optional step) To create a super user run:
python manage.py createsuperuser
- Clone the repo:
git clone repository_link
- Install the dependencies:
sudo apt-get update sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx
- Set up the postgresql database Setup Database
- Create an .env file and configure the environment variables
- Create a virtual env and activate it:
virtualenv myprojectenv source myprojectenv/bin/activate
- Pip install the requirements:
pip install -r requirements.txt
- Pip install gunicorn:
pip install gunicorn
- Run the migrations and then test the the app:
python manage.py migrate python manage.py runserver
- Complete the setup of the website with this Link
- Configure the CORS to allow the Frontend to make api calls. See Link
- Setup Database: Digital Ocean Link for Django Deployment on VPS
- Docker Oficial Documentation
- Dockerizing Django, PostgreSQL, guinicorn, and Nginx:
- Django Official Documentation
- Generate a new secret key: Stackoverflow Link
- Modify the Django Admin:
- Small modifications (add searching, columns, ...): Link
- Modify Templates and css: Link from Medium
- Django Rest Framework Official Documentation
- More about Nested Serializers: Stackoverflow Link
- More about GenericViews: Testdriver.io Link
- Create Virual Environment with Virtualenv and Virtualenvwrapper: Link
- Configure CORS
- Setup Django with Cloudinary