# barchart/common-js architecture

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

- Interactive diagram: https://gitdiagram.com/barchart/common-js
- Repository: https://github.com/barchart/common-js

## Overview

@barchart/common-js is a public, browser- and Node-compatible JavaScript utility library, not an application with one fixed end-to-end workflow. A consumer selects utilities for a task; the library supplies reusable language/date values, collections, predicates, serialization, messaging/models, command dispatch, HTTP/REST, and timing behavior. Groups reflect these runtime capabilities. Sampled source supports only the internal edges shown; other branches are retained from the README and file tree without assuming their wiring.

Main entry points: [`commands/CommandHandler.js`](https://github.com/barchart/common-js/blob/master/commands/CommandHandler.js) (Command handlers), [`messaging/Event.js`](https://github.com/barchart/common-js/blob/master/messaging/Event.js) (Events), [`serialization/json/DataType.js`](https://github.com/barchart/common-js/blob/master/serialization/json/DataType.js) (JSON data types), [`lang/Day.js`](https://github.com/barchart/common-js/blob/master/lang/Day.js) (Date and time values)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Language and values"]
  node_language["Language utilities"]
  node_date["Date and time values<br/>[Day.js]"]
  node_numeric["Numeric and currency values<br/>[Decimal.js]"]
end

subgraph group_data["Collections and rules"]
  node_collections["Collections"]
  node_specialized["Specialized collections"]
  node_specifications["Specifications<br/>[Specification.js]"]
  node_serialization["JSON schemas<br/>[Schema.js]"]
  node_datatype["JSON data types<br/>[DataType.js]"]
end

subgraph group_integration["Interaction and transport"]
  node_commands["Command handlers<br/>[CommandHandler.js]"]
  node_mapped["Mapped dispatch"]
  node_composite["Composite dispatch"]
  node_events["Events<br/>[Event.js]"]
  node_eventmap["Named events<br/>[EventMap.js]"]
  node_model["Observable models<br/>[Model.js]"]
  node_gateway["HTTP gateway<br/>[Gateway.js]"]
  node_rest["REST providers<br/>[RestProvider.js]"]
  node_parser["REST parsing<br/>[RestParser.js]"]
end

subgraph group_runtime["Scheduling"]
  node_scheduler["Scheduler<br/>[Scheduler.js]"]
  node_rate["Rate limiting<br/>[RateLimiter.js]"]
  node_serializer["Serialized timing<br/>[Serializer.js]"]
end

node_consumer(("Library consumer"))

node_consumer -->|"uses"| node_language
node_consumer -->|"uses"| node_collections
node_consumer -->|"uses"| node_specifications
node_consumer -->|"uses"| node_serialization
node_consumer -->|"uses"| node_commands
node_consumer -->|"uses"| node_events
node_consumer -->|"uses"| node_model
node_consumer -->|"uses"| node_gateway
node_consumer -->|"uses"| node_rest
node_consumer -->|"uses"| node_scheduler
node_mapped -->|"dispatches to"| node_commands
node_composite -->|"invokes"| node_commands
node_eventmap -->|"creates and fires"| node_events
node_model -->|"fires commits"| node_events
node_parser -->|"uses schema"| node_serialization
node_datatype -->|"revives values"| node_date
node_datatype -->|"revives values"| node_numeric
node_date -->|"uses comparator"| node_collections

click node_language "https://github.com/barchart/common-js/tree/master/lang"
click node_date "https://github.com/barchart/common-js/blob/master/lang/Day.js"
click node_numeric "https://github.com/barchart/common-js/blob/master/lang/Decimal.js"
click node_collections "https://github.com/barchart/common-js/tree/master/collections"
click node_specialized "https://github.com/barchart/common-js/tree/master/collections/specialized"
click node_specifications "https://github.com/barchart/common-js/blob/master/specifications/Specification.js"
click node_serialization "https://github.com/barchart/common-js/blob/master/serialization/json/Schema.js"
click node_datatype "https://github.com/barchart/common-js/blob/master/serialization/json/DataType.js"
click node_commands "https://github.com/barchart/common-js/blob/master/commands/CommandHandler.js"
click node_mapped "https://github.com/barchart/common-js/blob/master/commands/MappedCommandHandler.js"
click node_composite "https://github.com/barchart/common-js/blob/master/commands/CompositeCommandHandler.js"
click node_events "https://github.com/barchart/common-js/blob/master/messaging/Event.js"
click node_eventmap "https://github.com/barchart/common-js/blob/master/messaging/EventMap.js"
click node_model "https://github.com/barchart/common-js/blob/master/models/Model.js"
click node_gateway "https://github.com/barchart/common-js/blob/master/api/http/Gateway.js"
click node_rest "https://github.com/barchart/common-js/blob/master/network/rest/RestProvider.js"
click node_parser "https://github.com/barchart/common-js/blob/master/network/rest/RestParser.js"
click node_scheduler "https://github.com/barchart/common-js/blob/master/timing/Scheduler.js"
click node_rate "https://github.com/barchart/common-js/blob/master/timing/RateLimiter.js"
click node_serializer "https://github.com/barchart/common-js/blob/master/timing/Serializer.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_language,node_date,node_numeric toneBlue
class node_collections,node_specialized,node_specifications,node_serialization,node_datatype toneAmber
class node_commands,node_mapped,node_composite,node_events,node_eventmap,node_model,node_gateway,node_rest,node_parser toneMint
class node_scheduler,node_rate,node_serializer toneRose
class node_consumer toneIndigo
```

## Components

### Language and values

- [Language utilities](https://github.com/barchart/common-js/tree/master/lang): `lang`
- [Date and time values](https://github.com/barchart/common-js/blob/master/lang/Day.js): `lang/Day.js`
- [Numeric and currency values](https://github.com/barchart/common-js/blob/master/lang/Decimal.js): `lang/Decimal.js`

### Collections and rules

- [Collections](https://github.com/barchart/common-js/tree/master/collections): `collections`
- [Specialized collections](https://github.com/barchart/common-js/tree/master/collections/specialized): `collections/specialized`
- [Specifications](https://github.com/barchart/common-js/blob/master/specifications/Specification.js): `specifications/Specification.js`
- [JSON schemas](https://github.com/barchart/common-js/blob/master/serialization/json/Schema.js): `serialization/json/Schema.js`
- [JSON data types](https://github.com/barchart/common-js/blob/master/serialization/json/DataType.js): `serialization/json/DataType.js`

### Interaction and transport

- [Command handlers](https://github.com/barchart/common-js/blob/master/commands/CommandHandler.js): `commands/CommandHandler.js`
- [Mapped dispatch](https://github.com/barchart/common-js/blob/master/commands/MappedCommandHandler.js): `commands/MappedCommandHandler.js`
- [Composite dispatch](https://github.com/barchart/common-js/blob/master/commands/CompositeCommandHandler.js): `commands/CompositeCommandHandler.js`
- [Events](https://github.com/barchart/common-js/blob/master/messaging/Event.js): `messaging/Event.js`
- [Named events](https://github.com/barchart/common-js/blob/master/messaging/EventMap.js): `messaging/EventMap.js`
- [Observable models](https://github.com/barchart/common-js/blob/master/models/Model.js): `models/Model.js`
- [HTTP gateway](https://github.com/barchart/common-js/blob/master/api/http/Gateway.js): `api/http/Gateway.js`
- [REST providers](https://github.com/barchart/common-js/blob/master/network/rest/RestProvider.js): `network/rest/RestProvider.js`
- [REST parsing](https://github.com/barchart/common-js/blob/master/network/rest/RestParser.js): `network/rest/RestParser.js`

### Scheduling

- [Scheduler](https://github.com/barchart/common-js/blob/master/timing/Scheduler.js): `timing/Scheduler.js`
- [Rate limiting](https://github.com/barchart/common-js/blob/master/timing/RateLimiter.js): `timing/RateLimiter.js`
- [Serialized timing](https://github.com/barchart/common-js/blob/master/timing/Serializer.js): `timing/Serializer.js`

### Other components

- **Library consumer**

## Connections

- Library consumer → Language utilities: uses
- Library consumer → Collections: uses
- Library consumer → Specifications: uses
- Library consumer → JSON schemas: uses
- Library consumer → Command handlers: uses
- Library consumer → Events: uses
- Library consumer → Observable models: uses
- Library consumer → HTTP gateway: uses
- Library consumer → REST providers: uses
- Library consumer → Scheduler: uses
- Mapped dispatch → Command handlers: dispatches to
- Composite dispatch → Command handlers: invokes
- Named events → Events: creates and fires
- Observable models → Events: fires commits
- REST parsing → JSON schemas: uses schema
- JSON data types → Date and time values: revives values
- JSON data types → Numeric and currency values: revives values
- Date and time values → Collections: uses comparator
