Activist Database Project
This project uses mise to install tool dependencies. The only dependency mise
can't install for you is Docker. If you are running the devcontainer, both mise
and Docker are installed for you, and you can skip to mise run deps.
Please install Docker and mise, and optionally "activate" mise.
Finally, download all the tools and dependencies of this project (for the main server and frontend, at least) in one command:
mise run deps
If you are not using the devcontainer, you can use our Docker Compose configuration to run MySQL locally:
mise run db:up
mise run db:init
If you are using the devcontainer, just run this command in the container:
mise run db:init
db:init sets up the database only if it has no tables yet, so it's safe to
re-run. To start over, run mise run db:reset. It deletes everything in your
local dev database, then re-creates it with the current schema, some fake data,
and a dev user for logging in.
You can log into the database by running mise db (or just db in a shell where mise is activated; see the [shell_alias] section of mise.toml).
To seed data into the database for various testing scenarios, check out the ADB CLI "seed" command.
Note that for the activists pages, you can see the generated SQL queries and their EXPLAIN ANALYZE results by adding "debug=true" to the page URL and clicking the "Debug" button.
After downloading the dependencies, start the development servers. There are two ways to do this.
The first way is using the tasks in mise.toml. This runs the React app and
the Go server in parallel, with each line of output prefixed by its task name.
mise run dev
# Or run each server in its own terminal:
mise run dev:frontend
mise run dev:backend
The other way is using VS Code launch configurations. This allows you to see
the output of each process individually via the debug console, and to restart
processes individually. To do this, go to the Run and Debug panel and choose
Launch all.
Access the new frontend (React app) at http://localhost:8080/v2 - or test with http://localhost:8080/v2/test.
React pages auto-update in the frontend development server when you save changes.
Note: The frontend has a different color scheme in development. This helps developers with prod access maintain awareness of which environment they are working in to avoid making changes in the wrong environment. Double-clicking the navigation bar will toggle back to the prod color scheme e.g., for testing purposes or taking screenshots.
Note: The react app can technically be accessed directly on port 3000 locally, but it won't have access to the cookies from :8080 which could cause issues.
Access the Go API server at http://localhost:8080/
Access the Members app at members.dxesf.org at http://localhost:8081/
Please run mise run fmt before sending a pull request.
Note that prettier is configured at the root of the repo and not within individual projects, although project-specifc
configuration can be applied in the configuration file. This allows formatting the repo with one invocation of prettier,
and is necessary as VS Code only accepts one prettier configuration. It also ensures consistency by avoiding multiple
versions or configurations of prettier.
Please run mise run test before sending a pull request.
Note the tests take several minutes to run, even though some of them finish quickly. To check if any tests are hanging, you can add "-v -p 1" after "go test" args in the "test:server" task in mise.toml to show individual test names and to run them in serial.
The frontend is a Next.js (React) app in frontend-v2/. See
frontend-v2/README.md for more information. See above for instructions on
building and running it along with other components of ADB.
These variables are always required in prod:
- ADB_URL_PATH: For example, "http://adb.domain.com"
- PORT: The port to run the webserver on
- MEMBERS_PORT: Port to run the Members webserver on
- DB_USER
- DB_PASSWORD
- DB_NAME
- DB_PROTOCOL: For example, "tcp([host]:[port])"
- PROD: [true or false]
- RUN_BACKGROUND_JOBS: [true or false] should only be true on at most one instance if load balancing
- COOKIE_SECRET: [a random string]
- CSRF_AUTH_KEY: [a random string]
Please reach out to tech@dxe.io to get an API key to sign people up.
- SIGNUP_ENDPOINT
- SIGNUP_KEY
- SYNC_MAILING_LISTS_CONFIG_JSON: the contents of client_secrets.json, for a deployment that injects secrets as environment variables rather than files
- SYNC_MAILING_LISTS_CONFIG_FILE: relative path to client_secrets.json, if the above is not set
- SYNC_MAILING_LISTS_OAUTH_SUBJECT: google account to use to sync
- SMTP_HOST
- SMTP_PORT
- SMTP_USER
- SMTP_PASSWORD
- SURVEY_FROM_EMAIL
- SURVEY_MISSING_EMAIL: Email to send survey errors to
- MEMBERS_CLIENT_ID
- MEMBERS_CLIENT_SECRET
- WEBSITE_GOOGLE_CLIENT_ID: the "DxE website sign-in" client (public; set in dxe/terraform). Unset disables Google sign-in there; locally, POST
{"credential": "dev"}to/auth/google/tokeninstead. - The sign-in page is
GET /loginonmembers.directactioneverywhere.com(served by Host; locally it is the default for/login, and the legacy members.dxesf.org login is at/login?legacy). It needshttp://localhost:<MEMBERS_PORT>among the Google client's authorized JavaScript origins. - MEMBERS_DEV_LOGIN:
trueonly for local development (set inserver/debug.env): enables the fake{"credential": "dev"}sign-in, logs magic links instead of emailing them, and allows localhost origins. Ignored when PROD is true.
ipgeolocation.io key for finding nearby upcoming events based on a user's IP address (used w/ public-facing API):
- IPGEOLOCATION_KEY
Google Places API Key for finding city information on public-facing forms and the events location picker
- GOOGLE_PLACES_API_KEY
This key is not in server/debug.env. To use the location picker locally, add
it to server/.env (created empty by mise run deps, loaded on top of
server/debug.env). See server/.env.example for the available keys:
GOOGLE_PLACES_API_KEY=...
This API key can be found in GCP under the dev environment: https://console.cloud.google.com/apis/credentials/key/68509fdd-6190-406e-b89f-16286be4faf5?project=places-api-308104
In production, logs are collected in CloudWatch under a log group called adb.
The log messages are a mix of English strings often generated by our use of Go's log package, and JSON-encoded strings
generated by our use of the github.com/rs/zerolog package.
JSON log lines have a property called level which when set to error is captured by a "Metric filter" called
error_logs on the adb CloudWatch log group. When any log item matches this filter, our CloudWatch alarm is triggerd
and the tech team is notified.
Note: authentication is bypassed during development in the server's model.authADBUser function.
Authentication is provided by Google Identity's 'Sign in with Google' for Web: https://developers.google.com/identity/gsi/web/guides/overview
This makes use of our OAuth 2.0 client ID in Google Cloud Platform. However many OAuth 2.0 details are taken care of for us by Google.
Pages protected by authentication check the cookies to see if a valid session exists and redirect to /v2/login which
serves up frontend-v2/src/app/login/page.tsx. This page handles authentication with Google client-side to get a token
and then makes a POST request to ADB's /tokensignin endpoint with the token. The backend endpoint verifies the token,
obtains the user indicated by the token and creates a session cookie. If the backend returns a successful response,
the login page then redirects to the homepage.
For local testing, you may need to add an ngrok authorized origin in GCP console. The origin http://localhost:8080
does not seem to work as of December 2025.
We make use of skills and CLAUDE.md files at the repo root and in subdirectories.
In Claude Code cloud environments, typically Anthropic hosted VMs, it is recommended
to add a setup script
that invokes .claude/cloud/setup.py.
DxE-provisioned Claude accounts already have access to an cloud environment that
does this, and it can be selected when starting a new Claude Code conversation
via Claude web UI.
We also have a script that runs only in cloud sessions, on Claude's session
start hook. The script runs the database and builds the app so Claude can start
working right away.
In other environments, developers might typically set up the database and build the app in advance of invoking Claude. However, in devcontainer environment incl GitHub codespaces, some steps may be done for you already.
More documentation is available in Tech team's Coda doc.