# anuraghazra/github-readme-stats architecture

> Architecture diagram of the GitHub repository anuraghazra/github-readme-stats, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anuraghazra/github-readme-stats
- Repository: https://github.com/anuraghazra/github-readme-stats

## Overview

GitHub Readme Stats serves dynamically generated SVG cards: a README image request reaches an API endpoint, which checks access and query options, fetches the relevant data, then renders a card response. The repository also includes repository and gist pins, WakaTime cards, and status endpoints. The graph reflects documented capabilities and relationships visible in the excerpts or SOURCE INDEX; unsampled modules are represented by their exact enclosing directories, and uncertain connections are omitted.

Main entry points: [`api/index.js`](https://github.com/anuraghazra/github-readme-stats/blob/master/api/index.js) (Stats endpoint), [`api/pin.js`](https://github.com/anuraghazra/github-readme-stats/blob/master/api/pin.js) (Repository pin endpoint), [`api/gist.js`](https://github.com/anuraghazra/github-readme-stats/blob/master/api/gist.js) (Gist endpoint), [`api/top-langs.js`](https://github.com/anuraghazra/github-readme-stats/blob/master/api/top-langs.js) (Languages endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routes["API routes"]
  node_express["Express adapter<br/>[express.js]"]
  node_stats_route["Stats endpoint<br/>[index.js]"]
  node_pin_route["Repository pin endpoint<br/>[pin.js]"]
  node_gist_route["Gist endpoint<br/>[gist.js]"]
  node_langs_route["Languages endpoint<br/>[top-langs.js]"]
  node_waka_route["WakaTime endpoint<br/>[wakatime.js]"]
  node_pat_status["Token status<br/>[pat-info.js]"]
  node_up_status["Service status<br/>[up.js]"]
end

subgraph group_data["Data retrieval"]
  node_stats_fetch["GitHub stats fetcher<br/>[stats.js]"]
  node_repo_fetch["Repository fetcher<br/>[repo.js]"]
  node_gist_fetch["Gist fetcher<br/>[gist.js]"]
  node_langs_fetch["Language fetcher<br/>[top-languages.js]"]
  node_waka_fetch["WakaTime fetcher<br/>[wakatime.js]"]
  node_rank["Rank calculation<br/>[calculateRank.js]"]
end

subgraph group_cards["Card rendering"]
  node_stats_card["Stats card<br/>[stats.js]"]
  node_repo_card["Repository pin card<br/>[repo.js]"]
  node_gist_card["Gist card<br/>[gist.js]"]
  node_langs_card["Top languages card<br/>[top-languages.js]"]
  node_waka_card["WakaTime card<br/>[wakatime.js]"]
end

subgraph group_shared["Shared services"]
  node_card_base["Card framework<br/>[Card.js]"]
  node_svg_render["SVG rendering helpers<br/>[render.js]"]
  node_access["Access checks<br/>[access.js]"]
  node_cache["Response caching<br/>[cache.js]"]
  node_translations["Translations<br/>[translations.js]"]
  node_themes["Themes and colors<br/>[color.js]"]
  node_common_util["Formatting and utilities"]
end

node_reader(("README reader"))
node_github{{"GitHub API"}}
node_wakatime_service{{"WakaTime API"}}

node_reader -->|"requests card"| node_stats_route
node_reader -->|"requests pin"| node_pin_route
node_reader -->|"requests gist"| node_gist_route
node_reader -->|"requests card"| node_langs_route
node_reader -->|"requests card"| node_waka_route
node_express -->|"routes to"| node_stats_route
node_express -->|"routes to"| node_pin_route
node_express -->|"routes to"| node_gist_route
node_express -->|"routes to"| node_langs_route
node_express -->|"routes to"| node_waka_route
node_stats_route -->|"checks access"| node_access
node_stats_route -->|"fetches stats"| node_stats_fetch
node_stats_route -->|"renders card"| node_stats_card
node_stats_route -->|"sets cache headers"| node_cache
node_stats_route -->|"checks locale"| node_translations
node_pin_route -->|"checks access"| node_access
node_pin_route -->|"fetches repository"| node_repo_fetch
node_pin_route -->|"renders card"| node_repo_card
node_pin_route -->|"sets cache headers"| node_cache
node_gist_route -->|"checks access"| node_access
node_gist_route -->|"fetches gist"| node_gist_fetch
node_gist_route -->|"renders card"| node_gist_card
node_gist_route -->|"sets cache headers"| node_cache
node_langs_route -->|"checks access"| node_access
node_langs_route -->|"fetches languages"| node_langs_fetch
node_langs_route -->|"renders card"| node_langs_card
node_langs_route -->|"sets cache headers"| node_cache
node_waka_route -->|"checks access"| node_access
node_waka_route -->|"fetches activity"| node_waka_fetch
node_waka_route -->|"renders card"| node_waka_card
node_stats_fetch -->|"calculates rank"| node_rank
node_stats_card -->|"builds on"| node_card_base
node_repo_card -->|"builds on"| node_card_base
node_langs_card -->|"builds on"| node_card_base
node_waka_card -->|"builds on"| node_card_base
node_stats_card -->|"uses labels"| node_translations
node_langs_card -->|"uses layout helpers"| node_svg_render
node_stats_card -->|"resolves colors"| node_themes
node_repo_card -->|"resolves colors"| node_themes
node_langs_card -->|"resolves colors"| node_themes
node_waka_card -->|"resolves colors"| node_themes
node_stats_fetch -->|"requests data"| node_github
node_repo_fetch -->|"requests data"| node_github
node_langs_fetch -->|"requests data"| node_github
node_waka_fetch -->|"requests activity"| node_wakatime_service
node_pat_status -->|"checks credentials"| node_github
node_up_status -->|"checks availability"| node_github

click node_express "https://github.com/anuraghazra/github-readme-stats/blob/master/express.js"
click node_stats_route "https://github.com/anuraghazra/github-readme-stats/blob/master/api/index.js"
click node_pin_route "https://github.com/anuraghazra/github-readme-stats/blob/master/api/pin.js"
click node_gist_route "https://github.com/anuraghazra/github-readme-stats/blob/master/api/gist.js"
click node_langs_route "https://github.com/anuraghazra/github-readme-stats/blob/master/api/top-langs.js"
click node_waka_route "https://github.com/anuraghazra/github-readme-stats/blob/master/api/wakatime.js"
click node_pat_status "https://github.com/anuraghazra/github-readme-stats/blob/master/api/status/pat-info.js"
click node_up_status "https://github.com/anuraghazra/github-readme-stats/blob/master/api/status/up.js"
click node_stats_fetch "https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/stats.js"
click node_repo_fetch "https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/repo.js"
click node_gist_fetch "https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/gist.js"
click node_langs_fetch "https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/top-languages.js"
click node_waka_fetch "https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/wakatime.js"
click node_stats_card "https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/stats.js"
click node_repo_card "https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/repo.js"
click node_gist_card "https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/gist.js"
click node_langs_card "https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/top-languages.js"
click node_waka_card "https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/wakatime.js"
click node_rank "https://github.com/anuraghazra/github-readme-stats/blob/master/src/calculateRank.js"
click node_card_base "https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/Card.js"
click node_svg_render "https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/render.js"
click node_access "https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/access.js"
click node_cache "https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/cache.js"
click node_translations "https://github.com/anuraghazra/github-readme-stats/blob/master/src/translations.js"
click node_themes "https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/color.js"
click node_common_util "https://github.com/anuraghazra/github-readme-stats/tree/master/src/common"

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_express,node_stats_route,node_pin_route,node_gist_route,node_langs_route,node_waka_route,node_pat_status,node_up_status toneBlue
class node_stats_fetch,node_repo_fetch,node_gist_fetch,node_langs_fetch,node_waka_fetch,node_rank toneAmber
class node_stats_card,node_repo_card,node_gist_card,node_langs_card,node_waka_card,node_github,node_wakatime_service toneMint
class node_card_base,node_svg_render,node_access,node_cache,node_translations,node_themes,node_common_util toneRose
class node_reader toneIndigo
```

## Components

### API routes

- [Express adapter](https://github.com/anuraghazra/github-readme-stats/blob/master/express.js): `express.js`
- [Stats endpoint](https://github.com/anuraghazra/github-readme-stats/blob/master/api/index.js): `api/index.js`
- [Repository pin endpoint](https://github.com/anuraghazra/github-readme-stats/blob/master/api/pin.js): `api/pin.js`
- [Gist endpoint](https://github.com/anuraghazra/github-readme-stats/blob/master/api/gist.js): `api/gist.js`
- [Languages endpoint](https://github.com/anuraghazra/github-readme-stats/blob/master/api/top-langs.js): `api/top-langs.js`
- [WakaTime endpoint](https://github.com/anuraghazra/github-readme-stats/blob/master/api/wakatime.js): `api/wakatime.js`
- [Token status](https://github.com/anuraghazra/github-readme-stats/blob/master/api/status/pat-info.js): `api/status/pat-info.js`
- [Service status](https://github.com/anuraghazra/github-readme-stats/blob/master/api/status/up.js): `api/status/up.js`

### Data retrieval

- [GitHub stats fetcher](https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/stats.js): `src/fetchers/stats.js`
- [Repository fetcher](https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/repo.js): `src/fetchers/repo.js`
- [Gist fetcher](https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/gist.js): `src/fetchers/gist.js`
- [Language fetcher](https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/top-languages.js): `src/fetchers/top-languages.js`
- [WakaTime fetcher](https://github.com/anuraghazra/github-readme-stats/blob/master/src/fetchers/wakatime.js): `src/fetchers/wakatime.js`
- [Rank calculation](https://github.com/anuraghazra/github-readme-stats/blob/master/src/calculateRank.js): `src/calculateRank.js`

### Card rendering

- [Stats card](https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/stats.js): `src/cards/stats.js`
- [Repository pin card](https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/repo.js): `src/cards/repo.js`
- [Gist card](https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/gist.js): `src/cards/gist.js`
- [Top languages card](https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/top-languages.js): `src/cards/top-languages.js`
- [WakaTime card](https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/wakatime.js): `src/cards/wakatime.js`

### Shared services

- [Card framework](https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/Card.js): `src/common/Card.js`
- [SVG rendering helpers](https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/render.js): `src/common/render.js`
- [Access checks](https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/access.js): `src/common/access.js`
- [Response caching](https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/cache.js): `src/common/cache.js`
- [Translations](https://github.com/anuraghazra/github-readme-stats/blob/master/src/translations.js): `src/translations.js`
- [Themes and colors](https://github.com/anuraghazra/github-readme-stats/blob/master/src/common/color.js): `src/common/color.js`
- [Formatting and utilities](https://github.com/anuraghazra/github-readme-stats/tree/master/src/common): `src/common`

### Other components

- **README reader**
- **GitHub API**
- **WakaTime API**

## Connections

- README reader → Stats endpoint: requests card
- README reader → Repository pin endpoint: requests pin
- README reader → Gist endpoint: requests gist
- README reader → Languages endpoint: requests card
- README reader → WakaTime endpoint: requests card
- Express adapter → Stats endpoint: routes to (evidence: `express.js`)
- Express adapter → Repository pin endpoint: routes to (evidence: `express.js`)
- Express adapter → Gist endpoint: routes to (evidence: `express.js`)
- Express adapter → Languages endpoint: routes to (evidence: `express.js`)
- Express adapter → WakaTime endpoint: routes to (evidence: `express.js`)
- Stats endpoint → Access checks: checks access (evidence: `api/index.js`)
- Stats endpoint → GitHub stats fetcher: fetches stats (evidence: `api/index.js`)
- Stats endpoint → Stats card: renders card (evidence: `api/index.js`)
- Stats endpoint → Response caching: sets cache headers (evidence: `api/index.js`)
- Stats endpoint → Translations: checks locale (evidence: `api/index.js`)
- Repository pin endpoint → Access checks: checks access (evidence: `api/pin.js`)
- Repository pin endpoint → Repository fetcher: fetches repository (evidence: `api/pin.js`)
- Repository pin endpoint → Repository pin card: renders card (evidence: `api/pin.js`)
- Repository pin endpoint → Response caching: sets cache headers (evidence: `api/pin.js`)
- Gist endpoint → Access checks: checks access (evidence: `api/gist.js`)
- Gist endpoint → Gist fetcher: fetches gist (evidence: `api/gist.js`)
- Gist endpoint → Gist card: renders card (evidence: `api/gist.js`)
- Gist endpoint → Response caching: sets cache headers (evidence: `api/gist.js`)
- Languages endpoint → Access checks: checks access (evidence: `api/top-langs.js`)
- Languages endpoint → Language fetcher: fetches languages (evidence: `api/top-langs.js`)
- Languages endpoint → Top languages card: renders card (evidence: `api/top-langs.js`)
- Languages endpoint → Response caching: sets cache headers (evidence: `api/top-langs.js`)
- WakaTime endpoint → Access checks: checks access (evidence: `api/wakatime.js`)
- WakaTime endpoint → WakaTime fetcher: fetches activity (evidence: `api/wakatime.js`)
- WakaTime endpoint → WakaTime card: renders card (evidence: `api/wakatime.js`)
- GitHub stats fetcher → Rank calculation: calculates rank (evidence: `src/fetchers/stats.js`)
- Stats card → Card framework: builds on (evidence: `src/cards/stats.js`)
- Repository pin card → Card framework: builds on (evidence: `src/cards/repo.js`)
- Top languages card → Card framework: builds on (evidence: `src/cards/top-languages.js`)
- WakaTime card → Card framework: builds on (evidence: `src/cards/wakatime.js`)
- Stats card → Translations: uses labels (evidence: `src/cards/stats.js`)
- Top languages card → SVG rendering helpers: uses layout helpers (evidence: `src/cards/top-languages.js`)
- Stats card → Themes and colors: resolves colors (evidence: `src/cards/stats.js`)
- Repository pin card → Themes and colors: resolves colors (evidence: `src/cards/repo.js`)
- Top languages card → Themes and colors: resolves colors (evidence: `src/cards/top-languages.js`)
- WakaTime card → Themes and colors: resolves colors (evidence: `src/cards/wakatime.js`)
- GitHub stats fetcher → GitHub API: requests data (evidence: `src/fetchers/stats.js`)
- Repository fetcher → GitHub API: requests data (evidence: `src/fetchers/repo.js`)
- Language fetcher → GitHub API: requests data (evidence: `src/fetchers/top-languages.js`)
- WakaTime fetcher → WakaTime API: requests activity (evidence: `src/fetchers/wakatime.js`)
- Token status → GitHub API: checks credentials (evidence: `api/status/pat-info.js`)
- Service status → GitHub API: checks availability (evidence: `api/status/up.js`)
