# aprimo-connect/aprimo-analytics architecture

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

- Interactive diagram: https://gitdiagram.com/aprimo-connect/aprimo-analytics
- Repository: https://github.com/aprimo-connect/aprimo-analytics

## Overview

Aprimo Analytics is a browser-based reporting application for DAM analytics and configured PM reports. Users sign in through Aprimo PKCE OAuth, then explore prebuilt dashboards or build custom queries; results pass through Next.js API proxies to Aprimo and return for charting, tables, and export. PM reports follow a separate list-and-detail path. The README documents these capabilities and proxy boundaries; some dashboard and auth wiring is unsampled, so uncertain links are omitted or marked dashed.

Main entry points: [`lib/hooks/useAnalytics.ts`](https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/hooks/useAnalytics.ts) (Analytics query hook), [`app/(dashboard)/content-health/page.tsx`](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/content-health/page.tsx) (Content health), [`components/charts`](https://github.com/aprimo-connect/aprimo-analytics/tree/main/components/charts) (Charts and tables), [`app/(dashboard)/overview/page.tsx`](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/overview/page.tsx) (Executive overview)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dam["DAM analytics"]
  node_overview["Executive overview<br/>[page.tsx]"]
  node_downloads["Downloads<br/>[page.tsx]"]
  node_views["Views and portal<br/>[page.tsx]"]
  node_impressions["Impressions traffic<br/>[page.tsx]"]
  node_plays["Video plays<br/>[page.tsx]"]
  node_health["Content health<br/>[page.tsx]"]
  node_explorer["Query explorer<br/>[page.tsx]"]
end

subgraph group_pm["PM reporting"]
  node_pm_list["Report catalog<br/>[page.tsx]"]
  node_pm_detail["Report detail<br/>[page.tsx]"]
end

subgraph group_auth["Identity and tenant"]
  node_auth_context["Session context"]
  node_oauth_callback["OAuth callback<br/>[page.tsx]"]
  node_auth_api["Token exchange<br/>[route.ts]"]
  node_auth_client["PKCE auth<br/>[auth.ts]"]
  node_tenant_context["Tenant mode"]
end

subgraph group_runtime["API and presentation"]
  node_analytics_hook["Analytics query hook<br/>[useAnalytics.ts]"]
  node_analytics_api["Analytics proxy<br/>[route.ts]"]
  node_analytics_client["Analytics client"]
  node_pm_hook["PM report hook<br/>[usePMReport.ts]"]
  node_pm_api["PM report proxy<br/>[route.ts]"]
  node_pm_client["PM reporting client"]
  node_charts["Charts and tables"]
end

node_browser(("Browser user"))
node_aprimo_analytics{{"Aprimo DAM Analytics"}}
node_aprimo_reporting{{"Aprimo PM Reporting"}}

node_browser -.->|"views dashboard"| node_overview
node_browser -.->|"views dashboard"| node_downloads
node_browser -.->|"views dashboard"| node_views
node_browser -.->|"views dashboard"| node_impressions
node_browser -.->|"views dashboard"| node_plays
node_browser -->|"views dashboard"| node_health
node_browser -->|"builds query"| node_explorer
node_overview -->|"queries data"| node_analytics_hook
node_downloads -->|"queries data"| node_analytics_hook
node_health -->|"queries data"| node_analytics_hook
node_explorer -.->|"runs query"| node_analytics_hook
node_views -.->|"queries data"| node_analytics_hook
node_impressions -.->|"queries data"| node_analytics_hook
node_plays -.->|"queries data"| node_analytics_hook
node_analytics_hook -->|"posts query"| node_analytics_api
node_analytics_api -->|"delegates query"| node_analytics_client
node_analytics_client -->|"fetches analytics"| node_aprimo_analytics
node_analytics_hook -.->|"supplies results"| node_charts
node_overview -->|"renders metrics"| node_charts
node_downloads -->|"renders metrics"| node_charts
node_health -->|"renders metrics"| node_charts
node_browser -.->|"opens reports"| node_pm_list
node_pm_list -.->|"opens report"| node_pm_detail
node_pm_detail -.->|"loads report"| node_pm_hook
node_pm_hook -.->|"requests report"| node_pm_api
node_pm_api -->|"delegates request"| node_pm_client
node_pm_client -->|"fetches report"| node_aprimo_reporting
node_browser -.->|"completes sign-in"| node_oauth_callback
node_oauth_callback -->|"sets session"| node_auth_context
node_oauth_callback -->|"exchanges code"| node_auth_api
node_auth_api -.->|"exchanges token"| node_auth_client
node_auth_client -.->|"authorizes access"| node_aprimo_analytics
node_analytics_hook -->|"reads credentials"| node_auth_context
node_browser -.->|"selects tenant mode"| node_tenant_context
node_health -->|"reads tenant mode"| node_tenant_context

click node_overview "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/overview/page.tsx"
click node_downloads "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/downloads/page.tsx"
click node_views "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/views/page.tsx"
click node_impressions "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/impressions/page.tsx"
click node_plays "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/plays/page.tsx"
click node_health "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/content-health/page.tsx"
click node_explorer "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/explorer/page.tsx"
click node_pm_list "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/pm-reports/page.tsx"
click node_pm_detail "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/pm-reports/%5BreportId%5D/page.tsx"
click node_auth_context "https://github.com/aprimo-connect/aprimo-analytics/blob/main/context/AprimoAuthContext.tsx"
click node_oauth_callback "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/oauth/callback/page.tsx"
click node_auth_api "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/api/auth/token/route.ts"
click node_auth_client "https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/aprimo/auth.ts"
click node_tenant_context "https://github.com/aprimo-connect/aprimo-analytics/blob/main/context/TenantModeContext.tsx"
click node_analytics_hook "https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/hooks/useAnalytics.ts"
click node_analytics_api "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/api/analytics/route.ts"
click node_analytics_client "https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/aprimo/analytics-client.ts"
click node_pm_hook "https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/hooks/usePMReport.ts"
click node_pm_api "https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/api/pm-reports/%5BreportId%5D/route.ts"
click node_pm_client "https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/aprimo/pm-reporting-client.ts"
click node_charts "https://github.com/aprimo-connect/aprimo-analytics/tree/main/components/charts"

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_overview,node_downloads,node_views,node_impressions,node_plays,node_health,node_explorer,node_browser toneBlue
class node_pm_list,node_pm_detail toneAmber
class node_auth_context,node_oauth_callback,node_auth_api,node_auth_client,node_tenant_context toneMint
class node_analytics_hook,node_analytics_api,node_analytics_client,node_pm_hook,node_pm_api,node_pm_client,node_charts toneRose
class node_aprimo_analytics,node_aprimo_reporting toneIndigo
```

## Components

### DAM analytics

- [Executive overview](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/overview/page.tsx): `app/(dashboard)/overview/page.tsx`
- [Downloads](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/downloads/page.tsx): `app/(dashboard)/downloads/page.tsx`
- [Views and portal](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/views/page.tsx): `app/(dashboard)/views/page.tsx`
- [Impressions traffic](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/impressions/page.tsx): `app/(dashboard)/impressions/page.tsx`
- [Video plays](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/plays/page.tsx): `app/(dashboard)/plays/page.tsx`
- [Content health](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/content-health/page.tsx): `app/(dashboard)/content-health/page.tsx`
- [Query explorer](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/explorer/page.tsx): `app/(dashboard)/explorer/page.tsx`

### PM reporting

- [Report catalog](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/pm-reports/page.tsx): `app/(dashboard)/pm-reports/page.tsx`
- [Report detail](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/(dashboard)/pm-reports/%5BreportId%5D/page.tsx): `app/(dashboard)/pm-reports/[reportId]/page.tsx`

### Identity and tenant

- [Session context](https://github.com/aprimo-connect/aprimo-analytics/blob/main/context/AprimoAuthContext.tsx): `context/AprimoAuthContext.tsx`
- [OAuth callback](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/oauth/callback/page.tsx): `app/oauth/callback/page.tsx`
- [Token exchange](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/api/auth/token/route.ts): `app/api/auth/token/route.ts`
- [PKCE auth](https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/aprimo/auth.ts): `lib/aprimo/auth.ts`
- [Tenant mode](https://github.com/aprimo-connect/aprimo-analytics/blob/main/context/TenantModeContext.tsx): `context/TenantModeContext.tsx`

### API and presentation

- [Analytics query hook](https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/hooks/useAnalytics.ts): `lib/hooks/useAnalytics.ts`
- [Analytics proxy](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/api/analytics/route.ts): `app/api/analytics/route.ts`
- [Analytics client](https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/aprimo/analytics-client.ts): `lib/aprimo/analytics-client.ts`
- [PM report hook](https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/hooks/usePMReport.ts): `lib/hooks/usePMReport.ts`
- [PM report proxy](https://github.com/aprimo-connect/aprimo-analytics/blob/main/app/api/pm-reports/%5BreportId%5D/route.ts): `app/api/pm-reports/[reportId]/route.ts`
- [PM reporting client](https://github.com/aprimo-connect/aprimo-analytics/blob/main/lib/aprimo/pm-reporting-client.ts): `lib/aprimo/pm-reporting-client.ts`
- [Charts and tables](https://github.com/aprimo-connect/aprimo-analytics/tree/main/components/charts): `components/charts`

### Other components

- **Browser user**
- **Aprimo DAM Analytics**
- **Aprimo PM Reporting**

## Connections

- Browser user → Executive overview: views dashboard
- Browser user → Downloads: views dashboard
- Browser user → Views and portal: views dashboard
- Browser user → Impressions traffic: views dashboard
- Browser user → Video plays: views dashboard
- Browser user → Content health: views dashboard (evidence: `app/(dashboard)/content-health/page.tsx`)
- Browser user → Query explorer: builds query (evidence: `app/(dashboard)/explorer/page.tsx`)
- Executive overview → Analytics query hook: queries data (evidence: `app/(dashboard)/overview/page.tsx`)
- Downloads → Analytics query hook: queries data (evidence: `app/(dashboard)/downloads/page.tsx`)
- Content health → Analytics query hook: queries data (evidence: `app/(dashboard)/content-health/page.tsx`)
- Query explorer → Analytics query hook: runs query (evidence: `app/(dashboard)/explorer/page.tsx`)
- Views and portal → Analytics query hook: queries data
- Impressions traffic → Analytics query hook: queries data
- Video plays → Analytics query hook: queries data
- Analytics query hook → Analytics proxy: posts query (evidence: `lib/hooks/useAnalytics.ts`)
- Analytics proxy → Analytics client: delegates query (evidence: `app/api/analytics/route.ts`)
- Analytics client → Aprimo DAM Analytics: fetches analytics (evidence: `README.md`)
- Analytics query hook → Charts and tables: supplies results
- Executive overview → Charts and tables: renders metrics (evidence: `app/(dashboard)/overview/page.tsx`)
- Downloads → Charts and tables: renders metrics (evidence: `app/(dashboard)/downloads/page.tsx`)
- Content health → Charts and tables: renders metrics (evidence: `app/(dashboard)/content-health/page.tsx`)
- Browser user → Report catalog: opens reports
- Report catalog → Report detail: opens report
- Report detail → PM report hook: loads report
- PM report hook → PM report proxy: requests report
- PM report proxy → PM reporting client: delegates request (evidence: `app/api/pm-reports/[reportId]/route.ts`)
- PM reporting client → Aprimo PM Reporting: fetches report (evidence: `README.md`)
- Browser user → OAuth callback: completes sign-in
- OAuth callback → Session context: sets session (evidence: `app/oauth/callback/page.tsx`)
- OAuth callback → Token exchange: exchanges code (evidence: `README.md`)
- Token exchange → PKCE auth: exchanges token
- PKCE auth → Aprimo DAM Analytics: authorizes access
- Analytics query hook → Session context: reads credentials (evidence: `lib/hooks/useAnalytics.ts`)
- Browser user → Tenant mode: selects tenant mode
- Content health → Tenant mode: reads tenant mode (evidence: `app/(dashboard)/content-health/page.tsx`)
