# amejiarosario/dsa.js-data-structures-algorithms-javascript architecture

> Architecture diagram of the GitHub repository amejiarosario/dsa.js-data-structures-algorithms-javascript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amejiarosario/dsa.js-data-structures-algorithms-javascript
- Repository: https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript

## Overview

1. This repository has two primary faces: an educational codebase and a publishable Node.js package. The package exposes data structures and algorithms through `src/index.js`, while the book content in `book/` explains the concepts and points back to the code examples.

2. The core production library lives under `src/`. It is organized into reusable subsystems by topic: `algorithms/`, `data-structures/`, and `runtimes/`. This is the main boundary for the npm module; the rest of the repo mostly supports learning, validation, or experimentation.

3. `src/data-structures/` is the largest subsystem and contains implementations for linear and non-linear containers: arrays, linked lists, stacks, queues, sets, maps, heaps, graphs, trees, and custom structures like LRU caches. Many folders contain multiple versions of the same structure, which suggests the repo compares alternative implementations rather than maintaining a single canonical one.

4. `src/algorithms/` contains standalone algorithm implementations such as sorting, permutations, Fibonacci variants, knapsack, combination sum, and minimum-finding. The `sorting/` subfolder groups the major sort families together and shares helper logic via `sorting-common.js`, indicating a small internal utility boundary inside the algorithms layer.

5. `src/runtimes/` is a separate teaching-oriented subsystem focused on complexity analysis rather than data structures themselves. Files here appear to model runtime behavior and asymptotic patterns, so this section acts as the “analysis” layer that complements the concrete implementations.

6. The `book/` directory is a content pipeline, not application logic. It contains AsciiDoc chapters, images, and embedded example code for the published DSA.js book. The book mirrors the same subject areas as `src/`, but it is organized as narrative chapters and exercises rather than exportable library modules.

7. `book/interview-questions/` is a curated solution set for common problems, each usually paired with a `.spec.js` file. This section functions like a problem-solution catalog and is separate from the reusable library: it is more about worked examples than reusable abstractions.

8. `lab/` is an exercise sandbox. It contains many problem sets grouped by topic, with solutions, variants, and tests. Unlike `src/`, which is the package-facing code, `lab/` is structured for practice and likely includes intentionally duplicated or exploratory implementations.

9. `benchmarks/` is the performance-analysis subsystem. It includes comparison scripts, data files, and benchmark cases for array rotation, two-sum, hashing, statistics, and set-vs-array comparisons. The data flow here is: benchmark runner -> multiple candidate implementations -> shared input datasets -> performance output used to compare tradeoffs.

10. Testing is embedded throughout the repo rather than centralized in one test folder. Most implementation folders include colocated `.spec.js` files, and the repo also has separate Jasmine/Jest configuration files plus CI configuration. This indicates the codebase supports multiple test runners or has evolved over time with mixed testing conventions.

11. `deprecated/` and `book/deprecated/` are explicit legacy boundaries. They preserve older implementations and documentation without mixing them into the main library path, which helps keep the current architecture clean while retaining historical material.

12. Operationally, the repo is Node.js-based and CommonJS-oriented, and it includes packaging and automation scaffolding such as `package.json`, lockfile, Dockerfile, CircleCI, ESLint, and editor configs. Those tools support development, testing, and CI, but the architectural center remains the code library plus the book/exercise/benchmark content that surrounds it.

13. If you are drawing the architecture, the important flows are: book chapters reference source files; source files are exercised by unit tests; benchmark scripts compare alternate implementations against shared datasets; and `src/index.js` serves as the package entry point that exposes the reusable API surface.

Main entry points: [`src/data-structures`](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures) (Data structures), [`src/index.js`](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/blob/master/src/index.js) (Package API), [`src/algorithms`](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/algorithms) (Algorithms), [`benchmarks`](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/benchmarks) (Benchmarks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core library"]
  node_src_index["Package API<br/>entrypoint<br/>[index.js]"]
  node_src_algorithms["Algorithms"]
  node_src_sorting["Sorting<br/>algorithms"]
  node_src_data["Data structures"]
  node_src_arrays["Arrays<br/>structures"]
  node_src_lists["Linked lists<br/>structures"]
  node_src_maps["Maps<br/>structures"]
  node_src_sets["Sets<br/>structures"]
  node_src_trees["Trees<br/>structures"]
  node_src_heaps["Heaps<br/>structures"]
  node_src_graphs["Graphs<br/>structures"]
  node_src_custom["LRU cache<br/>custom-structure"]
  node_src_runtimes["Runtimes<br/>analysis"]
end

subgraph group_content["Learning content"]
  node_book["Book<br/>documentation"]
  node_book_interview["Interview Qs<br/>solutions"]
  node_lab["Lab<br/>exercises"]
end

subgraph group_analysis["Validation and performance"]
  node_benchmarks["Benchmarks<br/>perf-suite"]
  node_tests["Specs<br/>test-harness"]
  node_tooling["Tooling<br/>devops"]
end

node_src_index -->|"exports"| node_src_algorithms
node_src_index -->|"exports"| node_src_data
node_src_index -->|"exports"| node_src_runtimes
node_src_algorithms -->|"includes"| node_src_sorting
node_src_data -->|"contains"| node_src_arrays
node_src_data -->|"contains"| node_src_lists
node_src_data -->|"contains"| node_src_maps
node_src_data -->|"contains"| node_src_sets
node_src_data -->|"contains"| node_src_trees
node_src_data -->|"contains"| node_src_heaps
node_src_data -->|"contains"| node_src_graphs
node_src_data -->|"contains"| node_src_custom
node_src_sets -.->|"shares"| node_src_maps
node_src_maps -.->|"shares"| node_src_trees
node_book -->|"references"| node_src_algorithms
node_book -->|"references"| node_src_data
node_book_interview -->|"demonstrates"| node_src_data
node_lab -->|"practices"| node_src_data
node_lab -->|"practices"| node_src_algorithms
node_benchmarks -->|"compares"| node_src_algorithms
node_benchmarks -->|"compares"| node_src_data
node_benchmarks -.->|"uses"| node_tests
node_tests -->|"verifies"| node_src_index
node_tests -->|"verifies"| node_book_interview
node_tooling -.->|"packages"| node_src_index
node_tooling -.->|"runs"| node_tests

click node_src_index "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/blob/master/src/index.js"
click node_src_algorithms "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/algorithms"
click node_src_sorting "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/algorithms/sorting"
click node_src_data "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures"
click node_src_arrays "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/arrays"
click node_src_lists "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/linked-lists"
click node_src_maps "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/maps"
click node_src_sets "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/sets"
click node_src_trees "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/trees"
click node_src_heaps "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/heaps"
click node_src_graphs "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/graphs"
click node_src_custom "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/custom"
click node_src_runtimes "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/runtimes"
click node_book "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/book"
click node_book_interview "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/book/interview-questions"
click node_lab "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/lab"
click node_benchmarks "https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/benchmarks"

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_src_index,node_src_algorithms,node_src_sorting,node_src_data,node_src_arrays,node_src_lists,node_src_maps,node_src_sets,node_src_trees,node_src_heaps,node_src_graphs,node_src_custom,node_src_runtimes toneBlue
class node_book,node_book_interview,node_lab toneAmber
class node_benchmarks,node_tests,node_tooling toneMint
```

## Components

### Core library

Publishable Node.js package and reusable implementations

- [Package API](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/blob/master/src/index.js): entrypoint · CommonJS export surface for the npm package · `src/index.js`
- [Algorithms](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/algorithms): library · Standalone algorithm implementations and shared sorting helpers · `src/algorithms`
- [Sorting](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/algorithms/sorting): algorithms · Major sorting implementations with common utilities · `src/algorithms/sorting`
- [Data structures](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures): library · Core containers and advanced structures · `src/data-structures`
- [Arrays](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/arrays): structures · Array wrapper and related behaviors · `src/data-structures/arrays`
- [Linked lists](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/linked-lists): structures · Linked-list variants and node models · `src/data-structures/linked-lists`
- [Maps](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/maps): structures · Hash maps and tree maps · `src/data-structures/maps`
- [Sets](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/sets): structures · Array, hash, map, and tree-backed set implementations · `src/data-structures/sets`
- [Trees](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/trees): structures · Binary trees, balanced trees, and tries · `src/data-structures/trees`
- [Heaps](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/heaps): structures · Heaps and priority-queue variants · `src/data-structures/heaps`
- [Graphs](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/graphs): structures · Graph and node abstractions · `src/data-structures/graphs`
- [LRU cache](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/data-structures/custom): custom-structure · Custom cache implementations built from core primitives · `src/data-structures/custom`
- [Runtimes](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/src/runtimes): analysis · Complexity and runtime behavior examples · `src/runtimes`

### Learning content

Book, interview solutions, and practice exercises

- [Book](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/book): documentation · AsciiDoc chapters and figures for the published DSA.js book · `book`
- [Interview Qs](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/book/interview-questions): solutions · Worked problem solutions paired with specs · `book/interview-questions`
- [Lab](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/lab): exercises · Practice sandboxes with variants and tests · `lab`

### Validation and performance

Benchmarks, tests, and repository tooling

- [Benchmarks](https://github.com/amejiarosario/dsa.js-data-structures-algorithms-javascript/tree/master/benchmarks): perf-suite · Performance comparisons across competing implementations · `benchmarks`
- **Specs**: test-harness · Colocated spec files and repo-level runners/configuration
- **Tooling**: devops · Package metadata, linting, CI, and container automation

## Connections

- Package API → Algorithms: exports · Main entry point exposes algorithm APIs
- Package API → Data structures: exports · Main entry point exposes data-structure APIs
- Package API → Runtimes: exports · Main entry point exposes runtime examples
- Algorithms → Sorting: includes · Sorting is the main internal algorithms boundary
- Data structures → Arrays: contains · Container family split by major structure type
- Data structures → Linked lists: contains · Container family split by major structure type
- Data structures → Maps: contains · Container family split by major structure type
- Data structures → Sets: contains · Container family split by major structure type
- Data structures → Trees: contains · Container family split by major structure type
- Data structures → Heaps: contains · Container family split by major structure type
- Data structures → Graphs: contains · Container family split by major structure type
- Data structures → LRU cache: contains · Specialized structures built from core primitives
- Sets → Maps: shares · Set implementations reuse map-like backing strategies
- Maps → Trees: shares · Tree-map boundary mirrors tree-based ordering concepts
- Book → Algorithms: references · Chapters point back to source examples
- Book → Data structures: references · Chapters mirror the main data-structure topics
- Interview Qs → Data structures: demonstrates · Interview solutions build on reusable structures
- Lab → Data structures: practices · Exercises explore implementations and variants of core structures
- Lab → Algorithms: practices · Exercises explore algorithms and problem-solving patterns
- Benchmarks → Algorithms: compares · Benchmarks evaluate competing algorithm implementations
- Benchmarks → Data structures: compares · Benchmarks evaluate alternative container implementations
- Benchmarks → Specs: uses · Benchmark scripts are wired with specs and runners
- Specs → Package API: verifies · Specs exercise the exported package surface
- Specs → Interview Qs: verifies · Problem solutions are paired with spec files
- Tooling → Package API: packages · Build and publish scaffolding centers on the npm entrypoint
- Tooling → Specs: runs · CI, runners, and config execute the repo test matrix
