How interglobalmedia/wikipedia-viewer works
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: index.js Application entry · package.json Package scripts · styles.scss Stylesheet composition · vite.config.js Vite build
Components 16
Browser Application
Client-side Wikipedia viewer runtime.
- Page shell · Supplies DOM targets for the application.
index.html - Application entry · Wires startup and UI events.
src/index.js - Viewer initialization · Handles search results and random-entry actions.
src/modules/wikiViewerInit.js - Scroll interaction · Manages independent scroll-oriented UI behavior.
src/modules/scrollStep.js
Presentation
Composed SCSS for visible application regions.
- Stylesheet composition · Imports global and feature-level styles.
src/styles/styles.scss - Global styles
src/styles/base/_global.scss - Search styles
src/styles/modules/_search.scss
Build & Hosting
Static build and GitHub Pages delivery.
- Vite build · Bundles browser assets for development and production.
vite.config.js - Package scripts · Defines build and consolidated validation commands.
package.json - Deployment workflow · Builds and deploys on main pushes or manual dispatch.
.github/workflows/deploy.yml - GitHub Pages · Hosts the deployed browser application.
Quality Gates
Automated behavior and source validation.
- Viewer tests · Validates viewer behavior with coverage.
src/modules/wikiViewerInit.test.js - Scroll tests · Validates scroll behavior with coverage.
src/modules/scrollStep.test.js - Pre-commit hook · Runs consolidated validation before commits.
.husky/pre-commit - Lint & formatting · ESLint, Stylelint, and Prettier enforce consistency.
Other components
- Wikipedia API & pages · Public search and random-entry boundary.
Connections 15
- 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