Vetspire
View SourceMonorepo for the Vetspire veterinary practice-management platform â a React/TypeScript frontend, an Elixir/Phoenix GraphQL API, cloud functions, and supporting apps.
đ Contents
- Overview
- Tech Stack
- Project Structure
- Prerequisites
- Backend Setup
- Frontend Setup
- E2E Tests
- Connecting to Remote Environments
- GraphiQL with Local Auth
- Git Worktrees
- Continuous Deployment
- Cloud Functions
- Online Booker (Legacy)
- Editor / Agent Setup
- Linting & Formatting
- Documentation
- Monitoring & Observability
đ§ Overview
This is the monorepo for the Vetspire platform, housing both frontend and backend codebases, cloud functions, documentation sites, and deployment scripts.
A set of browser SPAs talk to a single Elixir/Phoenix umbrella API over GraphQL (plus a few REST endpoints), which persists to PostgreSQL, runs background work on Oban, and integrates with labs, payments, and accounting providers.
graph LR
subgraph Clients["Client SPAs ¡ React ¡ Firebase"]
WEB["web/"]
BOOK["online bookers<br/>& kiosks"]
end
API["api/<br/>Elixir umbrella<br/>GraphQL ¡ REST ¡ WS<br/>(GKE)"]
PG[("PostgreSQL 15<br/>+ read replicas")]
OBAN["Oban workers"]
FNS["functions/<br/>Cloud Functions"]
EXT["Labs ¡ Stripe ¡<br/>Intacct ¡ Twilio"]
WEB & BOOK -->|GraphQL / REST| API
API --> PG
API --> OBAN
OBAN --> EXT
OBAN --> FNSđ For the full architecture â umbrella apps, request lifecycle, CI/CD, and more diagrams â see
docs/ARCHITECTURE.md.
đ§° Tech Stack
| Area | Technologies |
|---|---|
Backend (api/) | Elixir 1.19 / OTP 28 ¡ Phoenix 1.7 ¡ Absinthe 1.10 (GraphQL) ¡ Ecto 3.13 ¡ Oban 2.20 + Oban Pro |
Frontend (web/) | React 17 ¡ TypeScript 5.7 ¡ esbuild ¡ Apollo Client 3 ¡ Zustand ¡ MUI 7 ¡ React Router 5 |
E2E (e2e/) | Playwright 1.60 ¡ TypeScript ¡ Currents reporter |
| Data & infra | PostgreSQL 15 (+ read replicas) ¡ GKE (Kubernetes) ¡ Firebase Hosting ¡ Google Cloud Functions |
| Observability | OpenTelemetry â Jaeger (local) ¡ New Relic ¡ Sentry |
đ Project Structure
| Directory | Description | Deployment Target |
|---|---|---|
api/ | GraphQL & REST API â Elixir/Phoenix umbrella (6 OTP apps) | GKE |
web/ | Vetspire frontend (React) | Firebase |
e2e/ | Playwright end-to-end test suite | â (CI / Cloud Run) |
functions/ | Cloud functions for reporting, PDFs, integrations | Google Cloud Functions |
datasync/ | Python CLI tool for client-side data ingestion | Client machines |
developer.vetspire.com/ | Public GraphQL docs | Firebase |
email-templates/ | MJML email templates | â |
scripts/ | Internal helper scripts | â |
dns/ | DNS config dumps | â |
âšī¸ The
datasync/directory is the client-side Python ingestion tool. The umbrella also contains a separatedatasyncOTP app (server-side sync workers) â seedocs/ARCHITECTURE.md.
â Prerequisites
Runtime versions are pinned in .tool-versions (use asdf
or mise):
| Tool | Version |
|---|---|
| Elixir | 1.19.5-otp-28 |
| Erlang | 28.5.0.5 |
| Node.js | 22.13.1 |
| Yarn | 1.22.17 |
| pnpm | 10.33.2 |
| Python | 3.11.6 |
You'll also need PostgreSQL (via Docker, below), Docker, and the gcloud CLI.
đĄ A Nix flake is provided for a reproducible toolchain. With direnv installed,
.envrcloads your environment automatically oncdinto the repo.
âī¸ Backend Setup
# Start Docker daemon if necessary
sudo service docker start
# Start PostgreSQL (and the Jaeger tracing UI) containers
docker compose up db jaeger
# Auth to GCP
gcloud auth login
gcloud auth application-default login
# Backend setup
cd api
mix hex.repo add oban https://repo.oban.pro \
--fetch-public-key SHA256:4/OSKi0NRF91QVVXlGAhb/BIMLnK8NHcx/EWs+aIWPc \
--auth-key 0a0cb15a8ff6f9d6175a9ea19eccff0c
mix deps.get
mix ecto.reset
iex -S mix phx.server
Visit:
https://localhost:4000â Vetspire APIhttps://localhost:4000/graphiqlâ GraphiQL endpointhttps://localhost:4001â Admin app (requiresUSE_SSL=trueâ the admin endpoint only works over https)http://localhost:16686â Jaeger tracing UI (when thejaegercontainer is running)
The API is an Elixir umbrella of six OTP apps. If you don't need all of them during local
development, set these ENV VARs to false to skip booting them:
| Variable | Effect when false |
|---|---|
START_DATASYNC | Skip booting the datasync app |
START_PROTOCOLS | Skip booting the protocols app |
START_MONARCH | Skip running Monarch data migrations on boot |
START_OPENTELEMETRY | Skip attaching OpenTelemetry (Sibyl) trace handlers |
export START_DATASYNC=false
export START_MONARCH=false
export START_OPENTELEMETRY=false
export START_PROTOCOLS=false
â ī¸
START_READ_REPLICAis not an environment toggle. Read replicas auto-boot in non-test environments and are routed to programmatically viaVetspire.Repo.use_read_replica?/0â seeapi/apps/vetspire/lib/vetspire/repo.ex.
đĨī¸ Frontend Setup
cd web
pnpm install
pnpm start
Visit: https://localhost:3000
đ Local Login
- Go to
https://localhost:3000/select_org - Enter "test" for the subdomain.
- Login using test credentials from seed data
đ§Ē E2E Tests
End-to-end tests use Playwright and follow a Functional Page Model. Run them against a chosen environment:
cd e2e
pnpm install
pnpm test:local # also: test:dev | test:staging | test:production
pnpm ui # interactive UI mode
pnpm report # open the last HTML report
Use
pnpm(notnpx) ine2e/. Conventions live ine2e/CLAUDE.md; architecture indocs/ARCHITECTURE.md.
đ Connecting to Remote Environments
To connect to dev, staging, or prod:
./scripts/connect <environment>
If not already authenticated:
gcloud auth login
gcloud auth application-default login
đ§Ē Using GraphiQL with Local Auth
- Run backend and frontend locally.
- Login at
https://localhost:3000. - Open browser console and run:
copy(localStorage.getItem("authToken"))- Go to
/graphiql, set theauthorizationheader using the copied token.
đŗ Git Worktrees (Multi-Instance Development)
Git worktrees allow you to work on multiple branches simultaneously. Each worktree automatically gets its own database (named after the branch), so you can work on multiple features without conflicts.
Setup
1. Convert to bare repo (one-time setup):
# Clone as bare repo
git clone --bare git@github.com:Vetspire-VSP/vetspire.git vetspire
cd vetspire
# Create your main worktree
git worktree add master master
2. Create worktrees:
# New branch from master
git worktree add DI-1234 -b feat/DI-1234 master
# Existing branch
git worktree add my-feature fix/my-feature
# From remote branch
git worktree add DI-5678 -b chore/DI-5678 origin/DI-5678
3. Set up database (for each new worktree):
cd DI-1234
scripts/worktree-setup # Clones build state, reconciles deps, sets up databases
Takes ~1m45s, and is safe to re-run. WORKTREE_SHARED_DB=1 shares one dev/test
database across worktrees, which brings it down to ~50s. Pair it with
scripts/worktree-warm-bases on a timer to keep the base worktrees current.
If you drive worktrees with worktrunk,
.config/wt.toml runs all of this for you on wt switch --create.
See scripts/WORKTREES.md.
Configuration Options
Add these to .envrc_local in your worktree:
| Option | Description |
|---|---|
USE_SSL=true | Enable HTTPS/WSS (required for the Admin app on 4001) |
WORKTREE_SEPARATE_PORTS=true | Use separate ports per worktree (see below) |
Port Isolation (Optional)
By default, all worktrees use the same ports (4000 for backend, 3000 for frontend). This means you can only run one worktree at a time.
To run multiple worktrees simultaneously, enable port isolation in .envrc_local:
export WORKTREE_SEPARATE_PORTS=true
With port isolation enabled, each worktree gets sequential ports based on alphabetical order:
- First worktree: Backend
4000, Frontend3000 - Second worktree: Backend
4015, Frontend3015 - Third worktree: Backend
4030, Frontend3030
Database Naming
Each worktree automatically uses a branch-specific database:
Note: postgres database names have a max character setting requiring trimmed db names on long branch names
- Database:
<branch-name>(slashes replaced with hyphens) - Test DB:
vetspire_test_<branch-name>
You can bypass branch based test databases by removing the ENV var in your .envrc_local
unset TEST_DB_NAME
Examples
- Branch
feat/DI-1234â Databasefeat-DI-1234 - Branch
PL-2948-preserve-existing-lab-order-test-modifiers-for-fuji-risâ DatabasePL-2948-preserve-existing-lab-order-test-modifiers
Best Practices
- Cleanup:
git worktree remove <name>when done - List:
git worktree listto see all active worktrees - direnv: Install direnv for automatic environment configuration
đ Continuous Deployment
| Branch | Environment | Cluster | Project |
|---|---|---|---|
master | Development | vetspire-api-dev | vetspire-app |
staging | Staging | vetspire-staging-api | vetspire-app |
production | Production | vetspire-prod-api | vetspire-app |
production | Sandbox | vs-sandbox-k8s-a23b | vs-sandbox |
Deployments are automated via GitHub Actions (dev, staging, production). Order: backend â frontend. See the CI/CD overview for the full pipeline.
đŗ Online Booker
The online booker application now lives here: Online Booker.
Editor IDE and agent setup
We've added Tidewave MCP as a development dependency for improved tooling when using Copilot or Claude in local IDE development.
To set up Tidewave MCP with your editor/agent see docs here: https://hexdocs.pm/tidewave/mcp.html
e.g. claude mcp add --transport http tidewave http://localhost:4000/tidewave/mcp
đ§š Linting & Formatting (VS Code)
Install:
- ESLint extension
- Prettier extension (for GraphQL)
Update settings.json:
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[graphql]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}Run:
pnpm lint
âī¸ Vetspire Cloud Functions
Run locally:
cd functions
yarn start
Available at https://localhost:8080
Defined Functions
createAntechLabpollAntechLabssyncIntacctcreatePDFmergeURLsToPDFgeneratePDF
đ Documentation
- Architecture overview â diagrams, umbrella apps, request lifecycle, CI/CD
- GraphQL Docs
- Vetspire Docs
- Web App
- Admin App
- Worker
- Protocol System
- Datasync Tool