Skip to content

tim738745/zeva

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zero-Emission Vehicles

Facilitates online Zero-Emission Vehicle (ZEV) sales reporting by regulated parties (automakers), plus issuance and transfer of ZEV credits. This is to support compliance with the ZEV Act regulations that require increasing sales of ZEVs to reduce GHG emissions from vehicles in the province.

Project Architecture

The project is a typical we application, it has frontend, backend and database.

  • Frontend: Nodejs and React
  • Backend: Python and Django
  • Database: Postgresql 10 and Patroni
  • Object Storage: Minio
  • Application Monitoring: Nagios
  • Database Backup: BackupContainer
  • Cloud Platform: Openshift
  • Database Documentation: SchemaSpy

Development

Unfortunately we do not have a licence to use Docker Desktop at BC Gov. If you are on a mac here is a blogpost about how to setup Lima as an alternative solution for development purposes.

Backend

The backend and all services are setup to run via docker. To start everything up you can run in the project folder:

docker-compose up --build

This will start up a postgres database, a Django web app, and a MinIO service with a private bucket zeva

Add this entry to your /etc/hosts file:

127.0.0.1 minio

to view the database use: docker-compose exec db psql -U postgres postgres

Django

Django offers many helpful mangement commands out of the box. To be able to use these with docker you can access the python environment with bash:

docker-compose exec api bash

You can view Django Restframework's browseable api here: http://localhost:8000/api/

MinIO

You can view the contents of the bucket in MinIO by visiting http://localhost:9001/login. Use env variables MINIO_ROOT_USER and MINIO_ROOT_PASSWORD to login to the console. Default values are found in minio.env

We take advantage that MinIO is S3 compatible and use django-storages S3 backend for media files.

Auth

We are using a shared realm Keycloak client. Shared realm clients can be accessed and configured via Common Hosted Single Sign-on (CSS)

to access keycloak console on local, go to localhost:8888 when developing locally, you may want to assign different users to different profiles, for example, have a 'government' profile as well as a 'supplier' profile. To update keycloak profiles, go to the keycloak console (8888), then click users, then view all users. select one, then click attributes. Look at the database user_profiles table, find one that has an organization that matches what you want, or update one, then use that username as the 'Value' on keycloak. Different users have different permissions to view pages and complete actions.

Email

We are using CHES to send email. Documentation is available here

Deployment

We use Openshift to deploy our applications. Access the console here

There's training on Openshift offered by BCDevExchange. Check the schedule here

Git Process/ Rebasing

We use git for version control. Each developer has their own fork of the repo and works off of branches from there

Testing

backend tests will be recognized and run with other tests if they have follow this naming convention: test_[name].py eg. test_credit_transfers.py

to run tests use a terminal in the api container and type python manage.py test

or to run specific test files, point to the folder or file python manage.py test api.services.tests.test_credit_transfers.py

Project Pipeline

The project uses pull request based pipeline is supported by BCDK and follow the instructions at here to setup the pipeline.

Build and deploy

Application Setup on Openshift platforms

  • All templates are located under openshift/templates folder.
  • Follow the instructions here to setup The application on Openshift.

CI/CD

Build and deploy in Jenkins

Once Jenkins is up and running, it automatically builds pull requests and promote to dev, test and prod with confirmation. The Jenkins url can be found in Openshift under project's Networking->Routers.

Build and deploy in command line

  • Cd to .pipeline folder and run the following command line to build pull requests and deploy to environment.
    • $ npm run build -- --pr=pull-request-number --env=build
    • $ npm run deploy -- --pr=pull-request-number --env=dev/test/prod
  • When a pull request is closed or merged, all resources created for the pull request is removed by Jenkins automatically. They also can be remove the the following command.
    • $ npm run clean -- --pr=pull-request-number --env=build/dev/test/prod

License

Code released under the Apache License, Version 2.0.

About

zero emission vehicles

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 47.1%
  • Python 43.0%
  • Shell 3.6%
  • SCSS 2.3%
  • CSS 2.3%
  • PLpgSQL 0.4%
  • Other 1.3%