GithubHelp home page GithubHelp logo

codyle50 / truck-management-django-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 99 KB

This is a management solution for trucking companies to keep track of their fleet, trucks, drivers, and tax reports. This repo contains the Django backend API developed using Django-Rest-Framework

Dockerfile 0.56% Shell 0.38% Python 95.20% HTML 3.87%
django django-backend django-react django-rest-framework docker management-system nginx postgresql python reactjs-frontend

truck-management-django-api's Introduction

IFTA Filling

IF Logo

Python version Django version Django-RestFramework

Table of Contents

Description

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.

  • Some useful notes about the application:

    • 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.
  • How do subscriptions work?

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.

Install (Run) with Docker

About the Builds and Images in use:

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.

Runing Docker-Compose

  1. Clone the repo:

    git clone https://github.com/Ceci-Aguilera/ifta_filing_django_api.git
  2. Configure the environment variables.

    1. 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
    2. 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
    3. 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
    4. The DOCKER_SECRET_KEY is the django secret key. To generate a new one see: Stackoverflow Link

    5. 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:
        1. 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.
        2. Go to Developer > API Keys, and copy both the Publishable Key and the Secret Key.
    6. 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.

  3. Run docker-compose:

    docker-compose up --build
  4. Congratulations =) !!! The App should be running in localhost:80

  5. (Optional step) To create a super user run:

    docker-compose run api ./manage.py createsuperuser

Installation without Docker

  1. Clone the repo:

    git clone https://github.com/Ceci-Aguilera/truck_signs_api.git
  2. Configure a virtual env and set up the database. See Link for configuring Virtual Environment and Link for Database setup.

  3. Configure the environment variables.

    1. 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
    2. 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
    3. For the database, the default configurations should be:

      DB_NAME=iftadb
      DB_USER=iftauser
      DB_PASSWORD=SuperIfta123!
      DB_HOST=localhost
      DB_PORT=5432
    4. The SECRET_KEY is the django secret key. To generate a new one see: Stackoverflow Link

    5. 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:
        1. 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.
        2. Go to Developer > API Keys, and copy both the Publishable Key and the Secret Key.
    6. 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.

  4. Run the migrations and then the app:

    python manage.py migrate
    python manage.py runserver
  5. Congratulations =) !!! The App should be running in localhost:8000

  6. (Optional step) To create a super user run:

    python manage.py createsuperuser
    

Deploy on VPS

  1. Clone the repo:
    git clone https://github.com/Ceci-Aguilera/ifta_filing_django_api
  2. Install the dependencies:
    sudo apt-get update
    sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx
  3. Set up the postgresql database Setup Database
  4. Create an .env file and configure the environment variables
  5. Create a virtual env and activate it:
    virtualenv myprojectenv
    source myprojectenv/bin/activate
  6. Pip install the requirements:
    pip install -r requirements.txt
  7. Pip install gunicorn:
    pip install gunicorn
  8. Run the migrations and then test the the app:
    python manage.py migrate
    python manage.py runserver
  9. Complete the setup of the website with this Link
  10. Configure the CORS to allow the Frontend to make api calls. See Link

Useful Links

Postgresql Databse

Docker

Django and DRF

Miscellaneous

truck-management-django-api's People

Contributors

codyle50 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.