Summary: The former 7Mind backend, a Phoenix modulith on GKE. Since the 2026-09-14 migration to the Gymondo platform it no longer serves the apps or the website. Its code still renders the content catalogue (as a Lambda on AWS), and its production deployment stays up as the parity reference for that catalogue and for a few leftover GCP workloads until Google Cloud is switched off. Sources: direct code inspection (mix.exs, .github/workflows/, config/runtime/, lib/backend/, k8s/base/, Justfile, git log to 2026-09-29); origin/main read on 2026-11-09 (terraform/environment/, terraform/modules/backend/, terraform/environment/staging/RETIRED.md, lib/backend/web/shared/plugs/discontinued.ex, git log to 2026-10-29); Gymondo-git/function-sevenmind-legacy-gateway README and commit 8905d51 (TP-606); Gymondo-git/terraform workspace app-sevenmind-catalogue-builder; Slack 7m_product-team-public Last updated: 2026-11-09
Status: legacy (read this first)
Until 2026-09-14 this was the single source of truth for 7Mind’s business logic. On that day 7Mind moved to the Gymondo platform (see platform-unification). The magic.7mind.* hosts the app and website call now point at the Gymondo edge, where function-sevenmind-legacy-gateway answers the same API from Gymondo services. Do not use this code to explain what a client sees today. Auth, subscriptions, history, favourites, streaks, insurance activations and account deletion are all served by Gymondo now.
What still runs from this repo, as of 2026-11-09:
- Content rendering. The 7Mind catalogue is still rendered by this Elixir code, in two ways:
- The “catalogue builder”, an Elixir release packaged as an AWS Lambda container (TP-587). It renders the full catalogue from Contentful to S3 every 30 minutes, and the gateway serves every content screen from that artifact (test since 2026-09-24, production since 2026-10-05). It also runs the daily Algolia reindex, which it took over from the GKE deployment on 2026-10-07. Its CI is
.github/workflows/deploy-catalogue-builder.yml(GitHub OIDC into AWS):maingoes to test, a published release to production. - A keyed
/gateway/content/*channel ongateway.7mind.de. It was the gateway’s live source until 2026-10-05. Since 2026-10-07 (TP-606) the gateway no longer falls back to it: if the artifact cannot be loaded, the gateway refuses to start. The channel is kept only as the reference the gateway’s parity tests compare the artifact against. The staging channelgateway.6mind.dewent with the staging plane.
- The “catalogue builder”, an Elixir release packaged as an AWS Lambda container (TP-587). It renders the full catalogue from Contentful to S3 every 30 minutes, and the gateway serves every content screen from that artifact (test since 2026-09-24, production since 2026-10-05). It also runs the daily Algolia reindex, which it took over from the GKE deployment on 2026-10-07. Its CI is
- Parallel history recording. The Rudderstack to Pub/Sub path still writes history and streaks here, under the old UUIDs. Events that carry a numeric Gymondo id are skipped (#1101). Delta imports from
sevenmind_history_recordsinto Gymondofunction-statisticwere run after the cutover. - 7Sleep hosts.
backend.7mind.deandmagic.7sleep.destill route to this deployment (the production ingress notes thatbackend.7mind.deis not a 7Mind host, it serves 7Sleep). Since 2026-10-06 (TP-604) the 7Sleep API answers 410 Gone on every path except the Chargebee webhook (/monetization/webhooks/chargebee), which keeps refunds and cancellations on the 7Sleep site syncing. 7Sleep itself is sunset; its customers were migrated to 7Mind on 2026-09-14. - Other GCP residents around it: ZPP certificate generation (
zpp-certs.7mind.de), the old admin panel (still used read-only for UUID lookups), api-v1, micro-payments, SuperTokens and the identity service, Cloud SQL, and the production Pub/Sub topics. The Insurances and Mondia Pub/Sub subscribers were retired on 2026-10-12.
Only production runs. The staging plane was destroyed on 2026-10-07 (193 resources: the deployment, ingresses, 29 Pub/Sub topics, 38 subscriptions and 38 Datadog monitors), see terraform/environment/staging/RETIRED.md.
No shutdown date for the GKE clusters or the GCP project is recorded. Datadog alerts from this service still fire in 7m_backend_health.
The rest of this page describes the architecture as it was before the migration. It is accurate for the code, not for production traffic.
Purpose (before 2026-09-14)
The Elixir/Phoenix backend was the single source of truth for 7Mind’s business logic. It served the 7mind-mobile-apps-monorepo, the nuxt-website, and 7Mind’s B2B2C insurance partner flows (Barmer, DAK, Charité). It owned user accounts, subscriptions, content delivery, practice tracking, insurance certificates, and all persistent state. The codebase supported both the 7Mind and 7Sleep apps from a single backend with app-specific routing.
Stack (pre-migration)
- Elixir ~> 1.18 / OTP 27
- Phoenix 1.8.0 (three separate Endpoints for internal/public/admin traffic)
- Ecto 3.12 + PostgreSQL (multi-repo pattern: one Ecto repo per domain)
- Oban 2.19 (background job processing and cron scheduling)
- Broadway 1.1 + Broadway Cloud Pub/Sub 0.9 (Google Pub/Sub event consumption)
- Goth 1.0 (GCP service account authentication)
- Tesla 1.3 / Finch 0.13 (HTTP clients for external calls)
- Cachex 3.6 / Nebulex 2.6 (in-process and distributed caching)
- Joken 2.6 + Joken JWKS 1.7 (JWT validation)
- Phoenix LiveView 1.0 (admin panel)
- OpenTelemetry (distributed tracing, exported to Datadog)
- Prometheus Ex (metrics endpoint)
Key Files / Entry Points
mix.exs: project definition, all deps, aliases, release configlib/backend/web/public_api/endpoint.ex: Phoenix Endpoint for port 4100 (mobile clients)lib/backend/web/internal_api/endpoint.ex: Phoenix Endpoint for port 4000 (service-to-service)lib/backend/web/admin_panel/endpoint.ex: Phoenix Endpoint for port 4200 (LiveView admin)lib/backend/web/public_api/router.ex: app-specific routing viax-appheader (7mind vs 7sleep)config/compiletime.exs: compile-time config entry pointconfig/runtime/prod.ex: all production env var declarationsJustfile: task runner for dev, test, deploy, and secrets commandsterraform/: the Terraform that deploys this service (environment/production, the retiredenvironment/staging,modules/backend)k8s/base/: Helm chart templates; no deploy workflow uses them any more.github/workflows/: CI/CD pipeline definitionsguides/: architecture and developer guides
Deployment
Target: GKE application-cluster in the europe-west3 region. The deployment is declared in this repo’s own Terraform (terraform/environment/production and terraform/modules/backend: the Kubernetes deployment, the ingresses for the magic, gateway, backend and 7Sleep hosts, the Pub/Sub topics and subscriptions, and the Datadog monitors). State lives in the GCS bucket 7mind-terraform. See terraform.
Production:
- Trigger: GitHub Release published
- Registry:
europe-west3-docker.pkg.dev/sevenmind-infrastructure/application-cluster-repo - URL:
https://backend.7mind.de - Workflow:
.github/workflows/deploy-to-production.yml, which builds the image and applies the production Terraform root from CI (reusable-terraform-deploy-to.yml)
Staging: retired. The staging plane was destroyed on 2026-10-07, and deploy-to-staging.yml was deleted so the next merge would not rebuild it. The root stays in terraform/environment/staging so the destroy can be reversed with an apply.
Deploy flow: build Docker image → push to GCP Artifact Registry → Terraform applies the backend module to GKE → a migration init container runs the Ecto migrations → Datadog deployment event notified.
Admin panel: https://panel.backend.7mind.de (port 4200, LiveView, work-in-progress)
K8s services (all ClusterIP):
backend-internal-api→ port 4000backend-public-api→ port 4100backend-admin-panel→ port 4200- Headless service for distributed Erlang clustering
Dependencies
External services:
- Chargebee: subscription billing for both 7Mind and 7Sleep (separate namespaces/API keys)
- Braze: marketing automation and push notifications
- SuperTokens — identity service used by 7Sleep (7Mind used native Phoenix sessions; see supertokens-auth)
- Cloudflared: tunnel-based auth for admin access (JWT audience validation)
- Algolia: content search indexing (separate indices per app)
- Rudderstack: analytics event forwarding (separate write keys per app)
- Aury — vendor behind the in-app AI chat companion users see as “Seven” (base URL + API key + partner ID). 7Mind is Aury’s partner here, this is unrelated to 7Mind’s own B2B2C insurance partners. See aury-companion
- Datadog: APM, metrics, and deployment tracking
- Google Pub/Sub: async event bus (consumed via Broadway)
- Google Cloud Storage: ZPP insurance certificate storage (Prevention domain)
- Fastspring: legacy billing (admin panel access only)
- Contentful: CMS for meditation content (via internal content service)
Internal:
- api-contracts: shared API type definitions consumed by this repo
- Internal
CONTENT_SVC_URLandPAYMENTS_SVC_URL: separate microservices called over HTTP
Integration Points
Current (since 2026-09-14):
- function-sevenmind-legacy-gateway — its parity tests compare the catalogue artifact against the content channel on
gateway.7mind.de. The gateway itself has not called the channel at runtime since 2026-10-07 - Gymondo-git/terraform
app-sevenmind-catalogue-builder— runs the catalogue builder image built from this repo - Google Pub/Sub — still consumes Rudderstack events in parallel to the Gymondo path
Before the migration:
- 7mind-mobile-apps-monorepo: primary consumer of the Public API (port 4100) for both 7Mind and 7Sleep mobile apps
- nuxt-website: consumes Public API for SSR data fetching and web app features
- B2B2C insurance partners — Barmer, DAK, Charité and generic insurance activation flows in the
monetizationandpreventiondomains
Conventions
Modulith pattern: all domains live in lib/backend/ as top-level folders. Domains must not call each other directly; they communicate via the event bus or explicit public interfaces.
Domain modules (each owns its own Ecto repo, supervisor, and public API surface):
access: authorization and access controlactivation: user onboarding workflowsanalytics: event tracking (Rudderstack)content: CMS content delivery, Algolia search, Provider pattern for 7Mind vs 7Sleepexternal: thin wrappers around third-party clients (Braze, Aury, Payments, Rudderstack)monetization: subscriptions and billing (Chargebee, Fastspring, Barmer, Mondia)practice— meditation session tracking, progress, streaks, history, and the AI companion context and access rule (see aury-companion)prevention: ZPP insurance certificates (PDF generation, Cloud Storage, Braze email)shared: event bus, observability, config helpers, OTP utilities, HTTP client poolsuser_identity: authentication, sessions, SSO (Apple, Google, Facebook), SuperTokensweb: Phoenix endpoints and router definitions only; no business logic
Multi-database: each domain has its own DATABASE_URL env var and Ecto repo. Migrations are domain-scoped.
App routing: the Public API uses the x-app header (or hostname) to route between SevenMindRouter and SevenSleepRouter. Both apps share the same Phoenix process.
Documentation required: all modules and public functions must have @moduledoc and @doc. Enforced by mix doctor in CI.
Code quality gate: mix check runs credo, dialyzer, doctor, sobelow, mix_audit, and styler. All must pass before merge.
Secrets management: Kubernetes secrets managed via just secrets_* commands wrapping kubectl. Never committed to the repo.
Local dev: requires Docker Compose for Postgres and Pub/Sub emulator. just server handles full startup including DB init and asset building.
Agent Change Log
2026-05-15: stub created, awaiting content seeding from code inspection
2026-05-15: initial knowledge extraction from codebase
2026-08-26 — corrected the Aury entry: one vendor, the AI chat companion users see as “Seven”, not a B2B2C partner integration. Added the companion access rule (premium or trial or an account under 4 days old that never monetized), enforced on session start, and exposed to clients as unlockedFeatures alongside the existing visibleFeatures on the account endpoints. See aury-companion
2026-10-06 — marked legacy after the 2026-09-14 migration to the Gymondo platform: added the current role (content fallback and catalogue builder, parallel history recording, 7Sleep hosts, leftover GCP workloads) and pointed readers to platform-unification and function-sevenmind-legacy-gateway
2026-11-09 — checked against origin/main: no content fallback since TP-606, staging plane destroyed 2026-10-07, 7Sleep API answers 410 since TP-604, Algolia reindex moved to the catalogue builder, production deployed by this repo’s own Terraform from CI