Skip to content

Infrastructure Overview

How the tomoda app fits into production. This section is app-perspective — what runs where, how a request reaches the backend, how secrets get into a Pod. For the infrastructure itself (Terraform, K8s manifests, Argo CD, cluster operations), see the separate devops docs.

Environments

Three environments. Each is intentionally a strict superset of the previous one so surprises in production are minimized.

Local

Everything runs on the developer's machine. Infra dependencies (Postgres, Redis, RustFS, Photon) come up via docker-compose.dev.yml; the Go backend and the Expo frontend run outside Docker for fast iteration and hot reload.

Component How it runs locally
Postgres + PostGIS kartoza/postgis:15-3.3 container on :5432
Redis redis:7-alpine container on :6379
Object storage RustFS container on :9000 / :9001 (S3-compatible)
Geocoder Photon container on :2322
Backend (Go) go run / Air hot reload, served on :8080
Frontend (Expo) task dev:frontend, Metro on :8081

task dev orchestrates this — see Docker Compose and Getting Started.

Dev

The tomoda-dev namespace on the k3s cluster (one OVH bare-metal server in Beauharnois, Quebec), used for integration testing and pre-prod validation. Application manifests live in the separate devops/ repo at k8s/apps/tomoda/overlays/dev/. Argo CD watches that repo and reconciles cluster state. Secrets are sourced from GCP Secret Manager via External Secrets Operator.

Prod

Same cluster as dev, isolated in the tomoda-prod namespace. Argo CD reconciles k8s/apps/tomoda/overlays/prod/.

How prod actually runs

Prod is not managed databases. Postgres runs in-cluster as a CloudNative-PG (CNPG) cluster on local NVMe, Redis runs in-cluster as the Bitnami Helm chart. All object storage (user media, CNPG backups, Photon indexes, seed sets) is Cloudflare R2. For the full story, see DevOps → Architecture.

Production topology (app-perspective)

User
iOS / Android / Web
↓
Cloudflare
assets Worker
assets.tomoda.life
↓
R2 · tomoda-assets-prod
DNS + proxy
api / app / www
↓
k3s · OVH Beauharnois
Traefik Ingress
↙   ↘
Backend Pod
Go · :8080
Frontend Pod
Nginx · :8081
↓
CNPG Postgres
+ PostGIS
Bitnami Redis
Photon
:2322 ClusterIP
Media goes to R2 via presigned PUT and comes back through the assets Worker; API and web traffic reach Traefik on the server's public IP (prod proxied by Cloudflare). CNPG backups and Photon's index also live in R2.

Details worth calling out:

  • Two Cloudflare paths. Media (assets.tomoda.life) is served by a Worker in front of R2 that checks signed URLs and caches at the edge. API + web traffic (api.tomoda.life, app.tomoda.life, www.tomoda.life) resolves to the server's public IP, where Traefik terminates TLS; prod hostnames are proxied through Cloudflare with origin mTLS.
  • One ingress, two backends. Traefik routes /api/v1/* and /ws/* to the Go backend Pod, everything else to the frontend Pod (Nginx serving the Expo web static export). See k8s/apps/tomoda/base/ingress.yaml in the devops repo.
  • Frontend is static. The frontend/ container is a multi-stage build (Node 20 → Nginx Alpine). EXPO_PUBLIC_* env vars bake in at build time — see Container images.
  • Photon is internal-only. The Photon Service is ClusterIP at http://photon.platform.svc.cluster.local:2322. No external ingress.
  • Outbound for third-party APIs. Stripe, Resend, Google OAuth, Google Places — all called from the backend. Webhooks come back inbound through Cloudflare → Traefik → backend.

How the app gets there

Concern App side Infra side (devops repo)
Image build images.yml → GHCR OVH bare metal (registry pull)
Deployment n/a — GitOps via Argo CD Argo CD, Tomoda K8s app, Deploy runbook
Postgres DSN env var (DB_HOST, DB_USER, DB_PASSWORD) CNPG cluster
Redis URL env var (REDIS_*) Bitnami Redis
Object storage S3 SDK against R2 via object-storage-credentials; signed URLs with ASSET_SIGNING_KEY Cloudflare → R2
Photon PHOTON_URL env var → in-cluster service DNS Photon
Secrets envFrom: backend-secrets and object-storage-credentials Secrets Management, External Secrets
TLS n/a — ingress-level cert-manager, TLS
DNS n/a Cloudflare, External-DNS

Hosting

  • Cluster: k3s on one OVH Rise bare-metal server, Beauharnois (BHS)
  • Images: ghcr.io/tomoda-labs/tomoda-{backend,frontend}
  • Object storage: Cloudflare R2 (tomoda-assets-{dev,prod} and infra buckets)
  • GCP project development-485000: Secret Manager, Google OAuth clients, Places API only

What's not in this section