Automated member data synchronization for Dutch sports clubs. Extracts data from Sportlink Club (KNVB's member administration — no API) via headless browser automation and syncs it to Laposta, Rondo Club (WordPress), and FreeScout. Club volunteers never enter the same data twice.
The people import also refreshes Sportlink parent field labels for existing relationships. To backfill labels without changing contact data, run node tools/sync-parent-slot-labels.js --apply on the sync server; omit --apply to preview source coverage.
Parent relationships and slot-label imports exclude retired KNVB identities even when Sportlink still returns them. Their recovery mappings remain intact; current surviving identities continue to sync normally.
Laposta receives three current-season volunteer counters from Rondo: vrijwilligersplicht (total required duties, -1 for exempt/not applicable), vrijwilligersingepland (planned), and vrijwilligersafgerond (completed/credited). Progress follows Rondo's shared-family attribution. Planning or completing a shift never lowers the total requirement.
Player-history checks exclude obsolete and retired Sportlink identities while retaining their recovery mappings. A member who returns in a fresh source import becomes eligible again. Team-name whitespace is normalized to prevent duplicate history on repeated imports. Unmatched current team roles still require review; missing source history never clears them automatically.
Team downloads wait for Sportlink to recover temporary authentication failures and retry once after logging in again if needed. Failed or incomplete roster downloads preserve the existing team-member snapshot.
After a successful submission of all lists, Laposta sync unsubscribes obsolete
child identities from a parent's mailbox only when the child's current address
and the mailbox owner's correct identity both have active subscriptions. Unknown
identities, current shared addresses and existing opt-outs are preserved. This
requires a complete Sportlink snapshot less than one hour old and verifies each
unsubscribe. On the sync server, preview one mailbox with
node tools/cleanup-laposta-stale-identities.js --email parent@example.com;
add --apply to perform the verified cleanup without sending mail.
Scheduled reconciliation defers expired snapshots to the next fresh run; the
maintenance command reports an error until the Sportlink download is refreshed.
Encrypted backups of srv1's production, demo, and sync installations are pulled by the mini every six hours. See backup operations and recovery. The production WordPress database also has hourly local backups on srv1, retained for seven days.
Former-member cleanup requires a complete Sportlink snapshot no more than one hour old. When a long Laposta submission outlasts that limit, the People pipeline downloads fresh active and inactive snapshots before cleanup. Failed refreshes block cleanup; shared addresses remain protected and unsubscribes are verified.
All Laposta calls in a sync process share a queue with at least 2.5 seconds
between request starts, including list changes and cleanup reads. HTTP 429
responses are retried up to three times, respecting Laposta's Retry-After
header (see Laposta's API documentation).
Missing or invalid headers use increasing delays. A cooldown over 60 seconds
is reported as a failure without retrying early; each HTTP attempt has a
45-second deadline. Network failures and other HTTP errors are not replayed,
so an uncertain write cannot be duplicated. Existing subscription and email
notification protections remain in place. Failed items stay eligible for the
next normal sync; a partial result remains visible if recovery is exhausted.
The queue is per process; overlapping pipelines can still receive a 429 and
use the same bounded retry behavior.
The standalone comparison tools use the normal back-office login and CSV export
buttons without writing to Rondo. The scheduled importer is described below.
Set TWELVE_USERNAME, TWELVE_PASSWORD, and TWELVE_CLIENT_ID in the sync
server's .env. Chromium and Python 3 (standard-library ZIP reader) are required.
Run the downloader on the server as rondo:
sudo -u rondo node steps/download-twelve.js --from 2026-09-29 --to 2026-10-04
sudo -u rondo node tools/compare-twelve.js --snapshot data/twelve/snapshot-XXXXXX --fetch-rondoDates represent 06:00 Europe/Amsterdam; --to is exclusive. Historical downloads
may start at 2025-01-01; requests are split into at most 31-day chunks. Every run
creates a new private directory with three exports per chunk, SHA-256 checksums,
row counts checked against the screen, and a completion manifest. Failed runs
remain explicitly incomplete and cannot be compared. Authentication is not cached;
additional login challenges stop the run. Cron uses scripts/sync.sh twelve --scheduled,
which also imports the daily financial tables.
The comparison reads the latest 365 PDF report summaries via an authenticated
GET, or accepts a saved { "reports": [...] } reference with --reports file.json.
It produces private JSON analysis, no-sale details by transaction/product/category,
and a text comparison. It checks product gross, quantity, Businessclub, candidate
cash revenue, and the other-consumption residual. Coins use tendered value;
other payments allocate the paid share, net of deposit, over product value.
Exact fractions are rounded after daily summation. Discounts already included in
payments are not deducted again. Tab settlements do not count as new sales;
cancellation signs are normalized between exports. Shared payments use their
children, including partial no-sale amounts. For partial no-sales the basket is
context only: specific consumed products and quantities remain unknown.
This is not a full accounting
import: VAT totals, cashflow, account mutations, and invoice eligibility are not
reconciled. Unknown transaction types, missing joins and differences between the
two product exports are retained as issues. Missing PDF days are unverified, never
zero. A matching five-field comparison does not claim full PDF parity.
For previously downloaded files, an offline comparison is safe locally:
node tools/compare-twelve.js --transactions /private/path/transactions.csv \
--products /private/path/products.csv --raw /private/path/raw.zip \
--from 2025-01-01 --to 2026-10-04 --reports /private/path/reports.jsonKeep actual exports and references out of Git. Output directories are 0700 and
files 0600. Comparison exits 0 when all available reference days match with no
source issues, 2 for discrepancies/unverified source rows/no overlapping reference,
and 1 for invalid input or failed reads. Offline tests: node --test test/twelve-export.test.js.
graph LR
SL[Sportlink Club]
SYNC[Rondo Sync<br>+ SQLite databases]
ST[Rondo Club WordPress]
LP[Laposta]
FS[FreeScout]
SL -->|Members, teams,<br>functions, discipline| SYNC
SYNC -->|Members, custom fields| LP
SYNC -->|Members, parents, teams,<br>commissies, work history,<br>photos| ST
SYNC -->|Customers| FS
ST -->|Field changes| SYNC
SYNC -->|Reverse sync| SL
- Browser automation — Playwright (headless Chromium) with TOTP 2FA navigates Sportlink's UI to extract data from a system that has no API
- Hash-based change detection — SHA-256 diffing ensures only records that actually changed get synced, minimizing API calls and avoiding unnecessary updates
- State tracking — SQLite databases maintain ID mappings, sync history, and photo upload state across systems
- Pipeline locking — flock-based concurrency prevention ensures parallel cron jobs don't collide
- Operations dashboard — Manual starts confirm that the sync wrapper stayed alive and show immediate lock or launch failures inline
- Email reports — HTML summaries via Lettermint after every sync run
- Photo sync — Downloads member photos from Sportlink, uploads to WordPress with a state machine tracking each photo's lifecycle
- Reverse sync — Pushes Rondo Club field changes back to Sportlink via browser automation, retries transient Rondo API failures, normalizes Sportlink's localized date display during read-back verification, and supersedes queued intermediate values when a newer edit corrects or reverts them
Player-history reads retry a temporarily missing membership panel once after refreshing the Sportlink session. An explicit “no person for this relation code” response stops immediately and is reported separately; it never clears history. Conflicting team roles remain unchanged until their source evidence is reviewed.
Dutch name prefixes stay in Rondo's separate infix field for Sportlink members.
Sponsit may include them in the surname instead. Matching compares the complete
surname plus first name and email, retains stable source-ID precedence, and
quarantines ambiguous matches. Equivalent names keep their existing Rondo field
layout. FreeScout and the sponsor Laposta list receive the complete surname;
the regular member Laposta lists retain their separate tussenvoegsel field.
After a person merge, sponsor aliases with different emails share one primary pass. Sync preserves an existing eligible primary relation, including a manually managed Businessclub pass.
Member sync checks the surviving person's KNVB ID before following a merge.
When a merged source has a different KNVB ID, its original tracking row is
retained with retired_into_knvb_id. Reimports cannot reactivate that source,
even after the old WordPress post is permanently removed. Former-member cleanup
also leaves the surviving membership intact.
Edit automatic timings at Beheer → Sync schedules in the sync dashboard. Choose daily times, a weekly weekday, a monthly date, or a minute interval for each pipeline. Disabling a schedule keeps manual runs available and disables watchdog retries for that pipeline. All times use Europe/Amsterdam. Settings are stored privately in data/sync-schedules.json and survive code deployments.
npm run install-cron imports existing pipeline timings, backs up the crontab, and replaces only those pipeline entries with one minute dispatcher. Reinstalling preserves saved settings and unrelated cron jobs. The dispatcher uses scripts/sync.sh with its existing locks, tracking and email reports. Missed ticks are not replayed; fixed times in the missing spring hour are skipped, and repeated autumn times run once. Monthly dates absent from a month are skipped. Twelve continues its hourly check using opening windows edited in Rondo Club under Kassaomzet → Synchronisatie.
The following are the initial schedules; saved dashboard settings take precedence:
| Pipeline | Schedule | What it syncs |
|---|---|---|
| People | 4x daily | Members, parents, photos → Laposta + Rondo Club |
| Functions | 4x daily + weekly full | Commissies, free fields, work history → Rondo Club |
| FreeScout | Daily | Customer names and email addresses → FreeScout helpdesk |
| Teams | Weekly | Team rosters + work history with Sportlink relation dates → Rondo Club |
| Discipline | Weekly | Discipline cases → Rondo Club |
Sportlink-owned member fields are synchronized as desired state: when a complete
Sportlink response explicitly contains an empty game activity, the sync sends
spelactiviteit: null so Rondo Club clears the previous value. The individual
sync with --fetch (also used by Rondo Club) searches Sportlink by the exact KNVB
ID before overlaying its partial /general response, so game activity and age
class are refreshed immediately. Former members are searched with the inactive
status filter if needed. Missing, ambiguous, or incomplete search results stop
the sync before person updates; an explicitly empty activity still clears the
old value. Runs without --fetch continue to use the stored full member snapshot.
After a successful individual sync, its locally computed source hash is recorded
as synchronized so the next People run does not process the same payload again.
Team history uses the Sportlink season when a historical relation has no end date: a closed season ends on June 30. Explicit end dates and continuing current-season relations take precedence, so importing old history cannot reactivate an old role.
All times in Europe/Amsterdam timezone.
07:30 Functions sync (recent) → 08:00 People sync (1st) + FreeScout sync
10:30 Functions sync (recent) → 11:00 People sync (2nd)
13:30 Functions sync (recent) → 14:00 People sync (3rd)
16:30 Functions sync (recent) → 17:00 People sync (4th)
Sunday 01:00 Functions sync (full --all)
Sunday 06:00 Teams sync
Monday 23:30 Discipline sync
Prerequisites: Node.js 18+, a Sportlink Club account with TOTP 2FA configured.
npm install
npx playwright install chromium
cp .env.example .env # Fill in your credentialsRun a pipeline:
scripts/sync.sh people # Members, parents, photos
scripts/sync.sh functions # Commissies + free fields (recent)
scripts/sync.sh functions --all # Full commissie sync (all members)
scripts/sync.sh freescout # FreeScout customers
scripts/sync.sh teams # Team rosters + dated work history
scripts/sync.sh discipline # Discipline cases
scripts/sync.sh all # EverythingSee the Installation Guide for full setup instructions including server deployment and cron configuration.
| Document | Contents |
|---|---|
| Installation | Prerequisites, server setup, initial sync, cron |
| Architecture | System overview, schedules, field mappings, data flow |
| People Pipeline | 7-step flow, Laposta + Rondo Club field mappings |
| Teams Pipeline | Team download + work history |
| Functions Pipeline | Commissies, free fields, daily vs full mode |
| FreeScout Pipeline | Minimal customer identity sync |
| Discipline Pipeline | Discipline cases + season taxonomy |
| Reverse Sync | Rondo Club → Sportlink browser automation with parent e-mail propagation |
| Database Schema | All 4 databases, 21 tables |
| Operations | Server ops, monitoring, deploys |
| Troubleshooting | Common issues and solutions |
| Utility Scripts | Cleanup, validation, inspection tools |
Node.js 18+ · Playwright · better-sqlite3 · otplib · Lettermint · dotenv
The production sync server checks scripts/sync.sh twelve --scheduled hourly.
The club configures its active weekdays and hour windows in Rondo under
Kassaomzet → Synchronisatie. Within those windows, it imports every two hours
from the opening hour and once at closing (24 means midnight the following day).
Outside the windows it only checks Rondo settings, without opening Twelve.
An explicit scripts/sync.sh twelve remains available for manual imports. It logs
into the normal Twelve UI, validates transaction/product/raw CSV exports against
each other and the daily revenue/no-sale VAT tables, then upserts Rondo reports.
Use --dry-run for validation, --from 2025-01-01 --to 2026-10-04 for an explicit
06:00 Amsterdam range (exclusive end), or --snapshot data/twelve/snapshot-... to
resume/replay. The default includes seven completed days plus the current day;
the latter stays provisional. Credentials live only in the server .env.
Reports include hourly basket details for Rondo’s Drukte & bezetting view. Food/drink
classification stays in Rondo; split payments count once and product revenue
reconciles to daily totals. Old snapshots can be replayed to add the new details.
Snapshots are private and retained for audit. See CLAUDE.md for invariants.
RunTracker reports privacy-filtered timings per run and step to GlitchTip, with
aggregate counts only. Set GLITCHTIP_PERFORMANCE=false to disable these timings
without changing error reporting. See ops/glitchtip/README.md for retention,
sampling, and verification across Club, Sync and the website.
Sportlink login verifies the authenticated dashboard before persisting a session.
A redirect to Club alone is insufficient: its ClubAuthorizations API can reject
a newly issued session after successful two-factor authentication. Persistent
HTTP 401 responses are reported explicitly; an initial 401 followed by a successful
SPA token refresh remains recoverable. Do not log tokens or authentication URLs
with query parameters while diagnosing this failure.