2025-11-03 12:13:48 +00:00
|
|
|
# Nidus Sync
|
|
|
|
|
|
|
|
|
|
This is the software that powers [Nidus Cloud Sync](https://sync.nidus.cloud).
|
2025-11-03 12:22:59 +00:00
|
|
|
|
|
|
|
|
## Building from source
|
|
|
|
|
|
|
|
|
|
First, you'll need [Nix](https://nix.dev).
|
|
|
|
|
|
|
|
|
|
Then:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
nix develop
|
|
|
|
|
go build .
|
|
|
|
|
```
|
|
|
|
|
|
2026-01-28 22:25:02 +00:00
|
|
|
## Building Custom Theme
|
|
|
|
|
|
|
|
|
|
We're using a customized Bootstrap theme for this site. You'll need to build the SCSS into CSS:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
nix develop
|
2026-02-16 01:10:13 +00:00
|
|
|
sass --style=compressed --trace "$SASS_SRC_DIR/custom.scss":"$CSS_OUTPUT_DIR/bootstrap.css"
|
2026-01-28 22:25:02 +00:00
|
|
|
```
|
|
|
|
|
|
2025-11-04 23:15:17 +00:00
|
|
|
## Running
|
|
|
|
|
|
2025-12-18 03:36:32 -07:00
|
|
|
You'll need a number of environment variables for configuring things;
|
|
|
|
|
|
|
|
|
|
* ARCGIS_CLIENT_ID - The client ID for ArcGIS oauth, configured with esri.
|
|
|
|
|
* ARCGIS_CLIENT_SECRET - The client secret for ArcGIS oauth, configured with esri.
|
|
|
|
|
* BASE_URL - The URL the site is hosted at, used for forming callback URLs. Should be complete like 'https://foo.bar'
|
|
|
|
|
* BIND - The address and port to bind to. Use ':9001' for 'any address, port 9001'
|
|
|
|
|
* ENVIRONMENT - either 'PRODUCTION' or 'DEVELOPMENT'. It's used to set things like oauth token length.
|
|
|
|
|
* MAPBOX_TOKEN - The token to use with mapbox which is important for rendering maps.
|
|
|
|
|
* POSTGRES_DSN - The DSN for connecting to the postgres database.
|
|
|
|
|
* FIELDSEEKER_SCHEMA_DIRECTORY - The directory to write fieldseeker schema files for debugging.
|
|
|
|
|
* USER_FILES_DIRECTORY - The directory for writing uploaded user data files (audio, images).
|
|
|
|
|
|
2025-11-04 23:15:17 +00:00
|
|
|
```sh
|
|
|
|
|
> BASE_URL=https://sync.nidus.cloud ARCGIS_CLIENT_ID=foo ARCGIS_CLIENT_SECRET=bar POSTGRES_DSN='postgresql://?host=/var/run/postgresql&dbname=nidus-sync' ./nidus-sync
|
|
|
|
|
```
|
|
|
|
|
|
2026-01-13 19:47:19 +00:00
|
|
|
### Districts
|
|
|
|
|
|
2026-01-22 04:50:20 +00:00
|
|
|
There's a table containing district information in the database, `import.district`. It was created with:
|
2026-01-13 19:47:19 +00:00
|
|
|
|
|
|
|
|
```
|
2026-01-13 23:36:09 +00:00
|
|
|
psql
|
2026-01-22 04:50:20 +00:00
|
|
|
CREATE SCHEMA import;
|
|
|
|
|
shp2pgsql -s 3857 -c -D -I CA_districts.shp import.district | psql -d nidus-sync
|
|
|
|
|
psql
|
|
|
|
|
ALTER TABLE import.district ADD COLUMN geom_4326 geometry(MultiPolygon,4326) GENERATED ALWAYS AS (ST_Transform(geom, 4326)) STORED;
|
2026-01-13 19:47:19 +00:00
|
|
|
```
|
|
|
|
|
|
2025-11-04 23:11:32 +00:00
|
|
|
## Hacking
|
|
|
|
|
|
2025-11-05 17:17:03 +00:00
|
|
|
### air
|
|
|
|
|
|
|
|
|
|
This project uses [air](https://github.com/air-verse/air) for fast compile-and-test loops. You can run it with:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
> BASE_URL=https://sync.nidus.cloud ARCGIS_CLIENT_ID=foo ARCGIS_CLIENT_SECRET=bar POSTGRES_DSN='postgresql://?host=/var/run/postgresql&dbname=nidus-sync' air
|
|
|
|
|
```
|
|
|
|
|
|
2025-11-04 23:11:32 +00:00
|
|
|
### bob
|
|
|
|
|
|
|
|
|
|
This uses the bob query framework. You can regenerate the models for bob with:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
PSQL_DSN="postgresql://dbname?host=/var/run/postgresql&sslmode=disable" go run github.com/stephenafamo/bob/gen/bobgen-psql@latest"
|
|
|
|
|
PSQL_DSN="postgresql://?host=/var/run/postgresql&sslmode=disable&dbname=nidus-sync" go run github.com/stephenafamo/bob/gen/bobgen-psql@latest
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This will generate a bunch of files. They're already committed, you only need this if you change the database schema in some way.
|
2025-11-07 02:07:33 +00:00
|
|
|
|
|
|
|
|
### goose
|
|
|
|
|
|
|
|
|
|
This uses [goose](https://github.com/pressly/goose). You can use the goose command line to check status and make changes
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
> cd migrations
|
|
|
|
|
> GOOSE_DRIVER=postgres GOOSE_DBSTRING="dbname=nidus-sync sslmode=disable" goose status
|
|
|
|
|
> GOOSE_DRIVER=postgres GOOSE_DBSTRING="dbname=nidus-sync sslmode=disable" goose down
|
|
|
|
|
> GOOSE_DRIVER=postgres GOOSE_DBSTRING="dbname=nidus-sync sslmode=disable" goose up
|
|
|
|
|
```
|
2026-01-29 02:57:27 +00:00
|
|
|
|
|
|
|
|
### watchexec
|
|
|
|
|
|
|
|
|
|
For iterating on styles
|
|
|
|
|
|
|
|
|
|
```
|
2026-03-19 05:45:54 +00:00
|
|
|
watchexec -e scss sass scss/custom.scss:html/static/css/bootstrap.css
|
2026-01-29 02:57:27 +00:00
|
|
|
```
|