# tridibjena/pure-insights-command-center architecture

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

- Interactive diagram: https://gitdiagram.com/tridibjena/pure-insights-command-center
- Repository: https://github.com/tridibjena/pure-insights-command-center

## Overview

Pure Insights Command Center is a role-based operational analytics dashboard backed by an Express API, PostgreSQL and a Python data pipeline. Operators sign in, then use permission-gated views for report health, reports, orphaned ownership, costs, data quality and administration. Telemetry can be ingested or replayed; server-side rules create alerts that reach the dashboard over WebSockets, with REST resynchronization. The README also documents Snowflake ACCOUNT_USAGE cost attribution. Some routes and pipeline stages are represented by their exact enclosing directories because their implementations were not excerpted; the cost SQL suite is not present in the supplied tree.

Main entry points: [`server/src/app.js`](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/app.js) (HTTP router), [`server/src/services/telemetryIngest.js`](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/telemetryIngest.js) (Telemetry ingestion), [`server/src/server.js`](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/server.js) (Server wiring), [`client/src/App.jsx`](https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/App.jsx) (Dashboard routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Dashboard routes<br/>[App.jsx]"]
  node_auth_ui["Session context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[client.js]"]
  node_data_views["Analytics views"]
  node_live_ui["Live alert stream<br/>[AlertStream.jsx]"]
end

subgraph group_api["API and access"]
  node_server_app["HTTP router<br/>[app.js]"]
  node_auth_routes["Sign-in routes<br/>[auth.js]"]
  node_access["Authentication and RBAC<br/>[middleware.js]"]
  node_domain_routes["Analytics API routes"]
  node_server_runtime["Server wiring<br/>[server.js]"]
end

subgraph group_alerts["Telemetry and alerts"]
  node_telemetry_api["Telemetry routes<br/>[telemetry.js]"]
  node_ingest["Telemetry ingestion<br/>[telemetryIngest.js]"]
  node_rules["Alert rules<br/>[alertRules.js]"]
  node_alert_service["Alert lifecycle<br/>[alertService.js]"]
  node_websocket["WebSocket hub<br/>[wsHub.js]"]
  node_replay["Telemetry replay"]
end

subgraph group_pipeline["Data pipeline"]
  node_pipeline["CSV processing and quality"]
  node_cost_attribution["Snowflake cost attribution"]
end

subgraph group_state["Data stores"]
  node_postgres[("PostgreSQL")]
end

node_operator(("Operator"))
node_snowflake[("Snowflake ACCOUNT_USAGE")]

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"checks session"| node_auth_ui
node_dashboard -->|"routes to"| node_data_views
node_dashboard -->|"provides stream"| node_live_ui
node_auth_ui -->|"requests session"| node_api_client
node_data_views -->|"fetches data"| node_api_client
node_live_ui -->|"resyncs alerts"| node_api_client
node_api_client -.->|"calls REST"| node_server_app
node_live_ui -->|"opens WebSocket"| node_websocket
node_server_app -->|"mounts"| node_auth_routes
node_server_app -->|"mounts"| node_domain_routes
node_server_app -->|"mounts"| node_telemetry_api
node_server_app -->|"guards routes"| node_access
node_auth_routes -->|"reads users"| node_postgres
node_auth_routes -->|"authenticates session"| node_access
node_access -->|"loads user"| node_postgres
node_domain_routes -.->|"serves analytics"| node_postgres
node_server_runtime -->|"creates app"| node_server_app
node_server_runtime -->|"creates ingest"| node_ingest
node_server_runtime -->|"creates replayer"| node_replay
node_server_runtime -->|"creates hub"| node_websocket
node_telemetry_api -.->|"accepts telemetry"| node_ingest
node_replay -->|"replays events"| node_ingest
node_ingest -->|"evaluates events"| node_rules
node_ingest -->|"updates incidents"| node_alert_service
node_alert_service -->|"uses rules"| node_rules
node_ingest -.->|"writes telemetry"| node_postgres
node_websocket -->|"streams updates"| node_live_ui
node_pipeline -->|"loads cleaned data"| node_postgres
node_snowflake -->|"provides usage records"| node_cost_attribution
node_cost_attribution -.->|"publishes attribution"| node_postgres
node_data_views -.->|"requests analytics"| node_domain_routes

click node_dashboard "https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/App.jsx"
click node_auth_ui "https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/auth/AuthContext.jsx"
click node_api_client "https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/api/client.js"
click node_data_views "https://github.com/tridibjena/pure-insights-command-center/tree/main/client/src/pages"
click node_live_ui "https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/realtime/AlertStream.jsx"
click node_server_app "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/app.js"
click node_auth_routes "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/routes/auth.js"
click node_access "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/auth/middleware.js"
click node_domain_routes "https://github.com/tridibjena/pure-insights-command-center/tree/main/server/src/routes"
click node_server_runtime "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/server.js"
click node_telemetry_api "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/routes/telemetry.js"
click node_ingest "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/telemetryIngest.js"
click node_rules "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/alertRules.js"
click node_alert_service "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/alertService.js"
click node_websocket "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/wsHub.js"
click node_replay "https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/telemetryReplayer.js"
click node_pipeline "https://github.com/tridibjena/pure-insights-command-center/tree/main/pipeline/pic_pipeline"
click node_cost_attribution "https://github.com/tridibjena/pure-insights-command-center/tree/main/pipeline/pic_pipeline"

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_auth_ui,node_api_client,node_data_views,node_live_ui toneBlue
class node_server_app,node_auth_routes,node_access,node_domain_routes,node_server_runtime,node_snowflake toneAmber
class node_telemetry_api,node_ingest,node_rules,node_alert_service,node_websocket,node_replay toneMint
class node_pipeline,node_cost_attribution toneRose
class node_postgres,node_operator toneIndigo
```

## Components

### Dashboard

- [Dashboard routes](https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Session context](https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/auth/AuthContext.jsx): `client/src/auth/AuthContext.jsx`
- [API client](https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/api/client.js): `client/src/api/client.js`
- [Analytics views](https://github.com/tridibjena/pure-insights-command-center/tree/main/client/src/pages): `client/src/pages`
- [Live alert stream](https://github.com/tridibjena/pure-insights-command-center/blob/main/client/src/realtime/AlertStream.jsx): `client/src/realtime/AlertStream.jsx`

### API and access

- [HTTP router](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/app.js): `server/src/app.js`
- [Sign-in routes](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/routes/auth.js): `server/src/routes/auth.js`
- [Authentication and RBAC](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/auth/middleware.js): `server/src/auth/middleware.js`
- [Analytics API routes](https://github.com/tridibjena/pure-insights-command-center/tree/main/server/src/routes): `server/src/routes`
- [Server wiring](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/server.js): `server/src/server.js`

### Telemetry and alerts

- [Telemetry routes](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/routes/telemetry.js): `server/src/routes/telemetry.js`
- [Telemetry ingestion](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/telemetryIngest.js): `server/src/services/telemetryIngest.js`
- [Alert rules](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/alertRules.js): `server/src/services/alertRules.js`
- [Alert lifecycle](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/alertService.js): `server/src/services/alertService.js`
- [WebSocket hub](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/wsHub.js): `server/src/services/wsHub.js`
- [Telemetry replay](https://github.com/tridibjena/pure-insights-command-center/blob/main/server/src/services/telemetryReplayer.js): `server/src/services/telemetryReplayer.js`

### Data pipeline

- [CSV processing and quality](https://github.com/tridibjena/pure-insights-command-center/tree/main/pipeline/pic_pipeline): `pipeline/pic_pipeline`
- [Snowflake cost attribution](https://github.com/tridibjena/pure-insights-command-center/tree/main/pipeline/pic_pipeline): `pipeline/pic_pipeline`

### Data stores

- **PostgreSQL**

### Other components

- **Operator**
- **Snowflake ACCOUNT_USAGE**

## Connections

- Operator → Dashboard routes: uses (evidence: `README.md`)
- Dashboard routes → Session context: checks session (evidence: `client/src/App.jsx`)
- Dashboard routes → Analytics views: routes to (evidence: `client/src/App.jsx`)
- Dashboard routes → Live alert stream: provides stream (evidence: `client/src/App.jsx`)
- Session context → API client: requests session (evidence: `client/src/auth/AuthContext.jsx`)
- Analytics views → API client: fetches data (evidence: `client/src/pages/Alerts.jsx`)
- Live alert stream → API client: resyncs alerts (evidence: `client/src/realtime/AlertStream.jsx`)
- API client → HTTP router: calls REST
- Live alert stream → WebSocket hub: opens WebSocket (evidence: `client/src/realtime/AlertStream.jsx`)
- HTTP router → Sign-in routes: mounts (evidence: `server/src/app.js`)
- HTTP router → Analytics API routes: mounts (evidence: `server/src/app.js`)
- HTTP router → Telemetry routes: mounts (evidence: `server/src/app.js`)
- HTTP router → Authentication and RBAC: guards routes (evidence: `server/src/app.js`)
- Sign-in routes → PostgreSQL: reads users (evidence: `server/src/routes/auth.js`)
- Sign-in routes → Authentication and RBAC: authenticates session (evidence: `server/src/routes/auth.js`)
- Authentication and RBAC → PostgreSQL: loads user (evidence: `server/src/auth/middleware.js`)
- Analytics API routes → PostgreSQL: serves analytics
- Server wiring → HTTP router: creates app (evidence: `server/src/server.js`)
- Server wiring → Telemetry ingestion: creates ingest (evidence: `server/src/server.js`)
- Server wiring → Telemetry replay: creates replayer (evidence: `server/src/server.js`)
- Server wiring → WebSocket hub: creates hub (evidence: `server/src/server.js`)
- Telemetry routes → Telemetry ingestion: accepts telemetry
- Telemetry replay → Telemetry ingestion: replays events (evidence: `server/src/server.js`)
- Telemetry ingestion → Alert rules: evaluates events (evidence: `server/src/services/telemetryIngest.js`)
- Telemetry ingestion → Alert lifecycle: updates incidents (evidence: `server/src/services/telemetryIngest.js`)
- Alert lifecycle → Alert rules: uses rules (evidence: `server/src/services/alertService.js`)
- Telemetry ingestion → PostgreSQL: writes telemetry
- WebSocket hub → Live alert stream: streams updates (evidence: `client/src/realtime/AlertStream.jsx`)
- CSV processing and quality → PostgreSQL: loads cleaned data (evidence: `README.md`)
- Snowflake ACCOUNT_USAGE → Snowflake cost attribution: provides usage records (evidence: `README.md`)
- Snowflake cost attribution → PostgreSQL: publishes attribution
- Analytics views → Analytics API routes: requests analytics
