Deploy Swetrix Analytics Template

Privacy-first analytics with funnels, sessions, and events on Railway.

Deploy Swetrix Analytics Template

Just deployed

Just deployed

/data

/var/lib/clickhouse

Just deployed

Deploy and Host Swetrix Analytics with Railway

Deploy on Railway

Privacy-first web analytics with funnels, sessions, custom events, and performance tracking — full Swetrix CE on Railway.

Live demo: gateway-production-0764.up.railway.app/login

What you get

  • Swetrix CE dashboard — funnels, custom events, sessions, performance
  • Five-service stack wired on private networking
  • ClickHouse on a volume — events survive redeploys
  • One public URL via nginx gateway (this repo)
  • First-user signup — no shared default admin password

About Swetrix

Swetrix is open-source, privacy-friendly analytics. The Community Edition tracks page views, custom events, funnels, sessions, and errors. Only a handful of Swetrix templates exist on Railway (~7 listings) compared to thousands for Umami — room to stand out with a complete, documented stack.

About Hosting Swetrix

This template deploys the official Swetrix v5.4.1 images with Railway Redis, ClickHouse, and an nginx gateway. Only the gateway is public; API, frontend, Redis, and ClickHouse use private DNS.

Architecture

                    ┌─────────────┐
  Browser ──HTTPS──►│   Gateway   │ (this repo)
                    └──────┬──────┘
           ┌───────────────┼───────────────┐
           ▼               ▼               ▼
    ┌────────────┐  ┌────────────┐  ┌────────────┐
    │ Swetrix FE │  │Swetrix API │  │ ClickHouse │
    │  :8080     │  │   :5005    │  │  (volume)  │
    └────────────┘  └──────┬─────┘  └────────────┘
                           │
                    ┌──────▼──────┐
                    │    Redis    │
                    └─────────────┘

Environment Variables

Gateway (this repo)

VariableDescriptionSecretExample/Notes
SWETRIX_API_HOSTPrivate hostname of Swetrix APINo${{Swetrix-API.RAILWAY_PRIVATE_DOMAIN}}
SWETRIX_FE_HOSTPrivate hostname of Swetrix FENo${{Swetrix-FE.RAILWAY_PRIVATE_DOMAIN}}
SWETRIX_API_PORTAPI portNo5005
SWETRIX_FE_PORTFE port (Railway $PORT)No8080

Swetrix API (swetrix/swetrix-api:v5.4.1)

VariableDescriptionSecretExample/Notes
SECRET_KEY_BASEAuth/session secretYes${{secret(64)}}
BASE_URLPublic Swetrix URLNohttps://${{Gateway.RAILWAY_PUBLIC_DOMAIN}}
REDIS_HOSTRedis hostnameNoredis (short name — not .railway.internal)
REDIS_PORTRedis portNo6379
REDIS_PASSWORDRedis passwordYes${{Redis.REDISPASSWORD}}
CLICKHOUSE_HOSTClickHouse HTTP endpointNohttp://${{ClickHouse.RAILWAY_PRIVATE_DOMAIN}}
CLICKHOUSE_PORTClickHouse HTTP portNo8123
CLICKHOUSE_DATABASEClickHouse databaseNoanalytics
CLICKHOUSE_USERClickHouse userNodefault
CLICKHOUSE_PASSWORDClickHouse passwordYesSame value as ClickHouse service
SMTP_MOCKSkip real email (MVP)Notrue
DISABLE_REGISTRATIONLock registration after first userNotrue
CLIENT_IP_HEADERClient IP behind proxyNox-forwarded-for

Swetrix FE (swetrix/swetrix-fe:v5.4.1)

VariableDescriptionSecretExample/Notes
BASE_URLPublic Swetrix URLNohttps://${{Gateway.RAILWAY_PUBLIC_DOMAIN}}

ClickHouse

VariableDescriptionSecretExample/Notes
CLICKHOUSE_DBDatabase nameNoanalytics
CLICKHOUSE_USERUserNodefault
CLICKHOUSE_PASSWORDPasswordYes${{secret(32)}}

Attach a volume at /var/lib/clickhouse.

Deploy and Host

  1. Create a new Railway project.
  2. Add Redis (Database → Redis).
  3. Add ClickHouse — Docker image clickhouse/clickhouse-server:25.8-alpine, volume at /var/lib/clickhouse.
  4. Add Swetrix APIswetrix/swetrix-api:v5.4.1 with variables above.
  5. Add Swetrix FEswetrix/swetrix-fe:v5.4.1 with BASE_URL.
  6. Deploy this repo as Gateway with host/port variables above.
  7. Enable public HTTP on Gateway only.
  8. Open the gateway URL → register first user at /login.
  9. Create a Swetrix project and add the tracking script.

Or run scripts/deploy-swetrix-railway.ps1 from the monorepo.

Common Use Cases

  • Funnels and custom events without GA4
  • Privacy-first analytics for side projects and MVPs
  • Session and performance tracking you self-host
  • Teams that want Swetrix CE without VPS Docker Compose

Why not Umami?

Choose Swetrix when you need funnels, custom events, or session-level analytics. Choose Simple Analytics (same author) when you want a tiny FastAPI app you own outright.

Troubleshooting

IssueFix
API cannot connect to RedisSet REDIS_HOST=redis (short name), not redis.railway.internal
Gateway 502Set SWETRIX_FE_PORT=8080 — Railway overrides FE port from 3000
ClickHouse crash loopVolume must mount at /var/lib/clickhouse (not /data). Wipe volume if corrupted from wrong path.
Registration closedExpected after first user when DISABLE_REGISTRATION=true

Dependencies for Swetrix Hosting

ServiceSourceVolume
GatewayGitHub repo (this template)
Swetrix APIswetrix/swetrix-api:v5.4.1
Swetrix FEswetrix/swetrix-fe:v5.4.1
RedisRailway Redis plugin
ClickHouseclickhouse/clickhouse-server:25.8-alpine/var/lib/clickhouse

Deployment Dependencies

Why Deploy Swetrix on Railway?

One HTTPS URL, five services on private networking, ClickHouse on a volume — Swetrix CE without maintaining Docker Compose on a VPS. Recommend 2GB+ RAM for ClickHouse.

Marketing site

Preview website/index.html. Marketplace icon: export website/icon.svg to 512×512 PNG.

Author

romeoxt — herbylegall9@gmail.com

License

MIT (this template). Swetrix CE is licensed separately.


Template Content

More templates in this category

View Template
Typesense vs Meilisearch
self-hosted Typesense vs Meilisearch

onepush
0
View Template
Betterlytics
Betterlytics is a cookieless analytics platform GDPR-compliant.

OpenSource Templates
27
View Template
Finance Tracker
Private multi-user household finance ledger with budgets and CSV import.

wotonews
0