Self-hosted platform architecture
This describes a self-hosted operations platform for CYC Community Sailing Center, built on the GCP project
(cyc-admin-scripts, us-west1) and the Pulumi stacks in this repo and isthmia. It starts from infrastructure — where
things run, the database, identity, backups, monitoring — then layers on the Clubspot sync and the CRM
as the first two applications.
The guiding split: adopt maintained software for the hard, security-critical parts (login, the permission engine, the database, backups), and write org-specific glue on top of their APIs. Clubspot stays the registration source of truth for now; the CRM is a derived, enriched store that everything else reads from.
Data model and table-level design are deliberately out of scope here — those belong in a design doc.
Principles
- One source of truth per fact. Clubspot owns registration-time data; the CRM owns the org-wide view of people.
- Everything rebuildable from git. Infra and workloads in Pulumi, and no secret values in git — never a hand-configured box only one person understands.
- Least privilege by default, because this platform holds minors’ medical and emergency data.
- Authorization is relationship-based, not just role-based. What you can see depends on how you relate to a record — a parent to their child, a team family to the rest of the team.
- Small bespoke surface. Generate the glue; run maintained platforms for the load-bearing pieces.
- Extend existing patterns (
@cyc-seattle/platform’sWebService,Workload, andScheduledJob, with Kubernetes Secrets) instead of inventing new ones.
Target topology
Cloud DNS ──► GKE Gateway (TLS, routes by hostname) │ ┌───────────────▼────────────────┐ staff (Workspace) ───►│ Google OIDC + Authentik │ login for everyone; families, coaches ───►│ │ external users on any Google account (any Google acct) └───────────────┬────────────────┘ │ ┌──────────────────────┴──────┐ ▼ ▼ Directus sail-team (permission engine, (cycsail.team: plans, roster, REST/GraphQL, MCP) as the signed-in user) │ Cloud SQL (Postgres, managed backups + PITR) ▲ Clubspot ──► sync job (Kubernetes CronJob) ──► CRM (via Directus API) (source of truth) backups: DB + files ──► csc-backups project (us-central1), twice a day monitoring: Cloud Logging ──► Cloud Monitoring alerts ──► emailCommitted decisions
- CRM: Directus. Chosen for its relationship-based, filter-driven permission engine — the feature that expresses “a parent sees their child’s medical information” and “a team family sees the team’s roster” server-side.
- Identity: Authentik, at
login.cycsail.team. Everyone signs in with a Google account or an emailed link; no one is forced onto a@cyccommunitysailing.orgaddress. - Compute: GKE Autopilot, from the
infrastack (cyc-seattle/isthmia#231). Every surface runs as a container in its environment’s namespace, behind the shared Gateway. The syncs are CronJobs.
Infrastructure
Database
Cloud SQL for PostgreSQL. One instance holds the app databases; managed backups, point-in-time recovery, and
patching matter most on the one dataset that can’t be recreated. Runs on db-g1-small; Cloud SQL’s shared-core
tier now requires Enterprise edition. Self-hosted Postgres on a VM would be cheaper, but the CRM carries medical
data, so managed durability earns its cost here.
Identity and authorization
Two separate concerns. Keep them separate.
Authentication — Authentik. Every app that speaks OIDC (Directus included) points at Authentik, which signs a user in through Google or an emailed link. sail-team signs in through Directus.
- Staff sign in with Workspace accounts. You control MFA and offboarding (disable the account, access is gone). Sensitive access — medical and emergency data — is reserved for these accounts.
- Families and coaches sign in with any Google account. The
group-policieshook links each login to a person record by email, once, so authorization rules have an identity to resolve against (access.md). - Authenticating is not authorizing. A new login is Community, which sees only its own family. An admin makes someone Crew, and groups give staff the rest (access.md).
- The sign-in page says “CYC Sail Team”, with CSC’s logo and a sailing photo beside the form. Sail Team serves
both pictures from its
public/sign-in/. The page names the app you’re continuing to, and Directus’s application is named “CYC Sail Team”, since Sail Team signs in through it. Every page of signing in and out has that look, because theauthentikstack owns each flow they use, in place of Authentik’s built-in ones.
Authorization — relationship-based, enforced by Directus. Access derives from how the signed-in person relates to a record, not from a static role alone. A parent can view their own child’s medical information, and a race-team family can view every team’s roster. Directus’s filter-based permission engine evaluates these rules server-side against the data graph, the same in the Data Studio, the API, and MCP. This is why Directus is the committed choice over a grid tool with coarser permissions. access.md has the roles and policies.
If the rules ever outgrow Directus filters — delegated, assistant, or time-boxed access — introduce a dedicated relationship-based authorization service (OpenFGA or SpiceDB) that the apps query. Not needed to start.
Secrets
Pods read Kubernetes Secrets that Pulumi writes, and never call Secret Manager, so a pod needs no IAM for its secrets.
- Generated values (database passwords, Directus’s key and secret, tokens, OIDC client secrets) are
randomresources in the owning project’s state, encrypted by that environment’s KMS key. - Hand-set values (the Directus license key, the Google OAuth client, the Clubspot login) stay in Secret Manager, set out of band. The deploy reads them.
Nothing sensitive is in git. Manual setup §5 and isthmia’s manual setup §3 list each secret.
Networking, TLS, DNS
- Cloud DNS zone for the chosen domain; a subdomain per surface (
directus.,login., …), and apps sharecycsail.teamby path. - TLS at the GKE Gateway, with a Certificate Manager certificate from the
infrastack. - Cloud SQL has only a private IP. No database port is exposed publicly.
Backups
Non-negotiable given the data. Target RPO ≤ 12h (minutes with PITR) and RTO of a few hours (rebuild from Pulumi + config, restore data).
- Database: Cloud SQL automated backups + point-in-time recovery, inside the instance.
- Directus files: a versioned Cloud Storage bucket per environment, which keeps a deleted or replaced file for 30 days.
- Copies outside it: twice a day, each prod database as plain SQL, Directus’s files, and Pulumi’s prod state go
to
csc-backups, a project of its own inus-central1. A database copy can’t be deleted for 35 days. - Verify: a restore drill each quarter. A backup you haven’t restored is a hope.
- Alerting: an email when a run fails or nothing has been copied in 23.5 hours.
backups.md has what’s kept, the drill, and how to restore.
Monitoring
Light; you’re already in GCP.
- Logs from every pod go to Cloud Logging. isthmia’s
mise run logstails a workload’s. - Job alerts, from the
infrastack: any prod Job that fails, and any CronJob with no successful run in 3 hours, emails the maintainer. - Uptime checks, from the
infrastack: each public address, every 5 minutes from 3 regions. An address that fails from 2 of them for 5 minutes, or a certificate with under 14 days left, emails the maintainer.
Deploy model
- Shared cloud resources (the VPC, Cloud SQL, DNS zones, the cluster, IAM) live in this repo’s
bootstrapandinfrastacks. - Apps are Pulumi projects, each deploying its workloads to the cluster.
authentikis this repo’sstacks/authentik, and sail-team’s app is its own repo’sstacks/app. Directus, its schema and roles, and the syncs are this repo’sbackendstack (cyc-seattle/workplace#6). Actions runs the tests on every pull request, and deploysmainto prod after a maintainer approves. Prod builds an image only when its tag isn’t in the registry yet. - Scheduled jobs (the syncs) are Kubernetes CronJobs, hourly.
- Environments.
prodis the one environment, a namespace in the cluster on regular capacity. The integration tests run on a throwaway stack instead, with synthetic data, Mailpit, and the Clubspot and Workspace fakes (testing.md, cyc-seattle/platform#171). - Availability. sail-team runs two replicas in prod. Directus and Authentik’s server run one each, which Autopilot won’t move to consolidate nodes. A second Directus needs Redis, to share its caches (cyc-seattle/isthmia#253).
Layer 1: Clubspot integration
A one-way sync: Clubspot → CRM. Clubspot stays authoritative for registration data; the hub enriches and redistributes it. See syncs.md for the implementation.
Because the hub — not Clubspot — becomes what the apps, and later Listmonk/Groups/FreeScout, read from, this one job is the seam that makes an eventual Clubspot replacement a contained change rather than a rebuild.
Layer 2: CRM
Directus on top of the CRM database — the permission engine, the staff admin UI, and the REST/GraphQL API everything else calls. The data model lives in crm-schema.md.
The relationship rules need a Directus license (cyc-seattle/isthmia#172), which prod and the CI stack hold. A hook extension,
community-query-guard (stacks/backend/), rejects a query that filters or sorts on a field the viewer can’t read on
every row, since Directus’s own checks would let it probe hidden values (access.md).
Apps are thin clients: they call the Directus API as the signed-in user, so the rules stay enforced server-side
and the app itself carries no security logic. sail-team, at cycsail.team, is the first: planners read plans there,
and families read rosters at /roster. Every role can also open the Data Studio, and connect an agent over MCP, with
the same access (backend.md).
Data protection
This platform holds minors’ medical and emergency information, and lets families read scoped slices of it: a parent sees their own child’s. Treat that as the hardest constraint.
- Encryption at rest — GCP defaults; CMEK if you want the key. Backups encrypted.
- Least privilege — relationship-based rules in Directus, enforced server-side. A new login sees only its own family.
- Audit — Directus activity log for data access/changes; Cloud Audit Logs for infra.
- Retention — set and honor a policy for youth data; check COPPA and state requirements before go-live.
- Access reviews — revisit group and role membership each season as people rotate.
- Family access is the highest-liability surface — external parents reading medical data. The failure mode is
one family seeing another’s information, so
features/authorization.featureandfeatures/crm.featurepin the rules, and the query guard closes the probes Directus’s own checks allow.
Cost
The platform runs on one GKE Autopilot cluster, one shared-core Cloud SQL instance, and backup storage. Directus, Authentik, Postgres, and Caddy are all open source, so nothing is licensed per seat. That is the point: the cost stays flat as volunteers, coaches, and guardians grow, where per-seat SaaS charges for every one of them.
Read current figures from the billing console.
Phased roadmap
Ordered by permission blast radius: internal and low-stakes first, external access to sensitive data last.
- Phase 0 — Infrastructure. Done: the cluster, Cloud SQL, Secret Manager, DNS/TLS, backups outside Cloud SQL, and monitoring are all live via Pulumi (cyc-seattle/platform#170).
- Phase 1 — Identity. Done: everyone signs in to Directus through Authentik, and the
group-policieshook links each login to a person by email. - Phase 2 — Staff CRM + Clubspot sync. Done: Directus holds the CRM, and clubspot-sync keeps it current.
- Phase 3 — Coach access. Done: coaches an admin vets are Crew, who see every roster, contact detail, and medical profile (cyc-seattle/workplace#6).
- Phase 4 — Family access. Done: a family sees its own children’s records and medical information, and a race-team family sees every team’s roster, with the contact details of adults who chose to share (cyc-seattle/isthmia#241).
- Google Group membership sync. Done. gsuite-sync syncs class and program group membership, managers, owners, and settings from the CRM. See syncs.md.
- Later. Listmonk (cyc-seattle/isthmia#71), FreeScout (cyc-seattle/isthmia#67) — both reading from the same hub and identity layer.
Open decisions
- ReBAC escalation: whether/when Directus filters give way to OpenFGA/SpiceDB. Revisit if rules get delegated or time-boxed.