# lib-pku/libpku architecture

> Architecture diagram of the GitHub repository lib-pku/libpku, 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/lib-pku/libpku
- Repository: https://github.com/lib-pku/libpku

## Overview

libpku is a community-maintained archive of university course materials, organized by course and course category. The README’s user workflow is to visit the published site, find a course’s materials, and follow a link to download them. Internally, index.js walks the repository tree, builds a linked table of contents, and renders it as HTML. The README documents the published-site workflow; the source excerpt shows index generation, but not the deployment or serving mechanism.

Main entry points: [`index.js`](https://github.com/lib-pku/libpku/blob/master/index.js) (Repository scan), [`专业课`](https://github.com/lib-pku/libpku/tree/master/%E4%B8%93%E4%B8%9A%E8%AF%BE) (Core courses), [`通选课`](https://github.com/lib-pku/libpku/tree/master/%E9%80%9A%E9%80%89%E8%AF%BE) (Elective courses), [`公选课`](https://github.com/lib-pku/libpku/tree/master/%E5%85%AC%E9%80%89%E8%AF%BE) (General courses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Course archive"]
  node_core_courses["Core courses"]
  node_electives["Elective courses"]
  node_general_courses["General courses"]
  node_politics["Politics courses"]
  node_summer["Summer courses"]
  node_english["English courses"]
end

subgraph group_generation["Catalog generation"]
  node_tree_scan["Repository scan<br/>[index.js]"]
  node_toc_build["Linked contents<br/>[index.js]"]
  node_html_render["HTML rendering<br/>[index.js]"]
end

subgraph group_access["Published access"]
  node_website["Published site"]
  node_github_raw["GitHub raw files"]
end

node_student(("Student"))

node_student -->|"browses"| node_website
node_website -->|"links to downloads"| node_github_raw
node_tree_scan -->|"scans tree"| node_core_courses
node_tree_scan -->|"scans tree"| node_electives
node_tree_scan -->|"scans tree"| node_general_courses
node_tree_scan -->|"scans tree"| node_politics
node_tree_scan -->|"scans tree"| node_summer
node_tree_scan -->|"scans tree"| node_english
node_tree_scan -->|"builds links"| node_toc_build
node_toc_build -->|"renders markup"| node_html_render
node_html_render -.->|"publishes output"| node_website

click node_core_courses "https://github.com/lib-pku/libpku/tree/master/%E4%B8%93%E4%B8%9A%E8%AF%BE"
click node_electives "https://github.com/lib-pku/libpku/tree/master/%E9%80%9A%E9%80%89%E8%AF%BE"
click node_general_courses "https://github.com/lib-pku/libpku/tree/master/%E5%85%AC%E9%80%89%E8%AF%BE"
click node_politics "https://github.com/lib-pku/libpku/tree/master/%E6%94%BF%E6%B2%BB%E8%AF%BE"
click node_summer "https://github.com/lib-pku/libpku/tree/master/%E6%9A%91%E6%9C%9F%E8%AF%BE"
click node_english "https://github.com/lib-pku/libpku/tree/master/%E8%8B%B1%E8%AF%AD%E8%AF%BE"
click node_tree_scan "https://github.com/lib-pku/libpku/blob/master/index.js"
click node_toc_build "https://github.com/lib-pku/libpku/blob/master/index.js"
click node_html_render "https://github.com/lib-pku/libpku/blob/master/index.js"

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_core_courses,node_electives,node_general_courses,node_politics,node_summer,node_english toneBlue
class node_tree_scan,node_toc_build,node_html_render toneAmber
class node_website,node_github_raw toneMint
class node_student toneIndigo
```

## Components

### Course archive

- [Core courses](https://github.com/lib-pku/libpku/tree/master/%E4%B8%93%E4%B8%9A%E8%AF%BE): `专业课`
- [Elective courses](https://github.com/lib-pku/libpku/tree/master/%E9%80%9A%E9%80%89%E8%AF%BE): `通选课`
- [General courses](https://github.com/lib-pku/libpku/tree/master/%E5%85%AC%E9%80%89%E8%AF%BE): `公选课`
- [Politics courses](https://github.com/lib-pku/libpku/tree/master/%E6%94%BF%E6%B2%BB%E8%AF%BE): `政治课`
- [Summer courses](https://github.com/lib-pku/libpku/tree/master/%E6%9A%91%E6%9C%9F%E8%AF%BE): `暑期课`
- [English courses](https://github.com/lib-pku/libpku/tree/master/%E8%8B%B1%E8%AF%AD%E8%AF%BE): `英语课`

### Catalog generation

- [Repository scan](https://github.com/lib-pku/libpku/blob/master/index.js): `index.js`
- [Linked contents](https://github.com/lib-pku/libpku/blob/master/index.js): `index.js`
- [HTML rendering](https://github.com/lib-pku/libpku/blob/master/index.js): `index.js`

### Published access

- **Published site**
- **GitHub raw files**

### Other components

- **Student**

## Connections

- Student → Published site: browses (evidence: `README.md`)
- Published site → GitHub raw files: links to downloads (evidence: `README.md`)
- Repository scan → Core courses: scans tree (evidence: `index.js`)
- Repository scan → Elective courses: scans tree (evidence: `index.js`)
- Repository scan → General courses: scans tree (evidence: `index.js`)
- Repository scan → Politics courses: scans tree (evidence: `index.js`)
- Repository scan → Summer courses: scans tree (evidence: `index.js`)
- Repository scan → English courses: scans tree (evidence: `index.js`)
- Repository scan → Linked contents: builds links (evidence: `index.js`)
- Linked contents → HTML rendering: renders markup (evidence: `index.js`)
- HTML rendering → Published site: publishes output
