{"id":23314863,"url":"https://github.com/deardurham/dear-petition","last_synced_at":"2025-08-22T14:31:26.546Z","repository":{"id":35569097,"uuid":"181311865","full_name":"deardurham/dear-petition","owner":"deardurham","description":"Petition form generation app to streamline expunction process in North Carolina","archived":false,"fork":false,"pushed_at":"2024-04-26T02:43:02.000Z","size":6942,"stargazers_count":10,"open_issues_count":63,"forks_count":15,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-29T00:10:06.901Z","etag":null,"topics":["celery","cookiecutter-django","django","django-rest-framework","docker","docker-compose","nodejs","python","python3","record-clearance"],"latest_commit_sha":null,"homepage":"https://deardurham.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deardurham.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-14T13:19:26.000Z","updated_at":"2024-04-30T22:32:21.236Z","dependencies_parsed_at":"2023-10-23T13:41:50.705Z","dependency_job_id":"bbfedb8f-b062-4d09-85fc-2ddea1a04adc","html_url":"https://github.com/deardurham/dear-petition","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deardurham%2Fdear-petition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deardurham%2Fdear-petition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deardurham%2Fdear-petition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deardurham%2Fdear-petition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deardurham","download_url":"https://codeload.github.com/deardurham/dear-petition/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230503381,"owners_count":18236429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["celery","cookiecutter-django","django","django-rest-framework","docker","docker-compose","nodejs","python","python3","record-clearance"],"created_at":"2024-12-20T15:18:11.528Z","updated_at":"2024-12-20T15:18:12.261Z","avatar_url":"https://github.com/deardurham.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DEAR Petition\n\nA [Durham Expunction and Restoration (DEAR)](https://www.deardurham.org)\n project for creating petition forms.\n\n[![Built with Cookiecutter Django](https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg)](https://github.com/pydanny/cookiecutter-django/)\n![Build Status](https://github.com/deardurham/dear-petition/actions/workflows/test.yml/badge.svg)\n[![Black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\n- [DEAR Petition](#dear-petition)\n  - [🚀 Docker Quick Start](#-docker-quick-start)\n  - [🐳 Development Container](#-development-container)\n  - [Frontend Development](#frontend-development)\n    - [🚀 Quick Setup](#-quick-setup)\n    - [API Proxy Configuration](#api-proxy-configuration)\n      - [Docker Container](#docker-container)\n      - [Local Frontend](#local-frontend)\n  - [Backend Development](#backend-development)\n    - [Initial Setup](#initial-setup)\n    - [Restore database](#restore-database)\n    - [Configuring the containers using docker-compose.override.yml (optional)](#configuring-the-containers-using-docker-composeoverrideyml-optional)\n  - [Development Tools and Testing](#development-tools-and-testing)\n    - [Running tests with py.test](#running-tests-with-pytest)\n    - [Test coverage](#test-coverage)\n    - [Sign up for Sentry](#sign-up-for-sentry)\n  - [Production testing](#production-testing)\n\n## 🚀 Docker Quick Start\n\n```sh\ngit clone git@github.com:deardurham/dear-petition.git\ncd dear-petition/\ndocker-compose up -d\ndocker-compose run --rm django python manage.py migrate\ndocker-compose run --rm django python manage.py createsuperuser\n```\n\nTry out DEAR Petition Generator by navigating to `http://localhost:3000`, logging in as the superuser you created, and uploading an example CIPRS pdf which can be downloaded from [the ciprs-reader test record directory](https://github.com/deardurham/ciprs-reader/tree/main/tests/test_records).\n\n## 🐳 Development Container\n\nThis project supports using a [Development Container](https://containers.dev/), is based on the [postgres](https://github.com/devcontainers/templates/tree/main/src/postgres) template and enables several features, including [python](https://github.com/devcontainers/features/tree/main/src/python) and [node](https://github.com/devcontainers/features/tree/main/src/node).\n\nBefore getting started, install [Visual Studio Code](https://code.visualstudio.com/) with the [Remote Development extension pack](https://aka.ms/vscode-remote/download/extension). See [Developing inside a Container](https://code.visualstudio.com/docs/remote/containers) for additional information.\n\n1. **Build and start dev container:** Using the [VS Code Command Pallete (`⇧⌘P`)](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette), select `Dev Containers: Reopen in Container`.\n2. **Install Python and Node requirements:**\n\n    ```sh\n    # Update pip\n    python -m pip install --upgrade pip\n    # Install Python packages\n    pip install --user -r requirements/local.txt\n    # Install node packages\n    npm install\n    ```\n\n3. **Setup pre-commit:** Install pre-commit to enforce a variety of community standards:\n\n    ```sh\n    pre-commit clean\n    pre-commit install\n    ```\n\n4. **Prepare your environment**: Run migrate and create a user for yourself:\n\n    ```sh\n    python manage.py migrate\n    python manage.py createsuperuser\n    ```\n\n5. **Start dev server:** Start the Django development server:\n\n    ```sh\n    python manage.py runserver\n    ```\n\n6. **Start Node dev server:** Start the Node development server in a separate terminal:\n\n    ```sh\n    npm run start\n    ```\n\n## Frontend Development\n\nThe user facing  side of the DEAR Petition Generator is a React single page app (SPA). It is common to run the frontend locally while running the backend on docker.\n\nNote: **Node 18 is the minimum supported version for local frontend development**\n\n### 🚀 Quick Setup\n\n```sh\ndocker compose up -d django # run the backend via docker in the background\nnpm i\nnpm run start\n```\n\n### API Proxy Configuration\n\nThe Petition Generator app uses a React frontend with a Django REST API backend. In the development environment, the React development server and Django backend will likely be hosted on different ports, and thus hosted on different urls. This causes issues when the frontend code sends API requests, such as a login request. The solution is to [proxy the API requests](https://create-react-app.dev/docs/proxying-api-requests-in-development/) to the url of the backend.\n\n#### Docker Container\n\nWhen the frontend is run using docker, the `API_PROXY` environment variable is set to `http://django:8000`.\n\nYou can override the this proxy url by setting `OVERRIDE_API_PROXY`:\n\n```sh\nOVERRIDE_API_PROXY=http://localhost:8888 docker-compose up -d\n```\n\nNote that there's an issue with the `node_modules` volume not updating when you add new dependencies. When this happens, run the following:\n\n```sh\ndocker compose up --renew-anon-volumes -d frontend\n```\n\n#### Local Frontend\n\nWhen using `npm run start` to run the frontend, the `API_PROXY` environment variable is unset. The fallback proxy is set to the `http://localhost:8000`.\n\nYou can set the proxy url by either setting `OVERRIDE_API_PROXY` or `API_PROXY`:\n\n```sh\nAPI_PROXY=http://localhost:8888 npm start\n```\n\n## Backend Development\n\n### Initial Setup\n\nTo run this on a Mac, use [Docker for\nMac](https://docs.docker.com/docker-for-mac/install/).\n\nBuild the project containers:\n\n  ```sh\n    docker-compose build\n  ```\n\nRun the containers:\n\n  ```sh\n    docker-compose up -d django\n  ```\n\nMigrate DB:\n\n  ```sh\n    docker-compose run --rm django python manage.py migrate\n  ```\n\nCreate a superuser:\n\n  ```sh\n    docker-compose run --rm django python manage.py createsuperuser\n  ```\n\nWhen asked for a username and password, enter values of your choosing.  Email address may be left empty.\n\nVisit `http://localhost:8000/petition/api/` in your browser.  If you get authentication errors, you may login as the superuser you created at `http://localhost:8000/` and try again.\n\nSee detailed [cookiecutter-django Docker\ndocumentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html).\n\n### Restore database\n\nIf you have a database dump you wish to restore, you can run:\n\n```sh\ndocker-compose run --rm django sh\ndropdb dear_petition\ncreatedb dear_petition\npg_restore -Ox -d dear_petition latest.dump\npython manage.py migrate\n```\n\n### Configuring the containers using docker-compose.override.yml (optional)\n\nTo develop in a Docker container, we'll create a `docker-compose.override.yml`\noverride file in the root of the `dear-petition` directory to configure the Django container to sleep by default:\n\n```yaml\n# file: docker-compose.override.yml\nversion: '3'\n\nservices:\n  django:\n    command: [\"sleep\", \"infinity\"]\n```\n\nNow we run `runserver` manually to have more control over restarts:\n\n```sh\ndocker-compose up -d django\ndocker-compose exec django bash\nroot$ python manage.py runserver 0.0.0.0:8000\n```\n\n## Development Tools and Testing\n\n### Running tests with py.test\n\n  ```sh\n    docker-compose run --rm django pytest\n  ```\n\n### Test coverage\n\nTest coverage is automatically generated as part of `pytest`.\n\nTo manually run the tests, check your test coverage, and generate an HTML\ncoverage report:\n\n  ```sh\n    coverage run -m pytest\n    coverage html\n    open htmlcov/index.html\n  ```\n\n### Sign up for Sentry\n\nThe dear-petition project is now on Sentry. Visit sentry.io and make an account or sign in with Github. Reach out to an existing member for an invite to the project.\n\n## Production testing\n\nTo test the production Dockerfile locally, run:\n\n```sh\nCOMPOSE_FILE=docker-compose.deploy.yml docker compose up --build -d django\n#  View logs for debugging\nCOMPOSE_FILE=docker-compose.deploy.yml docker compose logs django -f\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeardurham%2Fdear-petition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeardurham%2Fdear-petition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeardurham%2Fdear-petition/lists"}