# reactive-extensions/rxjs architecture

> Architecture diagram of the GitHub repository reactive-extensions/rxjs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/reactive-extensions/rxjs
- Repository: https://github.com/reactive-extensions/rxjs

## Overview

##### Project type and purpose
- RxJS is an open-source JavaScript library (version 4.0) for composing asynchronous and event-based programs via Observables, Operators, and Schedulers.
- It provides a “batteries-included” reactive programming toolkit that can run in browser environments (with AMD, global script tags) and in Node.js, and publishes builds via npm, Bower, NuGet, etc.

##### File structure
- Top-level directories and files:
- src/ – the hand-written source modules, organized by core, concurrency, disposables, internal, joins, linq, subjects, testing, etc.
- ts/ – TypeScript definitions and TS source mirroring src/
- lib/ – generated ES5 “legacy” modules
- modules/ – per-feature packaged modules (for smaller, modular builds)
- dist/ – concatenated bundles (rx.all.js, rx.lite.js, operator-specific bundles) ready for distribution
- examples/, tests/, doc/ – sample apps, test suites, API documentation, getting-started guides, design guidelines
- Gruntfile.js, package.json, webpack.config.js – build and packaging scripts
- nuget/, bower.json, component.json – publishing metadata for different ecosystems

- Patterns indicating architecture:
- Modular design – each feature (e.g., async, time, binding) lives in its own module folder under src/ and modules/
- Build pipeline – source → transpile/concatenate (Grunt + Webpack) → ES5 modules (lib/) → bundles (dist/) → package manifests → publish
- Testing harness – tests/ for core JS, modular/test for modules, with both HTML/browser and NodeJS runners

##### README for additional insights
- Describes the Rx paradigm: Observables + Operators + Schedulers
- Highlights how to consume builds (rx.js, rx.lite.js, rx.all.js, or individual operator bundles) in different environments (script tag, AMD, require.js, Node.js, Bower, NuGet)
- References example workflows (DOM events, AJAX, Promises, WebSockets)

a. Main components to represent:
- Source Modules (src/ and ts/) organized by feature (core, backpressure, concurrency, disposables, linQ, joins, subjects, testing)
- Build Tools (Grunt, Webpack, TypeScript compiler)
- Generated Outputs:
- Lib folder (ES5 modules)
- Dist folder (bundled JS files)
- Modules folder (per-feature exports for AMD/Webpack consumption)
- Packaging & Publishing: npm registry, Bower, NuGet, GitHub releases
- Consumers: Browser runtime (global & AMD), Node.js, TypeScript projects

b. Relationships and data flows:
- Developers → edit source in src/ or ts/ → Build Tools
- Build Tools → transpile/compile TS → produce lib/ and modules/ → bundle → dist/
- Test Runner → picks source or bundles → runs tests in Node/browser → reports results
- Documentation generator (doc/) → consumes README and API markdown → publishes docs site
- Package manifests (package.json, bower.json, nuspec) link bundles to registries
- End users → install via npm/Bower/NuGet → import modules or load bundles in runtime → subscribe to Observables

c. Architectural patterns and principles:
- Modular Layering: each feature is self-contained, enabling tree-shaking or custom builds
- Build-time code generation: TypeScript definitions, CommonJS, UMD and AMD wrapper generation
- Test-driven development: comprehensive unit tests for every operator and scheduler
- Documentation-first: markdown docs co-located with modules, API docs generated per module

d. Technologies and frameworks:
- JavaScript (ES5, ES6 modules via Webpack)
- TypeScript for type definitions (d.ts)
- Grunt for build orchestration
- Webpack for modular bundling
- Mocha/Jasmine (in examples/testing) for unit tests
- Markdown → static site doc generation (GitHub Pages)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Source Modules"
        SRC["src/ (core, concurrency, linq, subjects, testing)"]:::source
        TS["ts/ (type defs & mirror)"]:::source
    end

    subgraph "Build Tools"
        GRUNT["Gruntfile.js"]:::build
        WEBPACK_ROOT["webpack.config.js"]:::build
        WEBPACK_MOD["src/modular/webpack.config.js"]:::build
        WEBPACK_PROD["src/modular/webpack.config.production.js"]:::build
        TS_CONFIG["ts/tsconfig.json"]:::build
    end

    subgraph "Generated Outputs"
        LIB["lib/ (ES5 modules)"]:::output
        MOD["modules/ (per-feature modules)"]:::output
        DIST["dist/ (bundled JS)"]:::output
    end

    subgraph "Testing"
        TEST_CORE["tests/ (core, observable, concurrency, subjects, perf)"]:::test
        MOD_TEST["src/modular/test/ (buffer.js, scheduler.js)"]:::test
    end

    subgraph "Documentation"
        DOCS["doc/ (api, guides, design)"]:::docs
    end

    subgraph "Examples"
        EX["examples/ (autocomplete, backpressure, requirejs, testing/jasmine)"]:::examples
    end

    subgraph "Publishing"
        PKG["package.json, bower.json, component.json"]:::publish
        NUGET["nuget/ (RxJS-All.nuspec, RxJS-Async.nuspec)"]:::publish
    end

    subgraph "Consumers"
        BROWSER["Browser (Global & AMD)"]:::consumer
        NODE["Node.js (CommonJS)"]:::consumer
        TS_CONS["TypeScript Projects (ES6 imports)"]:::consumer
    end

    SRC -->|edit source| GRUNT
    TS -->|edit definitions| GRUNT
    GRUNT -->|"compile/transpile"| LIB
    GRUNT -->|"package modules"| MOD
    GRUNT -->|"bundle UMD/AMD"| DIST
    WEBPACK_ROOT -->|"bundle config"| DIST
    WEBPACK_MOD -->|"modular bundle"| DIST
    TS_CONFIG -->|"ts compile"| LIB
    TS_CONFIG -->|"ts compile"| MOD

    LIB -->|package artifacts| PKG
    MOD -->|package artifacts| PKG
    DIST -->|bundle artifacts| PKG
    PKG -->|publish metadata| NUGET

    LIB -->|source for tests| TEST_CORE
    DIST -->|bundle for tests| TEST_CORE
    MOD -->|modular tests| MOD_TEST

    SRC -->|"generate docs"| DOCS
    DOCS -->|publish site| NUGET

    EX -->|"demo usage"| BROWSER

    DIST -->|"load bundle"| BROWSER
    MOD -->|"import module"| BROWSER
    LIB -->|"require module"| NODE
    MOD -->|"ES6 import"| TS_CONS

    click SRC "https://github.com/reactive-extensions/rxjs/tree/master/src/"
    click TS "https://github.com/reactive-extensions/rxjs/tree/master/ts/"
    click GRUNT "https://github.com/reactive-extensions/rxjs/blob/master/Gruntfile.js"
    click WEBPACK_ROOT "https://github.com/reactive-extensions/rxjs/blob/master/webpack.config.js"
    click WEBPACK_MOD "https://github.com/reactive-extensions/rxjs/blob/master/src/modular/webpack.config.js"
    click WEBPACK_PROD "https://github.com/reactive-extensions/rxjs/blob/master/src/modular/webpack.config.production.js"
    click TS_CONFIG "https://github.com/reactive-extensions/rxjs/blob/master/ts/tsconfig.json"
    click LIB "https://github.com/reactive-extensions/rxjs/tree/master/lib/"
    click MOD "https://github.com/reactive-extensions/rxjs/tree/master/modules/"
    click DIST "https://github.com/reactive-extensions/rxjs/tree/master/dist/"
    click TEST_CORE "https://github.com/reactive-extensions/rxjs/tree/master/tests/"
    click MOD_TEST "https://github.com/reactive-extensions/rxjs/tree/master/src/modular/test/"
    click DOCS "https://github.com/reactive-extensions/rxjs/tree/master/doc/"
    click EX "https://github.com/reactive-extensions/rxjs/tree/master/examples/"
    click PKG "https://github.com/reactive-extensions/rxjs/blob/master/package.json"
    click NUGET "https://github.com/reactive-extensions/rxjs/tree/master/nuget/"

    classDef source fill:#D6EAF8,stroke:#3498DB,color:#1B4F72
    classDef build fill:#FAE5D3,stroke:#EB984E,color:#873600
    classDef output fill:#D5F5E3,stroke:#28B463,color:#186A3B
    classDef test fill:#FADBD8,stroke:#EC7063,color:#641E16
    classDef docs fill:#E8DAEF,stroke:#9B59B6,color:#4A235A
    classDef examples fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
    classDef publish fill:#F5EEF8,stroke:#BB8FCE,color:#4A235A
    classDef consumer fill:#EBF5FB,stroke:#5DADE2,color:#1B4F72
```
