# shigosag/veltrix architecture

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

- Interactive diagram: https://gitdiagram.com/shigosag/veltrix
- Repository: https://github.com/shigosag/veltrix

## Overview

Veltrix is a SaaS analytics command center: users sign in, inspect dashboard KPIs and anomaly signals, explore analytics, manage ingested datasets, and review generated insights. The Next.js client calls an Express API whose domain controllers and services handle analytics, datasets, insights, authentication, notifications, and user settings; Prisma persists backend data. The dashboard-to-API requests and several controller, route, service, and database links are directly supported by excerpts or the source index. Other page/API wiring is documented at product level only, so those links are marked unverified.

Main entry points: [`server/src/index.ts`](https://github.com/shigosag/veltrix/blob/main/server/src/index.ts) (Express API), [`server/src/lib/db.ts`](https://github.com/shigosag/veltrix/blob/main/server/src/lib/db.ts) (PostgreSQL via Prisma), [`server/src/routes/auth.routes.ts`](https://github.com/shigosag/veltrix/blob/main/server/src/routes/auth.routes.ts) (Authentication routes), [`server/src/services/insight-service.ts`](https://github.com/shigosag/veltrix/blob/main/server/src/services/insight-service.ts) (Insight generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_dashboard["Command center<br/>[page.tsx]"]
  node_analytics_ui["Analytics views<br/>[page.tsx]"]
  node_datasets_ui["Dataset manager<br/>[page.tsx]"]
  node_insights_ui["Insights view<br/>[page.tsx]"]
  node_account_ui["Account pages<br/>[page.tsx]"]
  node_notifications_ui["Notifications view<br/>[page.tsx]"]
  node_preferences_ui["Profile and preferences<br/>[page.tsx]"]
end

subgraph group_api["API and security"]
  node_api_entry["Express API<br/>[index.ts]"]
  node_auth_routes["Authentication routes<br/>[auth.routes.ts]"]
  node_auth_controller["Authentication controller<br/>[auth.controller.ts]"]
  node_auth_guard["Session guard<br/>[auth.middleware.ts]"]
end

subgraph group_telemetry["Telemetry analysis"]
  node_dashboard_controller["Dashboard controller"]
  node_dashboard_service["Dashboard aggregation"]
  node_analytics_controller["Analytics controller"]
  node_analytics_logic["Statistical analysis<br/>[analytics.ts]"]
  node_insights_controller["Insights controller"]
  node_insights_service["Insight generation<br/>[insight-service.ts]"]
end

subgraph group_workspace["Workspace data"]
  node_dataset_controller["Dataset controller"]
  node_dataset_service["Dataset ingestion<br/>[dataset-service.ts]"]
  node_notification_controller["Notification controller"]
  node_notification_service["Notification service"]
  node_user_controller["User controller<br/>[user.controller.ts]"]
  node_user_service["User service<br/>[user-service.ts]"]
end

subgraph group_persistence["Persistence"]
  node_database[("PostgreSQL via Prisma<br/>[db.ts]")]
end

node_user(("Analytics user"))

node_user -->|"views"| node_dashboard
node_user -->|"signs in"| node_account_ui
node_user -->|"explores"| node_analytics_ui
node_user -->|"manages"| node_datasets_ui
node_user -->|"reviews"| node_insights_ui
node_user -->|"reviews"| node_notifications_ui
node_user -.->|"configures"| node_preferences_ui
node_dashboard -->|"fetches dashboard and insights"| node_api_entry
node_analytics_ui -.->|"requests analytics"| node_api_entry
node_datasets_ui -.->|"requests datasets"| node_api_entry
node_insights_ui -.->|"requests insights"| node_api_entry
node_account_ui -.->|"requests authentication"| node_api_entry
node_notifications_ui -.->|"requests notifications"| node_api_entry
node_preferences_ui -.->|"requests user settings"| node_api_entry
node_api_entry -->|"mounts routes"| node_auth_routes
node_api_entry -->|"mounts dashboard routes"| node_dashboard_controller
node_api_entry -->|"mounts analytics routes"| node_analytics_controller
node_api_entry -->|"mounts insight routes"| node_insights_controller
node_api_entry -->|"mounts dataset routes"| node_dataset_controller
node_api_entry -->|"mounts notification routes"| node_notification_controller
node_api_entry -->|"mounts user routes"| node_user_controller
node_auth_routes -->|"routes requests"| node_auth_controller
node_auth_routes -->|"guards session lookup"| node_auth_guard
node_auth_controller -->|"reads user"| node_database
node_dashboard_controller -.->|"delegates"| node_dashboard_service
node_dashboard_service -->|"queries telemetry"| node_database
node_analytics_controller -.->|"uses analysis"| node_analytics_logic
node_insights_controller -->|"delegates"| node_insights_service
node_insights_service -->|"uses statistics"| node_analytics_logic
node_insights_service -->|"reads and writes"| node_database
node_dataset_controller -->|"delegates"| node_dataset_service
node_dataset_service -->|"reads and writes"| node_database
node_notification_controller -->|"delegates"| node_notification_service
node_notification_service -.->|"persists notifications"| node_database
node_user_controller -->|"delegates"| node_user_service
node_user_service -->|"reads and writes"| node_database

click node_dashboard "https://github.com/shigosag/veltrix/blob/main/client/src/app/page.tsx"
click node_analytics_ui "https://github.com/shigosag/veltrix/blob/main/client/src/app/analytics/page.tsx"
click node_datasets_ui "https://github.com/shigosag/veltrix/blob/main/client/src/app/datasets/page.tsx"
click node_insights_ui "https://github.com/shigosag/veltrix/blob/main/client/src/app/insights/page.tsx"
click node_account_ui "https://github.com/shigosag/veltrix/blob/main/client/src/app/login/page.tsx"
click node_notifications_ui "https://github.com/shigosag/veltrix/blob/main/client/src/app/notifications/page.tsx"
click node_preferences_ui "https://github.com/shigosag/veltrix/blob/main/client/src/app/preferences/page.tsx"
click node_api_entry "https://github.com/shigosag/veltrix/blob/main/server/src/index.ts"
click node_auth_routes "https://github.com/shigosag/veltrix/blob/main/server/src/routes/auth.routes.ts"
click node_auth_controller "https://github.com/shigosag/veltrix/blob/main/server/src/controllers/auth.controller.ts"
click node_auth_guard "https://github.com/shigosag/veltrix/blob/main/server/src/middleware/auth.middleware.ts"
click node_dashboard_controller "https://github.com/shigosag/veltrix/blob/main/server/src/controllers/dashboard.controller.ts"
click node_dashboard_service "https://github.com/shigosag/veltrix/blob/main/server/src/services/dashboard-service.ts"
click node_analytics_controller "https://github.com/shigosag/veltrix/blob/main/server/src/controllers/analytics.controller.ts"
click node_analytics_logic "https://github.com/shigosag/veltrix/blob/main/server/src/lib/analytics.ts"
click node_insights_controller "https://github.com/shigosag/veltrix/blob/main/server/src/controllers/insight.controller.ts"
click node_insights_service "https://github.com/shigosag/veltrix/blob/main/server/src/services/insight-service.ts"
click node_dataset_controller "https://github.com/shigosag/veltrix/blob/main/server/src/controllers/dataset.controller.ts"
click node_dataset_service "https://github.com/shigosag/veltrix/blob/main/server/src/services/dataset-service.ts"
click node_notification_controller "https://github.com/shigosag/veltrix/blob/main/server/src/controllers/notification.controller.ts"
click node_notification_service "https://github.com/shigosag/veltrix/blob/main/server/src/services/notification-service.ts"
click node_user_controller "https://github.com/shigosag/veltrix/blob/main/server/src/controllers/user.controller.ts"
click node_user_service "https://github.com/shigosag/veltrix/blob/main/server/src/services/user-service.ts"
click node_database "https://github.com/shigosag/veltrix/blob/main/server/src/lib/db.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_dashboard,node_analytics_ui,node_datasets_ui,node_insights_ui,node_account_ui,node_notifications_ui,node_preferences_ui,node_user toneBlue
class node_api_entry,node_auth_routes,node_auth_controller,node_auth_guard toneAmber
class node_dashboard_controller,node_dashboard_service,node_analytics_controller,node_analytics_logic,node_insights_controller,node_insights_service toneMint
class node_dataset_controller,node_dataset_service,node_notification_controller,node_notification_service,node_user_controller,node_user_service toneRose
class node_database toneIndigo
```

## Components

### Web client

- [Command center](https://github.com/shigosag/veltrix/blob/main/client/src/app/page.tsx): `client/src/app/page.tsx`
- [Analytics views](https://github.com/shigosag/veltrix/blob/main/client/src/app/analytics/page.tsx): `client/src/app/analytics/page.tsx`
- [Dataset manager](https://github.com/shigosag/veltrix/blob/main/client/src/app/datasets/page.tsx): `client/src/app/datasets/page.tsx`
- [Insights view](https://github.com/shigosag/veltrix/blob/main/client/src/app/insights/page.tsx): `client/src/app/insights/page.tsx`
- [Account pages](https://github.com/shigosag/veltrix/blob/main/client/src/app/login/page.tsx): `client/src/app/login/page.tsx`
- [Notifications view](https://github.com/shigosag/veltrix/blob/main/client/src/app/notifications/page.tsx): `client/src/app/notifications/page.tsx`
- [Profile and preferences](https://github.com/shigosag/veltrix/blob/main/client/src/app/preferences/page.tsx): `client/src/app/preferences/page.tsx`

### API and security

- [Express API](https://github.com/shigosag/veltrix/blob/main/server/src/index.ts): `server/src/index.ts`
- [Authentication routes](https://github.com/shigosag/veltrix/blob/main/server/src/routes/auth.routes.ts): `server/src/routes/auth.routes.ts`
- [Authentication controller](https://github.com/shigosag/veltrix/blob/main/server/src/controllers/auth.controller.ts): `server/src/controllers/auth.controller.ts`
- [Session guard](https://github.com/shigosag/veltrix/blob/main/server/src/middleware/auth.middleware.ts): `server/src/middleware/auth.middleware.ts`

### Telemetry analysis

- [Dashboard controller](https://github.com/shigosag/veltrix/blob/main/server/src/controllers/dashboard.controller.ts): `server/src/controllers/dashboard.controller.ts`
- [Dashboard aggregation](https://github.com/shigosag/veltrix/blob/main/server/src/services/dashboard-service.ts): `server/src/services/dashboard-service.ts`
- [Analytics controller](https://github.com/shigosag/veltrix/blob/main/server/src/controllers/analytics.controller.ts): `server/src/controllers/analytics.controller.ts`
- [Statistical analysis](https://github.com/shigosag/veltrix/blob/main/server/src/lib/analytics.ts): `server/src/lib/analytics.ts`
- [Insights controller](https://github.com/shigosag/veltrix/blob/main/server/src/controllers/insight.controller.ts): `server/src/controllers/insight.controller.ts`
- [Insight generation](https://github.com/shigosag/veltrix/blob/main/server/src/services/insight-service.ts): `server/src/services/insight-service.ts`

### Workspace data

- [Dataset controller](https://github.com/shigosag/veltrix/blob/main/server/src/controllers/dataset.controller.ts): `server/src/controllers/dataset.controller.ts`
- [Dataset ingestion](https://github.com/shigosag/veltrix/blob/main/server/src/services/dataset-service.ts): `server/src/services/dataset-service.ts`
- [Notification controller](https://github.com/shigosag/veltrix/blob/main/server/src/controllers/notification.controller.ts): `server/src/controllers/notification.controller.ts`
- [Notification service](https://github.com/shigosag/veltrix/blob/main/server/src/services/notification-service.ts): `server/src/services/notification-service.ts`
- [User controller](https://github.com/shigosag/veltrix/blob/main/server/src/controllers/user.controller.ts): `server/src/controllers/user.controller.ts`
- [User service](https://github.com/shigosag/veltrix/blob/main/server/src/services/user-service.ts): `server/src/services/user-service.ts`

### Persistence

- [PostgreSQL via Prisma](https://github.com/shigosag/veltrix/blob/main/server/src/lib/db.ts): `server/src/lib/db.ts`

### Other components

- **Analytics user**

## Connections

- Analytics user → Command center: views (evidence: `README.md`)
- Analytics user → Account pages: signs in (evidence: `README.md`)
- Analytics user → Analytics views: explores (evidence: `README.md`)
- Analytics user → Dataset manager: manages (evidence: `README.md`)
- Analytics user → Insights view: reviews (evidence: `README.md`)
- Analytics user → Notifications view: reviews (evidence: `README.md`)
- Analytics user → Profile and preferences: configures
- Command center → Express API: fetches dashboard and insights (evidence: `client/src/app/page.tsx`)
- Analytics views → Express API: requests analytics
- Dataset manager → Express API: requests datasets
- Insights view → Express API: requests insights
- Account pages → Express API: requests authentication
- Notifications view → Express API: requests notifications
- Profile and preferences → Express API: requests user settings
- Express API → Authentication routes: mounts routes (evidence: `server/src/index.ts`)
- Express API → Dashboard controller: mounts dashboard routes (evidence: `server/src/index.ts`)
- Express API → Analytics controller: mounts analytics routes (evidence: `server/src/index.ts`)
- Express API → Insights controller: mounts insight routes (evidence: `server/src/index.ts`)
- Express API → Dataset controller: mounts dataset routes (evidence: `server/src/index.ts`)
- Express API → Notification controller: mounts notification routes (evidence: `server/src/index.ts`)
- Express API → User controller: mounts user routes (evidence: `server/src/index.ts`)
- Authentication routes → Authentication controller: routes requests (evidence: `server/src/routes/auth.routes.ts`)
- Authentication routes → Session guard: guards session lookup (evidence: `server/src/routes/auth.routes.ts`)
- Authentication controller → PostgreSQL via Prisma: reads user (evidence: `server/src/controllers/auth.controller.ts`)
- Dashboard controller → Dashboard aggregation: delegates
- Dashboard aggregation → PostgreSQL via Prisma: queries telemetry (evidence: `server/src/services/dashboard-service.ts`)
- Analytics controller → Statistical analysis: uses analysis
- Insights controller → Insight generation: delegates (evidence: `server/src/controllers/insight.controller.ts`)
- Insight generation → Statistical analysis: uses statistics (evidence: `server/src/services/insight-service.ts`)
- Insight generation → PostgreSQL via Prisma: reads and writes (evidence: `server/src/services/insight-service.ts`)
- Dataset controller → Dataset ingestion: delegates (evidence: `server/src/controllers/dataset.controller.ts`)
- Dataset ingestion → PostgreSQL via Prisma: reads and writes (evidence: `server/src/services/dataset-service.ts`)
- Notification controller → Notification service: delegates (evidence: `server/src/controllers/notification.controller.ts`)
- Notification service → PostgreSQL via Prisma: persists notifications
- User controller → User service: delegates (evidence: `server/src/controllers/user.controller.ts`)
- User service → PostgreSQL via Prisma: reads and writes (evidence: `server/src/services/user-service.ts`)
