# sir-gon/algorithm-exercises-js architecture

> Architecture diagram of the GitHub repository sir-gon/algorithm-exercises-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sir-gon/algorithm-exercises-js
- Repository: https://github.com/sir-gon/algorithm-exercises-js

## Overview

1. This repository is a collection of algorithm solutions written in Node.js ES6, organized as two main problem domains: HackerRank and Project Euler. It is not an application with runtime services; the “architecture” is primarily a code-and-test system for solving exercises.

2. The core source tree lives under `src/`, and is split by problem source:
   - `src/hackerrank/...` contains challenge solutions grouped by category such as warmup, implementation, interview preparation kit, and projecteuler.
   - `src/projecteuler/...` contains numbered Project Euler solutions plus shared helpers and small library abstractions.
   - `src/problem0000.js` and `src/examples/` appear to be small standalone/example entry points.

3. Each exercise is typically implemented as a single solution module paired with a Jest test file in the same directory. The tests are the main execution path of the repository: they load the solution function, feed it fixtures or inline cases, and verify the result. This TDD-style pairing is the central structural pattern.

4. Many problems also include JSON fixture files beside the tests, such as `*.testcases.json`, `*.small.testcases.json`, or `*.big.testcases.json`. These files drive data-heavy or boundary-heavy test cases and are part of the test data layer, not application state.

5. Some problems include multiple implementations of the same algorithm, usually a brute-force version and an optimized version. This shows up in filenames like `*_bruteforce.js`, `*_optimized.js`, `*-alt.js`, and corresponding tests. In the architecture diagram, these are alternative solution branches under the same problem family, not separate subsystems.

6. Shared code is minimal but important:
   - `src/hackerrank/lib/` contains utility structures like `BigIntMath.js` and `Node.js`.
   - `src/projecteuler/helpers/` contains reusable math/string helpers such as prime generation, divisors, Collatz, palindromes, matrix utilities, and numeric conversions.
   - `src/projecteuler/lib/` contains tree/node builders used by some Euler problems.
   These shared modules are the main internal dependencies across many solutions.

7. There is also a small cross-cutting support layer:
   - `src/constants/` holds shared constants, notably date/time-related values.
   - `src/logger.js` suggests a lightweight logging abstraction used by tests and solution runs.
   These are support utilities rather than core algorithm logic.

8. The documentation layer is substantial and mirrors the source taxonomy. `docs/` contains markdown writeups for many HackerRank and Project Euler problems, including solution notes. These docs are not just user-facing; they likely capture reasoning and algorithm choices that correspond to the code variants.

9. The repository is heavily test-driven and quality-gated. Jest is the runtime test framework, while ESLint, Prettier, Markdown linting, YAML linting, and security scans are enforced through configuration files and GitHub Actions workflows. The CI boundary is therefore “source + docs must pass static checks and tests before merge.”

10. External dependencies are intentionally limited at runtime. The README emphasizes “vanilla code,” and the architecture reflects that: solutions are mostly self-contained pure functions with deterministic inputs/outputs, minimizing coupling to libraries or services.

11. Docker and Make are used as environment wrappers around the same codebase. `compose.yaml`, `Dockerfile`, and `Makefile` provide reproducible commands for linting, testing, and running a production-like container. This creates a platform boundary: local Node execution, containerized development/testing, and final image validation.

12. The GitHub Actions workflows form the automation layer. They cover unit tests, linting, code scanning, dependency/security checks, and image building. In an architecture diagram, this is the CI/CD lane that consumes the repo but does not affect runtime behavior.

13. A useful way to diagram the repository is as three layers:
   - Problem inputs/fixtures and documentation,
   - Algorithm implementations and reusable helpers,
   - Jest/CI/Docker tooling that validates the implementations.
   The main data flow is: fixtures and problem statements inform solution modules, which are exercised by tests, which are then validated by local tooling and CI.

14. There are no databases, message queues, web endpoints, or third-party service integrations in the application sense. The only “external systems” that materially affect architecture are the Node.js runtime, Jest test runner, Docker/Compose, and GitHub Actions.

Main entry points: [`jest.config.js`](https://github.com/sir-gon/algorithm-exercises-js/blob/main/jest.config.js) (Jest), [`src/projecteuler`](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/projecteuler) (Euler Problems), [`src/hackerrank/interview_preparation_kit`](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/interview_preparation_kit) (Interview Kit), [`src/hackerrank/implementation`](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/implementation) (Implementation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_source["Source & Problems"]
  node_hackerrank_warmup["Warmup<br/>problem set"]
  node_hackerrank_impl["Implementation<br/>problem set"]
  node_hackerrank_kit["Interview Kit<br/>problem set"]
  node_projecteuler_src["Euler Problems<br/>problem set"]
  node_problem0000["Problem 0000<br/>entry point<br/>[problem0000.js]"]
  node_examples["Examples<br/>sample code"]
end

subgraph group_shared["Shared Code"]
  node_hr_lib["HR Lib<br/>shared utils"]
  node_pe_helpers["Euler Helpers<br/>shared math"]
  node_pe_lib["Euler Lib<br/>tree helpers"]
  node_constants["Constants<br/>shared config"]
  node_logger["Logger<br/>support<br/>[logger.js]"]
end

subgraph group_docs["Docs"]
  node_docs_hr["HackerRank Docs"]
  node_docs_pe["Euler Docs"]
end

subgraph group_tooling["Tooling"]
  node_jest["Jest<br/>test runner<br/>[jest.config.js]"]
  node_lint_format["Lint & Format<br/>static checks<br/>[eslint.config.js]"]
  node_docker_make["Docker/Make<br/>env wrappers"]
end

subgraph group_ci["Automation"]
  node_github_actions["GitHub Actions<br/>ci pipeline<br/>[workflows]"]
end

node_docs_hr -->|"documents"| node_hackerrank_warmup
node_docs_hr -->|"documents"| node_hackerrank_impl
node_docs_hr -->|"documents"| node_hackerrank_kit
node_docs_pe -->|"documents"| node_projecteuler_src
node_hackerrank_warmup -->|"tested by"| node_jest
node_hackerrank_impl -->|"tested by"| node_jest
node_hackerrank_kit -->|"tested by"| node_jest
node_projecteuler_src -->|"tested by"| node_jest
node_examples -->|"tested by"| node_jest
node_hr_lib -->|"supports"| node_hackerrank_impl
node_hr_lib -->|"supports"| node_hackerrank_kit
node_pe_helpers -->|"supports"| node_projecteuler_src
node_pe_lib -->|"supports"| node_projecteuler_src
node_constants -->|"shared by"| node_hackerrank_impl
node_constants -->|"shared by"| node_projecteuler_src
node_logger -->|"supports"| node_jest
node_docker_make -->|"wraps"| node_jest
node_docker_make -->|"wraps"| node_lint_format
node_github_actions -->|"runs"| node_jest
node_github_actions -->|"runs"| node_lint_format
node_github_actions -->|"builds"| node_docker_make
node_projecteuler_src -->|"uses"| node_pe_helpers
node_projecteuler_src -->|"uses"| node_pe_lib
node_hackerrank_kit -->|"uses"| node_hr_lib

click node_hackerrank_warmup "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/warmup"
click node_hackerrank_impl "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/implementation"
click node_hackerrank_kit "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/interview_preparation_kit"
click node_projecteuler_src "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/projecteuler"
click node_problem0000 "https://github.com/sir-gon/algorithm-exercises-js/blob/main/src/problem0000.js"
click node_examples "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/examples"
click node_hr_lib "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/lib"
click node_pe_helpers "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/projecteuler/helpers"
click node_pe_lib "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/projecteuler/lib"
click node_constants "https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/constants"
click node_logger "https://github.com/sir-gon/algorithm-exercises-js/blob/main/src/logger.js"
click node_docs_hr "https://github.com/sir-gon/algorithm-exercises-js/tree/main/docs/hackerrank"
click node_docs_pe "https://github.com/sir-gon/algorithm-exercises-js/tree/main/docs/projecteuler"
click node_jest "https://github.com/sir-gon/algorithm-exercises-js/blob/main/jest.config.js"
click node_lint_format "https://github.com/sir-gon/algorithm-exercises-js/blob/main/eslint.config.js"
click node_docker_make "https://github.com/sir-gon/algorithm-exercises-js/tree/main/Dockerfile"
click node_github_actions "https://github.com/sir-gon/algorithm-exercises-js/blob/main/.github/workflows"

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_hackerrank_warmup,node_hackerrank_impl,node_hackerrank_kit,node_projecteuler_src,node_problem0000,node_examples toneBlue
class node_hr_lib,node_pe_helpers,node_pe_lib,node_constants,node_logger toneAmber
class node_docs_hr,node_docs_pe toneMint
class node_jest,node_lint_format,node_docker_make toneRose
class node_github_actions toneIndigo
```

## Components

### Source & Problems

Problem solutions, paired tests, and fixtures.

- [Warmup](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/warmup): problem set · Small HackerRank exercises with one solution and one test per problem. · `src/hackerrank/warmup`
- [Implementation](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/implementation): problem set · HackerRank implementation challenges and their paired tests. · `src/hackerrank/implementation`
- [Interview Kit](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/interview_preparation_kit): problem set · Grouped HackerRank interview-preparation problems, sometimes with alternative algorithms. · `src/hackerrank/interview_preparation_kit`
- [Euler Problems](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/projecteuler): problem set · Project Euler solutions, variants, and problem-specific tests. · `src/projecteuler`
- [Problem 0000](https://github.com/sir-gon/algorithm-exercises-js/blob/main/src/problem0000.js): entry point · Standalone top-level exercise entry point. · `src/problem0000.js`
- [Examples](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/examples): sample code · Small demonstration entry points and tests. · `src/examples`

### Shared Code

Reusable helpers and support modules used across solutions.

- [HR Lib](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/hackerrank/lib): shared utils · Hackerrank-specific helpers such as BigInt math and node structures. · `src/hackerrank/lib`
- [Euler Helpers](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/projecteuler/helpers): shared math · Reusable numeric, string, matrix, and combinatorics helpers. · `src/projecteuler/helpers`
- [Euler Lib](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/projecteuler/lib): tree helpers · Binary-tree builders and node abstractions for Euler problems. · `src/projecteuler/lib`
- [Constants](https://github.com/sir-gon/algorithm-exercises-js/tree/main/src/constants): shared config · Cross-cutting shared constants, mainly date/time values. · `src/constants`
- [Logger](https://github.com/sir-gon/algorithm-exercises-js/blob/main/src/logger.js): support · Lightweight logging abstraction used by tests and runs. · `src/logger.js`

### Docs

Problem writeups and solution notes mirrored from the source taxonomy.

- [HackerRank Docs](https://github.com/sir-gon/algorithm-exercises-js/tree/main/docs/hackerrank): docs · Markdown problem notes for warmup, implementation, interview kit, and Euler-on-HackerRank. · `docs/hackerrank`
- [Euler Docs](https://github.com/sir-gon/algorithm-exercises-js/tree/main/docs/projecteuler): docs · Markdown writeups for Project Euler problems. · `docs/projecteuler`

### Tooling

Local development, linting, and container wrappers.

- [Jest](https://github.com/sir-gon/algorithm-exercises-js/blob/main/jest.config.js): test runner · Primary execution and assertion framework for solution modules and fixtures. · `jest.config.js`
- [Lint & Format](https://github.com/sir-gon/algorithm-exercises-js/blob/main/eslint.config.js): static checks · ESLint, Prettier, Markdown lint, YAML lint, and related config. · `eslint.config.js`
- [Docker/Make](https://github.com/sir-gon/algorithm-exercises-js/tree/main/Dockerfile): env wrappers · Container and command wrappers for reproducible local validation. · `Dockerfile`

### Automation

GitHub Actions and quality gates.

- [GitHub Actions](https://github.com/sir-gon/algorithm-exercises-js/blob/main/.github/workflows): ci pipeline · Automated test, lint, scan, and image-build workflows. · `.github/workflows`

## Connections

- HackerRank Docs → Warmup: documents · Problem notes explain solution choices and variants.
- HackerRank Docs → Implementation: documents · Problem notes explain solution choices and variants.
- HackerRank Docs → Interview Kit: documents · Problem notes explain solution choices and variants.
- Euler Docs → Euler Problems: documents · Problem notes and writeups mirror solution taxonomy.
- Warmup → Jest: tested by · Each solution is exercised through a colocated test file.
- Implementation → Jest: tested by · Each solution is exercised through a colocated test file.
- Interview Kit → Jest: tested by · Paired tests drive the solution modules and fixtures.
- Euler Problems → Jest: tested by · Problem modules are validated by colocated tests.
- Examples → Jest: tested by · Example code has its own test companion.
- HR Lib → Implementation: supports · Shared Hackerrank utilities are imported by problem solutions.
- HR Lib → Interview Kit: supports · Shared Hackerrank utilities are imported by problem solutions.
- Euler Helpers → Euler Problems: supports · Common numeric and structural helpers are reused across Euler problems.
- Euler Lib → Euler Problems: supports · Tree/node abstractions back selected Euler solutions.
- Constants → Implementation: shared by · Cross-cutting values are consumed where needed.
- Constants → Euler Problems: shared by · Cross-cutting values are consumed where needed.
- Logger → Jest: supports · Logging is used during tests and local runs.
- Docker/Make → Jest: wraps · Containerized and make-based commands run the same tests and checks.
- Docker/Make → Lint & Format: wraps · Local wrappers provide reproducible linting and formatting commands.
- GitHub Actions → Jest: runs · CI executes the test suite.
- GitHub Actions → Lint & Format: runs · CI enforces static checks and formatting.
- GitHub Actions → Docker/Make: builds · CI validates container/image workflows.
- Euler Problems → Euler Helpers: uses · Euler solutions rely on shared helper modules.
- Euler Problems → Euler Lib: uses · Euler solutions rely on shared tree utilities.
- Interview Kit → HR Lib: uses · Selected challenge solutions depend on Hackerrank helpers.
