# interglobalmedia/wikipedia-viewer architecture

> Architecture diagram of the GitHub repository interglobalmedia/wikipedia-viewer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/interglobalmedia/wikipedia-viewer
- Repository: https://github.com/interglobalmedia/wikipedia-viewer

## Overview

#### Purpose and Runtime
Wikipedia Viewer is a client-side single-page experience for searching Wikipedia entries and opening a random entry. It runs as a Vite-built browser application, with no backend present in the repository. The external data boundary is Wikipedia’s public API/pages.

Paths: `index.html`, `src/index.js`, `vite.config.js`

#### Application Bootstrap
`index.html` supplies the page shell and DOM targets. `src/index.js` is the JavaScript entry point: it loads application behavior, wires user events, and connects UI interactions to the viewer initialization and scrolling modules. The Vite build resolves this entry and bundles JavaScript and SCSS for development and production.

Paths: `index.html`, `src/index.js`, `vite.config.js`

#### Viewer Initialization and Search Flow
`wikiViewerInit` is the primary feature module. It encapsulates viewer setup and the Wikipedia interaction flow: search input/actions produce displayed entry results, while the random action navigates users to a random Wikipedia entry. This module forms the main boundary between DOM/UI behavior and the external Wikipedia service.

Paths: `src/modules/wikiViewerInit.js`, `src/index.js`

#### Scroll Interaction
`scrollStep` provides a separate scroll-oriented UI behavior, likely advancing or managing scroll state independently of search retrieval. Keeping it modular lets startup/event wiring invoke scroll behavior without coupling it to Wikipedia request/rendering logic.

Paths: `src/modules/scrollStep.js`, `src/index.js`

#### Presentation Layer
SCSS is organized as a composed stylesheet: the root stylesheet imports shared global rules and feature-level modules for search, results, random-entry controls, scroll UI, sections, and footer. The style architecture mirrors the visible application regions rather than embedding presentation logic in JavaScript.

Paths: `src/styles/styles.scss`, `src/styles/base/_global.scss`, `src/styles/modules/_search.scss`

#### Build, Delivery, and Hosting
Vite provides local development, production bundling, and preview. GitHub Actions builds the static artifact and deploys it to GitHub Pages on pushes to `main` or manual workflow dispatch. GitHub Pages is the hosting boundary; no server runtime or database is indicated.

Paths: `vite.config.js`, `.github/workflows/deploy.yml`, `package.json`

#### Quality Gates
Vitest with Istanbul validates the two behavior modules, while the pre-commit hook runs the repository’s consolidated validation command. ESLint, Stylelint, and Prettier enforce source and stylesheet consistency before changes enter the main delivery path.

Paths: `src/modules/wikiViewerInit.test.js`, `src/modules/scrollStep.test.js`, `.husky/pre-commit`

Main entry points: [`src/index.js`](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/index.js) (Application entry), [`package.json`](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/package.json) (Package scripts), [`src/styles/styles.scss`](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/styles/styles.scss) (Stylesheet composition), [`vite.config.js`](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/vite.config.js) (Vite build)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser Application"]
  node_page_shell["Page shell<br/>HTML<br/>[index.html]"]
  node_app_entry["Application entry<br/>JavaScript entry<br/>[index.js]"]
  node_viewer_init["Viewer initialization<br/>feature module<br/>[wikiViewerInit.js]"]
  node_scroll_step["Scroll interaction<br/>feature module<br/>[scrollStep.js]"]
end

subgraph group_presentation["Presentation"]
  node_root_styles["Stylesheet composition<br/>SCSS entry<br/>[styles.scss]"]
  node_global_styles["Global styles<br/>SCSS module<br/>[_global.scss]"]
  node_search_styles["Search styles<br/>SCSS module<br/>[_search.scss]"]
end

subgraph group_delivery["Build &amp; Hosting"]
  node_vite["Vite build<br/>build tool<br/>[vite.config.js]"]
  node_package_scripts["Package scripts<br/>tooling manifest<br/>[package.json]"]
  node_deploy_workflow["Deployment workflow<br/>GitHub Actions<br/>[deploy.yml]"]
  node_github_pages{{"GitHub Pages<br/>static hosting"}}
end

subgraph group_quality["Quality Gates"]
  node_viewer_tests["Viewer tests<br/>Vitest tests"]
  node_scroll_tests["Scroll tests<br/>Vitest tests<br/>[scrollStep.test.js]"]
  node_pre_commit["Pre-commit hook<br/>Git hook<br/>[pre-commit]"]
  node_lint_format["Lint &amp; formatting<br/>validation tools"]
end

node_wikipedia{{"Wikipedia API &amp; pages<br/>external service"}}

node_page_shell -->|"loads"| node_app_entry
node_app_entry -->|"initializes"| node_viewer_init
node_app_entry -->|"invokes"| node_scroll_step
node_viewer_init -->|"searches and opens random entries"| node_wikipedia
node_root_styles -->|"imports"| node_global_styles
node_root_styles -->|"imports"| node_search_styles
node_vite -->|"bundles"| node_app_entry
node_vite -->|"bundles"| node_root_styles
node_deploy_workflow -->|"runs build"| node_package_scripts
node_package_scripts -->|"invokes"| node_vite
node_deploy_workflow -->|"deploys static artifact"| node_github_pages
node_viewer_tests -.->|"validates"| node_viewer_init
node_scroll_tests -.->|"validates"| node_scroll_step
node_pre_commit -->|"runs validation"| node_package_scripts
node_package_scripts -->|"runs"| node_lint_format

click node_page_shell "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/index.html"
click node_app_entry "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/index.js"
click node_viewer_init "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/wikiViewerInit.js"
click node_scroll_step "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/scrollStep.js"
click node_root_styles "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/styles/styles.scss"
click node_global_styles "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/styles/base/_global.scss"
click node_search_styles "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/styles/modules/_search.scss"
click node_vite "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/vite.config.js"
click node_package_scripts "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/package.json"
click node_deploy_workflow "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/.github/workflows/deploy.yml"
click node_viewer_tests "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/wikiViewerInit.test.js"
click node_scroll_tests "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/scrollStep.test.js"
click node_pre_commit "https://github.com/interglobalmedia/wikipedia-viewer/blob/main/.husky/pre-commit"

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_page_shell,node_app_entry,node_viewer_init,node_scroll_step toneBlue
class node_root_styles,node_global_styles,node_search_styles toneAmber
class node_vite,node_package_scripts,node_deploy_workflow,node_github_pages toneMint
class node_viewer_tests,node_scroll_tests,node_pre_commit,node_lint_format toneRose
class node_wikipedia toneNeutral
```

## Components

### Browser Application

Client-side Wikipedia viewer runtime.

- [Page shell](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/index.html): HTML · Supplies DOM targets for the application. · `index.html`
- [Application entry](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/index.js): JavaScript entry · Wires startup and UI events. · `src/index.js`
- [Viewer initialization](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/wikiViewerInit.js): feature module · Handles search results and random-entry actions. · `src/modules/wikiViewerInit.js`
- [Scroll interaction](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/scrollStep.js): feature module · Manages independent scroll-oriented UI behavior. · `src/modules/scrollStep.js`

### Presentation

Composed SCSS for visible application regions.

- [Stylesheet composition](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/styles/styles.scss): SCSS entry · Imports global and feature-level styles. · `src/styles/styles.scss`
- [Global styles](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/styles/base/_global.scss): SCSS module · `src/styles/base/_global.scss`
- [Search styles](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/styles/modules/_search.scss): SCSS module · `src/styles/modules/_search.scss`

### Build & Hosting

Static build and GitHub Pages delivery.

- [Vite build](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/vite.config.js): build tool · Bundles browser assets for development and production. · `vite.config.js`
- [Package scripts](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/package.json): tooling manifest · Defines build and consolidated validation commands. · `package.json`
- [Deployment workflow](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/.github/workflows/deploy.yml): GitHub Actions · Builds and deploys on main pushes or manual dispatch. · `.github/workflows/deploy.yml`
- **GitHub Pages**: static hosting · Hosts the deployed browser application.

### Quality Gates

Automated behavior and source validation.

- [Viewer tests](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/wikiViewerInit.test.js): Vitest tests · Validates viewer behavior with coverage. · `src/modules/wikiViewerInit.test.js`
- [Scroll tests](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/src/modules/scrollStep.test.js): Vitest tests · Validates scroll behavior with coverage. · `src/modules/scrollStep.test.js`
- [Pre-commit hook](https://github.com/interglobalmedia/wikipedia-viewer/blob/main/.husky/pre-commit): Git hook · Runs consolidated validation before commits. · `.husky/pre-commit`
- **Lint & formatting**: validation tools · ESLint, Stylelint, and Prettier enforce consistency.

### Other components

- **Wikipedia API & pages**: external service · Public search and random-entry boundary.

## Connections

- Page shell → Application entry: loads
- Application entry → Viewer initialization: initializes
- Application entry → Scroll interaction: invokes
- Viewer initialization → Wikipedia API & pages: searches and opens random entries
- Stylesheet composition → Global styles: imports
- Stylesheet composition → Search styles: imports
- Vite build → Application entry: bundles
- Vite build → Stylesheet composition: bundles
- Deployment workflow → Package scripts: runs build
- Package scripts → Vite build: invokes
- Deployment workflow → GitHub Pages: deploys static artifact
- Viewer tests → Viewer initialization: validates
- Scroll tests → Scroll interaction: validates
- Pre-commit hook → Package scripts: runs validation
- Package scripts → Lint & formatting: runs
