# mrcdprm/nabiz-analytics architecture

> Architecture diagram of the GitHub repository mrcdprm/nabiz-analytics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrcdprm/nabiz-analytics
- Repository: https://github.com/mrcdprm/nabiz-analytics

## Overview

Nabız is a privacy-focused, cookie-free web analytics service. A site embeds the tracker; it sends privacy-filtered events to the Go server, which records them for reporting. Users manage sites, teams, goals and funnels through the dashboard, and can view analytics or export CSV. The graph preserves these documented capabilities, plus accounts and optional subscriptions. Source excerpts establish only selected wiring; README-backed relationships are cited as documentation, while unsampled implementation details are kept at their exact enclosing paths.

Main entry points: [`internal/server/server.go`](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/server.go) (HTTP routing), [`internal/ingest/recorder.go`](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/ingest/recorder.go) (Privacy recorder), [`internal/store/store.go`](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/store/store.go) (Analytics database), [`internal/server/stats.go`](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/stats.go) (Stats and export routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tracking["Collection and privacy"]
  node_tracker["Browser tracker<br/>[nabiz.js]"]
  node_payload["Event parsing<br/>[payload.go]"]
  node_recorder["Privacy recorder<br/>[recorder.go]"]
  node_useragent["Agent parsing<br/>[useragent.go]"]
  node_salt["Daily visitor salt<br/>[salt.go]"]
  node_geo["Country lookup<br/>[geo.go]"]
end

subgraph group_server["HTTP application"]
  node_event_api["Event endpoint<br/>[event.go]"]
  node_http_server["HTTP routing<br/>[server.go]"]
  node_stats_routes["Stats and export routes<br/>[stats.go]"]
  node_site_routes["Site management routes<br/>[sites.go]"]
  node_team_routes["Team routes<br/>[team.go]"]
end

subgraph group_analytics["Analytics and storage"]
  node_event_store[("Analytics database<br/>[store.go]")]
  node_stats_engine["Analytics queries<br/>[stats.go]"]
  node_funnel_stats["Funnel analysis<br/>[funnel.go]"]
  node_goal_stats["Goal analysis<br/>[goals.go]"]
  node_periods["Reporting periods<br/>[period.go]"]
end

subgraph group_accounts["Accounts and monetization"]
  node_site_domain["Site and funnel setup"]
  node_team_domain["Membership roles<br/>[team.go]"]
  node_auth_service["Identity and sessions<br/>[auth.go]"]
  node_account_ops["Account operations<br/>[account.go]"]
  node_mail_service["Verification mail<br/>[mail.go]"]
  node_billing_routes["Billing endpoints<br/>[billing.go]"]
  node_billing_service["Plans and limits<br/>[billing.go]"]
  node_checkout["Subscription checkout<br/>[checkout.go]"]
end

subgraph group_dashboard["Dashboard"]
  node_web_entry["Dashboard navigation<br/>[main.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_dashboard_view["Analytics dashboard<br/>[dashboard.ts]"]
  node_dashboard_components["Charts and breakdowns"]
  node_settings_view["Site settings<br/>[settings.ts]"]
  node_team_component["Team controls<br/>[team.ts]"]
  node_snippet_component["Install snippet<br/>[snippet.ts]"]
end

node_site_visitor(("Site visitor"))
node_iyzico{{"iyzico payments"}}
node_dashboard_user(("Dashboard user"))

node_site_visitor -->|"loads script"| node_tracker
node_tracker -->|"sends events"| node_event_api
node_event_api -.->|"records event"| node_recorder
node_recorder -->|"parses payload"| node_payload
node_recorder -->|"looks up country"| node_geo
node_recorder -->|"hashes visitors"| node_salt
node_recorder -.->|"parses agent"| node_useragent
node_recorder -->|"writes events"| node_event_store
node_http_server -.->|"routes events"| node_event_api
node_http_server -.->|"routes reports"| node_stats_routes
node_http_server -.->|"routes sites"| node_site_routes
node_http_server -.->|"routes teams"| node_team_routes
node_stats_routes -.->|"queries metrics"| node_stats_engine
node_stats_engine -.->|"reads events"| node_event_store
node_funnel_stats -.->|"reads events"| node_event_store
node_goal_stats -.->|"reads events"| node_event_store
node_stats_routes -.->|"reports funnels"| node_funnel_stats
node_stats_routes -.->|"reports goals"| node_goal_stats
node_stats_routes -.->|"selects ranges"| node_periods
node_site_routes -.->|"manages sites"| node_site_domain
node_team_routes -.->|"manages roles"| node_team_domain
node_dashboard_user -->|"uses dashboard"| node_web_entry
node_web_entry -->|"requests data"| node_api_client
node_web_entry -->|"opens report"| node_dashboard_view
node_dashboard_view -->|"fetches metrics"| node_api_client
node_dashboard_view -->|"renders charts"| node_dashboard_components
node_web_entry -.->|"opens settings"| node_settings_view
node_settings_view -->|"renders team"| node_team_component
node_settings_view -->|"renders snippet"| node_snippet_component
node_api_client -.->|"calls API"| node_http_server
node_web_entry -.->|"checks session"| node_auth_service
node_http_server -->|"authenticates users"| node_auth_service
node_auth_service -->|"stores sessions"| node_event_store
node_account_ops -->|"stores accounts"| node_event_store
node_http_server -.->|"sends mail"| node_mail_service
node_billing_routes -->|"checks plans"| node_billing_service
node_billing_service -->|"reads subscriptions"| node_event_store
node_billing_routes -.->|"starts checkout"| node_checkout
node_checkout -.->|"requests payment"| node_iyzico

click node_tracker "https://github.com/mrcdprm/nabiz-analytics/blob/main/web/tracker/nabiz.js"
click node_event_api "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/event.go"
click node_payload "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/ingest/payload.go"
click node_recorder "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/ingest/recorder.go"
click node_useragent "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/ingest/useragent.go"
click node_salt "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/salt/salt.go"
click node_geo "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/geo/geo.go"
click node_http_server "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/server.go"
click node_stats_routes "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/stats.go"
click node_site_routes "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/sites.go"
click node_team_routes "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/team.go"
click node_event_store "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/store/store.go"
click node_stats_engine "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/stats.go"
click node_funnel_stats "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/funnel.go"
click node_goal_stats "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/goals.go"
click node_periods "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/period.go"
click node_site_domain "https://github.com/mrcdprm/nabiz-analytics/tree/main/internal/site"
click node_team_domain "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/team/team.go"
click node_auth_service "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/auth/auth.go"
click node_account_ops "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/auth/account.go"
click node_mail_service "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/mail/mail.go"
click node_billing_routes "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/billing.go"
click node_billing_service "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/billing/billing.go"
click node_checkout "https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/billing/checkout.go"
click node_web_entry "https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/main.ts"
click node_api_client "https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/api.ts"
click node_dashboard_view "https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/views/dashboard.ts"
click node_dashboard_components "https://github.com/mrcdprm/nabiz-analytics/tree/main/web/src/components"
click node_settings_view "https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/views/settings.ts"
click node_team_component "https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/components/team.ts"
click node_snippet_component "https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/components/snippet.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tracker,node_payload,node_recorder,node_useragent,node_salt,node_geo,node_dashboard_user toneBlue
class node_event_api,node_http_server,node_stats_routes,node_site_routes,node_team_routes toneAmber
class node_event_store,node_stats_engine,node_funnel_stats,node_goal_stats,node_periods toneMint
class node_site_domain,node_team_domain,node_auth_service,node_account_ops,node_mail_service,node_billing_routes,node_billing_service,node_checkout toneRose
class node_web_entry,node_api_client,node_dashboard_view,node_dashboard_components,node_settings_view,node_team_component,node_snippet_component,node_site_visitor,node_iyzico toneIndigo
```

## Components

### Collection and privacy

- [Browser tracker](https://github.com/mrcdprm/nabiz-analytics/blob/main/web/tracker/nabiz.js): `web/tracker/nabiz.js`
- [Event parsing](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/ingest/payload.go): `internal/ingest/payload.go`
- [Privacy recorder](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/ingest/recorder.go): `internal/ingest/recorder.go`
- [Agent parsing](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/ingest/useragent.go): `internal/ingest/useragent.go`
- [Daily visitor salt](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/salt/salt.go): `internal/salt/salt.go`
- [Country lookup](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/geo/geo.go): `internal/geo/geo.go`

### HTTP application

- [Event endpoint](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/event.go): `internal/server/event.go`
- [HTTP routing](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/server.go): `internal/server/server.go`
- [Stats and export routes](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/stats.go): `internal/server/stats.go`
- [Site management routes](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/sites.go): `internal/server/sites.go`
- [Team routes](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/team.go): `internal/server/team.go`

### Analytics and storage

- [Analytics database](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/store/store.go): `internal/store/store.go`
- [Analytics queries](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/stats.go): `internal/stats/stats.go`
- [Funnel analysis](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/funnel.go): `internal/stats/funnel.go`
- [Goal analysis](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/goals.go): `internal/stats/goals.go`
- [Reporting periods](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/stats/period.go): `internal/stats/period.go`

### Accounts and monetization

- [Site and funnel setup](https://github.com/mrcdprm/nabiz-analytics/tree/main/internal/site): `internal/site`
- [Membership roles](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/team/team.go): `internal/team/team.go`
- [Identity and sessions](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/auth/auth.go): `internal/auth/auth.go`
- [Account operations](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/auth/account.go): `internal/auth/account.go`
- [Verification mail](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/mail/mail.go): `internal/mail/mail.go`
- [Billing endpoints](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/server/billing.go): `internal/server/billing.go`
- [Plans and limits](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/billing/billing.go): `internal/billing/billing.go`
- [Subscription checkout](https://github.com/mrcdprm/nabiz-analytics/blob/main/internal/billing/checkout.go): `internal/billing/checkout.go`

### Dashboard

- [Dashboard navigation](https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/main.ts): `web/src/main.ts`
- [API client](https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/api.ts): `web/src/api.ts`
- [Analytics dashboard](https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/views/dashboard.ts): `web/src/views/dashboard.ts`
- [Charts and breakdowns](https://github.com/mrcdprm/nabiz-analytics/tree/main/web/src/components): `web/src/components`
- [Site settings](https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/views/settings.ts): `web/src/views/settings.ts`
- [Team controls](https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/components/team.ts): `web/src/components/team.ts`
- [Install snippet](https://github.com/mrcdprm/nabiz-analytics/blob/main/web/src/components/snippet.ts): `web/src/components/snippet.ts`

### Other components

- **Site visitor**
- **iyzico payments**
- **Dashboard user**

## Connections

- Site visitor → Browser tracker: loads script (evidence: `README.md`)
- Browser tracker → Event endpoint: sends events (evidence: `README.md`)
- Event endpoint → Privacy recorder: records event
- Privacy recorder → Event parsing: parses payload (evidence: `internal/ingest/recorder.go`)
- Privacy recorder → Country lookup: looks up country (evidence: `internal/ingest/recorder.go`)
- Privacy recorder → Daily visitor salt: hashes visitors (evidence: `internal/ingest/recorder.go`)
- Privacy recorder → Agent parsing: parses agent
- Privacy recorder → Analytics database: writes events (evidence: `internal/ingest/recorder.go`)
- HTTP routing → Event endpoint: routes events
- HTTP routing → Stats and export routes: routes reports
- HTTP routing → Site management routes: routes sites
- HTTP routing → Team routes: routes teams
- Stats and export routes → Analytics queries: queries metrics
- Analytics queries → Analytics database: reads events
- Funnel analysis → Analytics database: reads events
- Goal analysis → Analytics database: reads events
- Stats and export routes → Funnel analysis: reports funnels
- Stats and export routes → Goal analysis: reports goals
- Stats and export routes → Reporting periods: selects ranges
- Site management routes → Site and funnel setup: manages sites
- Team routes → Membership roles: manages roles
- Dashboard user → Dashboard navigation: uses dashboard (evidence: `README.md`)
- Dashboard navigation → API client: requests data (evidence: `web/src/main.ts`)
- Dashboard navigation → Analytics dashboard: opens report (evidence: `web/src/main.ts`)
- Analytics dashboard → API client: fetches metrics (evidence: `web/src/views/dashboard.ts`)
- Analytics dashboard → Charts and breakdowns: renders charts (evidence: `web/src/views/dashboard.ts`)
- Dashboard navigation → Site settings: opens settings (evidence: `web/src/main.ts`)
- Site settings → Team controls: renders team (evidence: `web/src/views/settings.ts`)
- Site settings → Install snippet: renders snippet (evidence: `web/src/views/settings.ts`)
- API client → HTTP routing: calls API
- Dashboard navigation → Identity and sessions: checks session
- HTTP routing → Identity and sessions: authenticates users (evidence: `internal/server/server.go`)
- Identity and sessions → Analytics database: stores sessions (evidence: `internal/auth/auth.go`)
- Account operations → Analytics database: stores accounts (evidence: `internal/auth/account.go`)
- HTTP routing → Verification mail: sends mail
- Billing endpoints → Plans and limits: checks plans (evidence: `internal/server/billing.go`)
- Plans and limits → Analytics database: reads subscriptions (evidence: `internal/billing/billing.go`)
- Billing endpoints → Subscription checkout: starts checkout
- Subscription checkout → iyzico payments: requests payment
