# timoa/workflow-metrics architecture

> Architecture diagram of the GitHub repository timoa/workflow-metrics, 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/timoa/workflow-metrics
- Repository: https://github.com/timoa/workflow-metrics

## Overview

Workflow Metrics is a GitHub Actions analytics dashboard. Users sign in with GitHub, select repositories, and inspect repository and workflow metrics; they can also configure DORA tracking and request AI recommendations, optionally applying them as a pull request. The map preserves the documented analytics and workflow-structure branches. Several route and component relationships are documented in the README rather than visible in the sampled excerpts, so those edges cite the README; unsampled implementation details are not inferred.

Main entry points: [`src/routes/api/optimize/+server.ts`](https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/optimize/%2Bserver.ts) (Optimization API), [`src/routes/api/optimize/apply/+server.ts`](https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/optimize/apply/%2Bserver.ts) (Apply as PR API), [`src/routes/auth/callback/+server.ts`](https://github.com/timoa/workflow-metrics/blob/main/src/routes/auth/callback/%2Bserver.ts) (OAuth Callback), [`src/routes/onboarding/+page.server.ts`](https://github.com/timoa/workflow-metrics/blob/main/src/routes/onboarding/%2Bpage.server.ts) (Repository Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_account["Accounts &amp; Setup"]
  node_login["GitHub Login<br/>[+page.svelte]"]
  node_oauth["OAuth Callback<br/>[+server.ts]"]
  node_onboarding["Repository Setup<br/>[+page.server.ts]"]
  node_settings["Settings<br/>[+page.server.ts]"]
end

subgraph group_analytics["Workflow Analytics"]
  node_dashboard_data["Dashboard Data API<br/>[+server.ts]"]
  node_dora_api["DORA Workflow API<br/>[+server.ts]"]
end

subgraph group_experience["Dashboard UI"]
  node_dashboard_page["Repository Dashboard<br/>[+page.svelte]"]
  node_workflow_page["Workflow Detail<br/>[+page.svelte]"]
  node_charts["Metrics Charts"]
  node_run_chart["Run History Chart"]
  node_minutes_chart["Minutes Donut Chart"]
  node_list_keys["List Key Helper<br/>[list-keys.ts]"]
  node_segment_keys["Segment Key Helper<br/>[segment-keys.ts]"]
  node_workflow_graph["Workflow Flow Chart"]
  node_dora_dialog["DORA Selection"]
  node_optimize_panel["Optimization Panel"]
end

subgraph group_optimization["AI Optimization"]
  node_optimize_api["Optimization API<br/>[+server.ts]"]
  node_apply_api["Apply as PR API<br/>[+server.ts]"]
end

subgraph group_services["External Services"]
  node_github["GitHub API"]
  node_supabase[("Supabase")]
  node_mistral["Mistral AI"]
  node_github_service["GitHub Client<br/>[github.ts]"]
  node_github_app["GitHub App Client<br/>[github-app.ts]"]
  node_mistral_service["Mistral Client<br/>[mistral.ts]"]
end

node_user(("User"))

node_user -->|"signs in"| node_login
node_login -->|"starts OAuth"| node_oauth
node_oauth -->|"authenticates via"| node_github
node_oauth -->|"establishes session"| node_supabase
node_user -->|"selects repositories"| node_onboarding
node_onboarding -->|"lists repositories"| node_github
node_onboarding -->|"saves selection"| node_supabase
node_user -->|"views metrics"| node_dashboard_page
node_dashboard_page -->|"loads metrics"| node_dashboard_data
node_dashboard_page -->|"presents analytics"| node_charts
node_workflow_page -->|"presents workflow metrics"| node_charts
node_workflow_page -->|"shows workflow structure"| node_workflow_graph
node_run_chart -->|"uses keys"| node_list_keys
node_minutes_chart -->|"builds segment keys"| node_segment_keys
node_user -->|"chooses workflows"| node_dora_dialog
node_dora_dialog -->|"saves selection"| node_dora_api
node_dora_api -->|"reads and writes"| node_supabase
node_user -->|"configures account"| node_settings
node_settings -->|"stores preferences"| node_supabase
node_settings -->|"syncs installations"| node_github_app
node_github_app -->|"calls GitHub API"| node_github
node_user -->|"requests suggestions"| node_optimize_panel
node_optimize_panel -->|"starts analysis"| node_optimize_api
node_optimize_api -->|"generates report"| node_mistral_service
node_optimize_api -->|"fetches workflow"| node_github
node_mistral_service -->|"requests analysis"| node_mistral
node_optimize_api -->|"reads settings and saves"| node_supabase
node_user -->|"applies recommendation"| node_apply_api
node_apply_api -->|"gets installation token"| node_github_app
node_apply_api -->|"generates YAML"| node_mistral_service
node_apply_api -->|"opens pull request"| node_github

click node_login "https://github.com/timoa/workflow-metrics/blob/main/src/routes/auth/login/%2Bpage.svelte"
click node_oauth "https://github.com/timoa/workflow-metrics/blob/main/src/routes/auth/callback/%2Bserver.ts"
click node_onboarding "https://github.com/timoa/workflow-metrics/blob/main/src/routes/onboarding/%2Bpage.server.ts"
click node_settings "https://github.com/timoa/workflow-metrics/blob/main/src/routes/settings/%2Bpage.server.ts"
click node_dashboard_data "https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/dashboard/data/%2Bserver.ts"
click node_dashboard_page "https://github.com/timoa/workflow-metrics/blob/main/src/routes/dashboard/%2Bpage.svelte"
click node_workflow_page "https://github.com/timoa/workflow-metrics/blob/main/src/routes/dashboard/workflow/%5Bid%5D/%2Bpage.svelte"
click node_charts "https://github.com/timoa/workflow-metrics/tree/main/src/lib/components/dashboard"
click node_run_chart "https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/RunHistoryChart.svelte"
click node_minutes_chart "https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/MinutesDonutChart.svelte"
click node_list_keys "https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/list-keys.ts"
click node_segment_keys "https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/segment-keys.ts"
click node_workflow_graph "https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/WorkflowJobGraph.svelte"
click node_dora_api "https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/dora-workflows/%2Bserver.ts"
click node_dora_dialog "https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/DoraWorkflowDialog.svelte"
click node_optimize_api "https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/optimize/%2Bserver.ts"
click node_apply_api "https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/optimize/apply/%2Bserver.ts"
click node_optimize_panel "https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/OptimizePanel.svelte"
click node_github_service "https://github.com/timoa/workflow-metrics/blob/main/src/lib/server/github.ts"
click node_github_app "https://github.com/timoa/workflow-metrics/blob/main/src/lib/server/github-app.ts"
click node_mistral_service "https://github.com/timoa/workflow-metrics/blob/main/src/lib/server/mistral.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_login,node_oauth,node_onboarding,node_settings,node_user toneBlue
class node_dashboard_data,node_dora_api toneAmber
class node_dashboard_page,node_workflow_page,node_charts,node_run_chart,node_minutes_chart,node_list_keys,node_segment_keys,node_workflow_graph,node_dora_dialog,node_optimize_panel toneMint
class node_optimize_api,node_apply_api toneRose
class node_github,node_supabase,node_mistral,node_github_service,node_github_app,node_mistral_service toneIndigo
```

## Components

### Accounts & Setup

- [GitHub Login](https://github.com/timoa/workflow-metrics/blob/main/src/routes/auth/login/%2Bpage.svelte): `src/routes/auth/login/+page.svelte`
- [OAuth Callback](https://github.com/timoa/workflow-metrics/blob/main/src/routes/auth/callback/%2Bserver.ts): `src/routes/auth/callback/+server.ts`
- [Repository Setup](https://github.com/timoa/workflow-metrics/blob/main/src/routes/onboarding/%2Bpage.server.ts): `src/routes/onboarding/+page.server.ts`
- [Settings](https://github.com/timoa/workflow-metrics/blob/main/src/routes/settings/%2Bpage.server.ts): `src/routes/settings/+page.server.ts`

### Workflow Analytics

- [Dashboard Data API](https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/dashboard/data/%2Bserver.ts): `src/routes/api/dashboard/data/+server.ts`
- [DORA Workflow API](https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/dora-workflows/%2Bserver.ts): `src/routes/api/dora-workflows/+server.ts`

### Dashboard UI

- [Repository Dashboard](https://github.com/timoa/workflow-metrics/blob/main/src/routes/dashboard/%2Bpage.svelte): `src/routes/dashboard/+page.svelte`
- [Workflow Detail](https://github.com/timoa/workflow-metrics/blob/main/src/routes/dashboard/workflow/%5Bid%5D/%2Bpage.svelte): `src/routes/dashboard/workflow/[id]/+page.svelte`
- [Metrics Charts](https://github.com/timoa/workflow-metrics/tree/main/src/lib/components/dashboard): `src/lib/components/dashboard`
- [Run History Chart](https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/RunHistoryChart.svelte): `src/lib/components/dashboard/RunHistoryChart.svelte`
- [Minutes Donut Chart](https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/MinutesDonutChart.svelte): `src/lib/components/dashboard/MinutesDonutChart.svelte`
- [List Key Helper](https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/list-keys.ts): `src/lib/components/dashboard/list-keys.ts`
- [Segment Key Helper](https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/segment-keys.ts): `src/lib/components/dashboard/segment-keys.ts`
- [Workflow Flow Chart](https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/WorkflowJobGraph.svelte): `src/lib/components/dashboard/WorkflowJobGraph.svelte`
- [DORA Selection](https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/DoraWorkflowDialog.svelte): `src/lib/components/dashboard/DoraWorkflowDialog.svelte`
- [Optimization Panel](https://github.com/timoa/workflow-metrics/blob/main/src/lib/components/dashboard/OptimizePanel.svelte): `src/lib/components/dashboard/OptimizePanel.svelte`

### AI Optimization

- [Optimization API](https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/optimize/%2Bserver.ts): `src/routes/api/optimize/+server.ts`
- [Apply as PR API](https://github.com/timoa/workflow-metrics/blob/main/src/routes/api/optimize/apply/%2Bserver.ts): `src/routes/api/optimize/apply/+server.ts`

### External Services

- **GitHub API**
- **Supabase**
- **Mistral AI**
- [GitHub Client](https://github.com/timoa/workflow-metrics/blob/main/src/lib/server/github.ts): `src/lib/server/github.ts`
- [GitHub App Client](https://github.com/timoa/workflow-metrics/blob/main/src/lib/server/github-app.ts): `src/lib/server/github-app.ts`
- [Mistral Client](https://github.com/timoa/workflow-metrics/blob/main/src/lib/server/mistral.ts): `src/lib/server/mistral.ts`

### Other components

- **User**

## Connections

- User → GitHub Login: signs in
- GitHub Login → OAuth Callback: starts OAuth
- OAuth Callback → GitHub API: authenticates via
- OAuth Callback → Supabase: establishes session
- User → Repository Setup: selects repositories
- Repository Setup → GitHub API: lists repositories (evidence: `src/routes/onboarding/+page.server.ts`)
- Repository Setup → Supabase: saves selection (evidence: `src/routes/onboarding/+page.server.ts`)
- User → Repository Dashboard: views metrics
- Repository Dashboard → Dashboard Data API: loads metrics
- Repository Dashboard → Metrics Charts: presents analytics
- Workflow Detail → Metrics Charts: presents workflow metrics
- Workflow Detail → Workflow Flow Chart: shows workflow structure
- Run History Chart → List Key Helper: uses keys (evidence: `src/lib/components/dashboard/RunHistoryChart.svelte`)
- Minutes Donut Chart → Segment Key Helper: builds segment keys (evidence: `src/lib/components/dashboard/MinutesDonutChart.svelte`)
- User → DORA Selection: chooses workflows
- DORA Selection → DORA Workflow API: saves selection
- DORA Workflow API → Supabase: reads and writes (evidence: `src/routes/api/dora-workflows/+server.ts`)
- User → Settings: configures account
- Settings → Supabase: stores preferences (evidence: `src/routes/settings/+page.server.ts`)
- Settings → GitHub App Client: syncs installations (evidence: `src/routes/settings/+page.server.ts`)
- GitHub App Client → GitHub API: calls GitHub API
- User → Optimization Panel: requests suggestions
- Optimization Panel → Optimization API: starts analysis
- Optimization API → Mistral Client: generates report (evidence: `src/routes/api/optimize/+server.ts`)
- Optimization API → GitHub API: fetches workflow (evidence: `src/routes/api/optimize/+server.ts`)
- Mistral Client → Mistral AI: requests analysis
- Optimization API → Supabase: reads settings and saves (evidence: `src/routes/api/optimize/+server.ts`)
- User → Apply as PR API: applies recommendation
- Apply as PR API → GitHub App Client: gets installation token (evidence: `src/routes/api/optimize/apply/+server.ts`)
- Apply as PR API → Mistral Client: generates YAML (evidence: `src/routes/api/optimize/apply/+server.ts`)
- Apply as PR API → GitHub API: opens pull request
