Nümi architecture

This document describes the high-level architecture of the Nümi application: layout of packages, request flow, and main subsystems.

Tech stack

Top-level layout

DNR-style flow (Data – Network – Render)

So: data layer (db + model) → network layer (api + handlers) → render (templates + static JS). Business rules live in service and are used by api/handlers.

Request flow

HTML pages (browser)

  1. Request hits a route in main.go (e.g. /, /dashboard, /journey/, /superadmin).
  2. Middleware may run (e.g. SecurityHeadersMiddleware; BrowserAuthMiddleware for superadmin).
  3. Handler in main.go or handlers/ loads data (config, quote, etc.), parses a template, executes it, writes HTML.
  4. Some handlers do not call repositories (e.g. dashboard only passes config/quote); others do (e.g. superadmin).

JSON API (authenticated)

  1. Request to /api/* (e.g. /api/journeys, /api/settings).
  2. AuthMiddleware verifies Clerk Bearer token and sets userID (and optionally userEmail) in context.
  3. Handler in api/ or handlers/ reads context, path, and body; calls repositories and/or services; returns JSON.
  4. Settings: The wired route is GET/POST/PUT /api/settings handled by handlers.SettingsHandler, which uses the authenticated user ID from context (no path segment).

Webhooks

Dependency flow (from main.go)

Key subsystems

Journeys and levels

Settings and users

Notifications and email

Security and middleware

Configuration (env)