BC Archaeology Branch Arches configuration, schemas and extensions for the BC Archaeology Portal.
- Docker Desktop
- Create a directory called
bcap - Open a terminal and navigate to the
bcapdirectory - Run the following to clone the repositories required for this project:
git clone https://github.com/bcgov/arches-dependency-containers
git clone https://github.com/bcgov/arches
git clone https://github.com/archesproject/arches-vue-components
git clone https://github.com/archesproject/arches-controlled-lists
git clone https://github.com/archesproject/arches-querysets
git clone https://github.com/bcgov/bcgov-arches-common
git clone https://github.com/bferguso/arches-workflow-stepper
git clone https://github.com/bferguso/arches-zod-validation
git clone https://github.com/bcgov/nr-bcap
- You should now have the following directory structure:
.
└── 📁 bcap/
├── 📁 arches-dependency-containers/
├── 📁 arches/
├── 📁 bcgov-arches-common/
├── 📁 arches-querysets/
├── 📁 arches-vue-components/
├── 📁 arches-controlled-lists/
├── 📁 arches-workflow-stepper/
├── 📁 arches-zod-validation/
└── 📁 nr-bcap/
- Open or navigate to the
bcapdirectory in the terminal - Run the following command:
cd arches && git checkout dev/8.1.x_bcgov
There are 3 application specific docker containers and 4 common depdendency containers:
- bcap: Application container (Django dev server, BCAP codebase)
- bcap-proxy: Nginx proxy container
- bcap-pg_tileserv: Postgres Tileserve container - tile server for hosting local map tiles
- bcap-pg_featureserv: Postgres Featureserv container - tile server for hosting local wfs (Used for QGIS plugin)
- bcap-nginx: Nginx container - reverse proxy for the Arches application
- bcap-jupyter: Jupyter container - for development
- Depdendency containers - These containers can be shared across applications
- postgres16-3_arches7-5-2: Postgres/PostGIS container
- elasticsearch8-3_arches7-5-2: Elasticsearch container
- redis_arches7-5-2: Redis container
- rabbitmq3_arches7-5-2: RabbitMQ (not currently used, but still there)
- We need to load the base dependencies needed for Arches (i.e., Postgres, Elasticsearch, Redis, etc).
- Open or navigate to the
bcapdirectory in the terminal - Run the following command to setup the project's dependencies:
cd arches-dependency-containers/arches-7-5-2 && docker compose up -d
This is done w/ modifications to the manage.py file that connects from the docker container back to the host so no ports need to be configured in the docker-compose.yml file.
To activate this debugging mode:
- Add/edit the following lines in the ./docker/docker.dev.env file:
INSTALL_PYCHARM_DEBUG=true PYCHARM_DEBUG=true DOCKER_HOST_PLATFORM=linux/arm64 # One of linux/arm64, linux/amd64 - Create a Python Debug Server configuration in PyCharm and set the following:
- host: localhost
- port: 5680
- path mappings:
<dir to nr-bcap parent on host> -> /web_root<dir to nr-bcap on host> -> /web_root/bcap
- An .env file
- Open or navigate to the
bcapdirectory in the terminal - Run the following command:
cd nr-bcap && docker compose up -d
- Let the
bcapcontainer fully load (i.e., watch the "Logs" tab). There will be a warning about missing environment variables.- You will see:
django.core.exceptions.ImproperlyConfigured: Set the BCGOV_PROXY_PREFIX environment variable - This can take some time.
- You will see:
- You need to create or move the .env file to
bcap/nr-bcap/.env - Restart the
bcapcontainer in Docker Desktop - Open the
bcapcontainer in Docker Desktop - Go to the "Exec" tab and run the following:
bash
cd bcap && mkdir logs
- Restart the
bcapcontainer in Docker Desktop
- Create
test_user_list.pyinbcap/nr-bcap/bcap/management/data/test_user_list.py - Put the following function in the
test_user_list.pyfile if you do not have an IDIR username/password:
def get_user_list():
return [
{
"name": "testuser123",
"email": "test@email.com",
"password": "Test12345!",
"is_superuser": True,
"is_staff": True,
"first_name": "Test",
"last_name": "User",
"groups": [
"Resource Editor",
"Resource Reviewer",
"Archaeology Branch",
"Resource Exporter"
]
}
]
- Put the following function in the
test_user_list.pyfile if you do have an IDIR username/password:
def get_user_list():
return [
{
"name": "<idir username>@idir",
"email": "<email>",
"password": "Test12345!",
"is_superuser": True,
"is_staff": True,
"first_name": "<first name>",
"last_name": "<last name>",
"groups": [
"Resource Editor",
"Resource Reviewer",
"Archaeology Branch",
"Resource Exporter",
],
},
]
- The password is a dummy password so it can be left as is.
- OIDC is used so when authenticating you will use your IDIR username and password.
- The
@idirsuffix is necessary - The
<idir username>must be in lowercase
- Start and open the
bcapcontainer in Docker Desktop - Go to the "Exec" tab and run the following:
python3 manage.py bc_test_users --refresh
-
Open the "Inspect" tab in the container
-
Ctrl + FforNetworksand look forIPAddress -
Copy the IP Address and open the
bcap/nr-bcap/.envfile -
Add the IP Address to the
AUTH_BYPASS_HOSTSvariable:AUTH_BYPASS_HOSTS = ... ... <IPAddress>
-
Open the
bcapcontainer in Docker Desktop -
Go to the "Exec" tab and run the following:
npm run build_development
python3 manage.py setup_db
- Open
bcap/nr-bcap/bcap/settings.py - Find
AUTHENTICATION_BACKENDSin thesettings.pyfile
- Comment out the following:
"oauth2_provider.backends.OAuth2Backend",
"bcap.util.external_oauth_backend.ExternalOauthAuthenticationBackend",
- Uncomment the following:
"django.contrib.auth.backends.ModelBackend"
- Uncomment the following:
"oauth2_provider.backends.OAuth2Backend",
"django.contrib.auth.backends.ModelBackend",
"guardian.backends.ObjectPermissionBackend",
"arches.app.utils.permission_backend.PermissionBackend",
- Comment out the following:
"arches.app.utils.email_auth_backend.EmailAuthenticationBackend",
"django.contrib.auth.backends.RemoteUserBackend",
- You must also add the secret to the
OAUTH_CLIENT_SECRETvariable in the .env file
- You should now be able to access BCAP at http://localhost:82/bcap
- If it doesn't work, then open or navigate to the
bcapdirectory in the terminal - Restart the
bcapcontainer or run the following command:
cd nr-bcap && docker compose up -d
- After logging into BCAP, the map will initially be blank.
- You must navigate to the "System Settings" from the menu on the left-hand side, and enter your
Mapboxtoken there.
- You must navigate to the "System Settings" from the menu on the left-hand side, and enter your
If you have been given a database dump like bcap.sql follow these steps to load it into the system.
- Copy db file into your docker container from any terminal.
docker cp bcap.sql bcap:/tmp/bcap.sql
- Create and index the database from the Exec tab inside your container (indexing may take up to an hour).
createdb -U postgres -h postgres16-3_arches7-5-2 bcap
psql -U postgres -h postgres16-3_arches7-5-2 -d bcap -c "CREATE EXTENSION IF NOT EXISTS postgis;"
psql -U postgres -h postgres16-3_arches7-5-2 -d bcap -f /tmp/bcap.sql
python3 manage.py es index_database
- If you are having trouble with logins you might need to refresh your test user list
python3 manage.py bc_test_users --refresh
See README.vite.md for details about developing using the Vite dev server.
Documented DRF views → schema.yml (OpenAPI) → Zod schemas in
bcap/src/bcap/client/ (via @hey-api/openapi-ts; types via
z.infer). Regenerate in the bcap container after changing a documented
serializer, view, route, or resource model:
python3 manage.py regenerate_apiThis runs the full pipeline: generated views → OpenAPI spec (drf_spectacular) → zod client (openapi-ts) → formatting (black, prettier). Useful flags:
--check— fail if any generated artifact drifts from the git index (CI use)--skip-zod— backend-only environments without npm--skip-views— use the committed generated views as-is
NOTE: Only the limited documented routes for now; arches-queryset routes later.
To load sample dashboard data into the current database (permit application, related resources, and Elasticsearch indexing):
# Small demo graph (one permit, three short requirements)
python3 manage.py seed_dashboard_demo
# Just the process-requirement templates (no permit application)
python3 manage.py seed_template_requirements
# Seed several cards at once (each with randomized names and application id)
python3 manage.py seed_dashboard_demo --count 20Seeded data uses Faker to randomize holder names, project officer, ministry assignees, and the application id, so each card is distinct. Both commands take --count N (default 1) and --no-index (for when Elasticsearch is not running).
To remove the seeded data again (only resources the seeders created are deleted — real data in the same graphs is left untouched):
python3 manage.py clear_dashboard_dataThese are temporary developer aids and will be removed in a future release.
After editing a resource model JSON in pkg/graphs/ (via the Arches graph
designer or direct file edits), the running database needs to be updated to
match. Run inside the bcap container:
python3 manage.py reload_permit_modelsThis reimports all permit resource models and branches from the checked-in JSON files, reloads the SKOS controlled lists, re-seeds the process-requirement templates, and re-indexes affected resources in Elasticsearch.
If a node was removed from the JSON or its datatype changed, existing tile data is incompatible and must be cleared first:
python3 manage.py reload_permit_models --delete-tilesAfter a successful reload, regenerate the OpenAPI spec and Python node-alias files so generated code stays in sync with the new graph structure:
python3 manage.py regenerate_api
python3 manage.py regen_python_aliasesCommit the updated graph JSON (node UUIDs may have been auto-rotated by the
command), schema.yml, generated views, Zod client, and alias files together.
See arches-zod-validation README for a detailed explanation of the full API generation pipeline.
python3 manage.py test tests --pattern="*.py" --settings="tests.test_settings" --keepdb
--keepdbreuses the existing test database between runs to save time- To run a specific test module or class, replace
testswith the dotted path (e.g.tests.views.test_api)
The graph config tests validate the checked-in JSON files in pkg/graphs/
against common mis-configurations (absolute URLs, wrong app prefixes, wrong
controlled-list-manager hosts) without requiring any database access:
python3 manage.py test tests.test_graph_config --settings="tests.test_settings"Run these after editing any resource model JSON.
To validate data integrity of the live database (graph structure, node
configuration, tile data consistency), use the Arches validate command:
python3 manage.py validateViolations can be auto-remediated where a fix is available:
python3 manage.py validate --fix-allUse --export-dir to export any modified graphs back to JSON after fixing:
python3 manage.py validate --fix-all --export-dir pkg/graphs/resource_modelsRun all four checks inside the bcap container. All must pass before merging.
Prettier auto-fixes formatting in-place; ESLint and TypeScript errors must be
zero.
-
Prettier (auto-formats):
npm run prettier:fix:all
-
ESLint (lint — zero errors required):
npm run eslint:check
-
TypeScript (no type errors):
npm run ts:check
-
Vitest (unit tests):
npm run vitest
- RabbitMQ is not being used
- We do not use the Django template engine, therefore changes to the Django code need to be rebuilt with the webpack