# afzalzada2026/hr-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/afzalzada2026/hr-dashboard
- Repository: https://github.com/afzalzada2026/hr-dashboard

## Overview

HR-Dashboard is a workforce data and HR analytics application. Users load or select workforce datasets, explore dashboards and employee views, and manage reports and access. Its client store prepares and filters employee data, while storage supports browser-local operation and an optional PostgreSQL-backed server mode. The tree and source index document additional directory, mapping, organizational-chart, security, and reporting capabilities. Several page and view implementations were not sampled, so their internal interactions are not inferred; edges cite sampled files or source-index references.

Main entry points: [`src/store/data.ts`](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/store/data.ts) (Workforce state), [`src/components/views/AnalyticsView.tsx`](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/AnalyticsView.tsx) (Analytics view), [`src/app/api/datasets/route.ts`](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/app/api/datasets/route.ts) (Server API routes), [`src/components/views/DataView.tsx`](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/DataView.tsx) (Dataset management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Dashboard experience"]
  node_dashboard["Overview page<br/>[page.tsx]"]
  node_analytics_page["Analytics page<br/>[page.tsx]"]
  node_overview["Overview view<br/>[OverviewView.tsx]"]
  node_analytics_view["Analytics view<br/>[AnalyticsView.tsx]"]
  node_directory["Employee directory<br/>[DirectoryView.tsx]"]
  node_map["Workforce map<br/>[MapView.tsx]"]
  node_orgchart["Organization chart<br/>[Organogram.tsx]"]
end

subgraph group_data["Workforce data"]
  node_data_view["Dataset management<br/>[DataView.tsx]"]
  node_data_store["Workforce state<br/>[data.ts]"]
  node_mapping["Field mapping<br/>[mapping.ts]"]
  node_normalization["Row normalization<br/>[normalize.ts]"]
  node_filters["Workforce filters<br/>[filters.ts]"]
end

subgraph group_analytics["Analysis and reporting"]
  node_reports["Report management<br/>[ReportsView.tsx]"]
  node_analytics_logic["Analytics calculations<br/>[analytics.ts]"]
  node_insights["Workforce insights<br/>[insights.ts]"]
  node_exports["Data and report exports<br/>[exporters.ts]"]
end

subgraph group_access["Identity and access"]
  node_security["Security management<br/>[SecurityView.tsx]"]
  node_ui_store["UI and session state<br/>[ui.ts]"]
  node_auth["Session and permissions<br/>[rbac.ts]"]
  node_server_auth["Server session and audit<br/>[server.ts]"]
end

subgraph group_backend["Server and persistence"]
  node_storage["Storage adapters<br/>[storage.ts]"]
  node_local_db[("Browser dataset store<br/>[storage.ts]")]
  node_api["Server API routes<br/>[route.ts]"]
  node_db[("PostgreSQL data<br/>[schema.ts]")]
  node_db_init["Schema bootstrap<br/>[ensure.ts]"]
end

node_user(("HR user"))

node_user -->|"opens"| node_dashboard
node_dashboard -->|"renders"| node_overview
node_analytics_page -->|"renders"| node_analytics_view
node_overview -->|"reads workforce state"| node_data_store
node_overview -->|"uses calculations"| node_analytics_logic
node_overview -->|"uses insights"| node_insights
node_analytics_view -->|"reads workforce state"| node_data_store
node_analytics_view -->|"uses calculations"| node_analytics_logic
node_analytics_view -->|"uses insights"| node_insights
node_data_view -->|"updates dataset state"| node_data_store
node_data_store -->|"maps columns"| node_mapping
node_data_store -->|"normalizes rows"| node_normalization
node_data_store -->|"applies filters"| node_filters
node_data_store -->|"loads and saves"| node_storage
node_storage -->|"reads and writes"| node_local_db
node_data_view -->|"uses mapping"| node_mapping
node_data_view -->|"uses normalization"| node_normalization
node_data_view -->|"uses exports"| node_exports
node_analytics_view -.->|"exports results"| node_exports
node_orgchart -.->|"uses employee data"| node_data_store
node_directory -.->|"uses employee data"| node_data_store
node_map -.->|"uses employee data"| node_data_store
node_reports -.->|"manages reports"| node_api
node_security -.->|"manages access data"| node_api
node_ui_store -->|"encodes session"| node_auth
node_data_store -->|"checks permissions"| node_auth
node_api -->|"authenticates requests"| node_server_auth
node_api -->|"ensures schema"| node_db_init
node_api -->|"reads and writes records"| node_db
node_server_auth -->|"decodes session"| node_auth
node_db_init -->|"creates tables"| node_db

click node_dashboard "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/app/(dashboard)/page.tsx"
click node_analytics_page "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/app/(dashboard)/analytics/page.tsx"
click node_overview "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/OverviewView.tsx"
click node_analytics_view "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/AnalyticsView.tsx"
click node_directory "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/DirectoryView.tsx"
click node_map "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/MapView.tsx"
click node_orgchart "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/org/Organogram.tsx"
click node_reports "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/ReportsView.tsx"
click node_security "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/SecurityView.tsx"
click node_data_view "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/DataView.tsx"
click node_data_store "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/store/data.ts"
click node_ui_store "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/store/ui.ts"
click node_mapping "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/mapping.ts"
click node_normalization "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/normalize.ts"
click node_filters "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/filters.ts"
click node_analytics_logic "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/analytics.ts"
click node_insights "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/insights.ts"
click node_exports "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/exporters.ts"
click node_storage "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/storage.ts"
click node_local_db "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/storage.ts"
click node_api "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/app/api/datasets/route.ts"
click node_auth "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/rbac.ts"
click node_server_auth "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/server.ts"
click node_db "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/db/schema.ts"
click node_db_init "https://github.com/afzalzada2026/hr-dashboard/blob/main/src/db/ensure.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_page,node_overview,node_analytics_view,node_directory,node_map,node_orgchart,node_user toneBlue
class node_data_view,node_data_store,node_mapping,node_normalization,node_filters toneAmber
class node_reports,node_analytics_logic,node_insights,node_exports toneMint
class node_security,node_ui_store,node_auth,node_server_auth toneRose
class node_storage,node_local_db,node_api,node_db,node_db_init toneIndigo
```

## Components

### Dashboard experience

- [Overview page](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/app/(dashboard)/page.tsx): `src/app/(dashboard)/page.tsx`
- [Analytics page](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/app/(dashboard)/analytics/page.tsx): `src/app/(dashboard)/analytics/page.tsx`
- [Overview view](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/OverviewView.tsx): `src/components/views/OverviewView.tsx`
- [Analytics view](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/AnalyticsView.tsx): `src/components/views/AnalyticsView.tsx`
- [Employee directory](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/DirectoryView.tsx): `src/components/views/DirectoryView.tsx`
- [Workforce map](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/MapView.tsx): `src/components/views/MapView.tsx`
- [Organization chart](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/org/Organogram.tsx): `src/components/org/Organogram.tsx`

### Workforce data

- [Dataset management](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/DataView.tsx): `src/components/views/DataView.tsx`
- [Workforce state](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/store/data.ts): `src/store/data.ts`
- [Field mapping](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/mapping.ts): `src/lib/mapping.ts`
- [Row normalization](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/normalize.ts): `src/lib/normalize.ts`
- [Workforce filters](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/filters.ts): `src/lib/filters.ts`

### Analysis and reporting

- [Report management](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/ReportsView.tsx): `src/components/views/ReportsView.tsx`
- [Analytics calculations](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/analytics.ts): `src/lib/analytics.ts`
- [Workforce insights](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/insights.ts): `src/lib/insights.ts`
- [Data and report exports](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/exporters.ts): `src/lib/exporters.ts`

### Identity and access

- [Security management](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/components/views/SecurityView.tsx): `src/components/views/SecurityView.tsx`
- [UI and session state](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/store/ui.ts): `src/store/ui.ts`
- [Session and permissions](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/rbac.ts): `src/lib/rbac.ts`
- [Server session and audit](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/server.ts): `src/lib/server.ts`

### Server and persistence

- [Storage adapters](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- [Browser dataset store](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- [Server API routes](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/app/api/datasets/route.ts): `src/app/api/datasets/route.ts`
- [PostgreSQL data](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/db/schema.ts): `src/db/schema.ts`
- [Schema bootstrap](https://github.com/afzalzada2026/hr-dashboard/blob/main/src/db/ensure.ts): `src/db/ensure.ts`

### Other components

- **HR user**

## Connections

- HR user → Overview page: opens (evidence: `src/app/(dashboard)/page.tsx`)
- Overview page → Overview view: renders (evidence: `src/app/(dashboard)/page.tsx`)
- Analytics page → Analytics view: renders (evidence: `src/app/(dashboard)/analytics/page.tsx`)
- Overview view → Workforce state: reads workforce state (evidence: `src/components/views/OverviewView.tsx`)
- Overview view → Analytics calculations: uses calculations (evidence: `src/components/views/OverviewView.tsx`)
- Overview view → Workforce insights: uses insights (evidence: `src/components/views/OverviewView.tsx`)
- Analytics view → Workforce state: reads workforce state (evidence: `src/components/views/AnalyticsView.tsx`)
- Analytics view → Analytics calculations: uses calculations (evidence: `src/components/views/AnalyticsView.tsx`)
- Analytics view → Workforce insights: uses insights (evidence: `src/components/views/AnalyticsView.tsx`)
- Dataset management → Workforce state: updates dataset state (evidence: `src/components/views/DataView.tsx`)
- Workforce state → Field mapping: maps columns (evidence: `src/store/data.ts`)
- Workforce state → Row normalization: normalizes rows (evidence: `src/store/data.ts`)
- Workforce state → Workforce filters: applies filters (evidence: `src/store/data.ts`)
- Workforce state → Storage adapters: loads and saves (evidence: `src/store/data.ts`)
- Storage adapters → Browser dataset store: reads and writes (evidence: `src/lib/storage.ts`)
- Dataset management → Field mapping: uses mapping (evidence: `src/components/views/DataView.tsx`)
- Dataset management → Row normalization: uses normalization (evidence: `src/components/views/DataView.tsx`)
- Dataset management → Data and report exports: uses exports (evidence: `src/components/views/DataView.tsx`)
- Analytics view → Data and report exports: exports results
- Organization chart → Workforce state: uses employee data
- Employee directory → Workforce state: uses employee data
- Workforce map → Workforce state: uses employee data
- Report management → Server API routes: manages reports
- Security management → Server API routes: manages access data
- UI and session state → Session and permissions: encodes session (evidence: `src/store/ui.ts`)
- Workforce state → Session and permissions: checks permissions (evidence: `src/store/data.ts`)
- Server API routes → Server session and audit: authenticates requests (evidence: `src/app/api/datasets/route.ts`)
- Server API routes → Schema bootstrap: ensures schema (evidence: `src/app/api/datasets/route.ts`)
- Server API routes → PostgreSQL data: reads and writes records (evidence: `src/app/api/datasets/route.ts`)
- Server session and audit → Session and permissions: decodes session (evidence: `src/lib/server.ts`)
- Schema bootstrap → PostgreSQL data: creates tables (evidence: `src/db/ensure.ts`)
