larestrepo / clerk

Website used by new Anika clients to enter the facts of their case (backend)

Home Page:https://repairs.anikalegal.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clerk

Test

This site is used by new Anika clients who want to submit their legal problem. Clients may submit the facts of their case using a structured form interface. Their case file is then entered into our case managment system.

Depending on the job, office clerks might answer phones, filing, data processing, faxing, envelope stuffing and mailing, message delivery, running errands, sorting incoming mail and much more. (source)

Prerequisites for Local Development

You will need:

Getting Started

First, add a file called .env to the repository root with the following contents:

SENDGRID_API_KEY=
MAILCHIMP_API_KEY=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
ACTIONSTEP_CLIENT_ID=
ACTIONSTEP_CLIENT_SECRET=
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=

The values of these secrets will be provided to you if you need them.

Next, you want to build the Docker environment that we'll be using:

make build

Now you can set up your database with this reset script:

./scripts/db/reset.sh

To do this manually, you can to get a bash shell into the web container and run a Django database migration:

# Get a bash shell in the container
make bash

# Setup the development database for Django - you only need to do this once.
./manage.py migrate

# Create a local admin user
./manage.py createsuperuser

Finallly you can exit the container shell and bring up the webserver:

make web

Now you should be able to visit http://localhost:8000/admin and see the Clerk site.

You can also get a Django shell using:

make shell

Deployment

Deployment is done via a GitHub workflow here A deployment involves SSHing into the target server and updating the Docker Swarm config. Deployment must be manually triggered from GitHub. There are two environments to deploy to, test and prod:

When making a change or bugfix, you should:

  • create a feature branch from develop called feature/my-branch-name and test it locally
  • merge the branch into develop and trigger a release to the test environment
  • check your changes in the test environment
  • merge the develop into master trigger a release of your change to prod

Infrastructure

infra

There are two containers that run the application. A Django web server and a Django Q worker server. Both connect to a common database.

The application runs on Docker Swarm. The test and prod environments both run on a single AWS EC2 instance. That instance also contains the PostgreSQL database and a NGINX server which reverse proxies requests into the Docker containers.

Database backups are taken manually and stored in s3://anika-database-backups. Uploaded files are stored in s3://anika-clerk and s3://anika-clerk-test. Other than uploaded files and the contents of the PostgreSQL database, there is no important state on the EC2 instance or Docker images, which can be blown away and rebuilt at will. The only thing that will change is that EC2 instance IP address, which will need to be updated in CloudFlare.

DNS is handled by CloudFlare, which also does SSL termination for us.

Emails are sent using SendGrid.

Infra config can be found in the infra repo.

Logging and Error Reporting

Testing and Linting

This app has unit tests. They are not run in CI, but if you are making changes, please run them:

make test

The Python code is formatted with Black. To check the code with the linter run:

make lint

To automatically fix any linting errors, run:

make format

Docker

The environment for this app is built using Docker, and the app runs in production using Docker Swarm. Our The docker directory has the following files:

  • Dockerfile.base: base Docker image, used to build anikalaw/clerkbase
  • Dockerfile: final Docker image, used to build anikalaw/clerk
  • docker.compose.local.yml: Docker Compose config for local development
  • docker.compose.staging.yml: Docker Swarm config for test environment
  • docker.compose.prod.yml: Docker Swarm config for prod environment

Twilio

We are using Twilio to handle inbound phone calls. To test Twilio locally:

  • Ensure you have access to the Anika Twilio account
  • Ensure you have set the correct Twilio envars in your .env file (see "Getting Started" section)
  • Start the Django server
  • Install and run ngrok for port 8000: ngrok http 8000
  • Login to Twilio and configure the test phone webhook so that it points to your ngrok endpoint, eg. http://88b59b03d2fd.ngrok.io/caller/answer/
  • Ring the test number on +61480015687
  • When finished, change the webhook back to staging: https://test-clerk.anikalegal.com/caller/answer/

About

Website used by new Anika clients to enter the facts of their case (backend)

https://repairs.anikalegal.com


Languages

Language:Python 95.8%Language:Shell 2.7%Language:Makefile 0.6%Language:HTML 0.6%Language:Dockerfile 0.2%