# martinandert/inflected architecture

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

- Interactive diagram: https://gitdiagram.com/martinandert/inflected
- Repository: https://github.com/martinandert/inflected

## Overview

##### Project type and purpose
- This is an open-source utility library (a port of Rails/ActiveSupport’s Inflector) for Node.js and the browser.
- It provides a suite of string-inflection functions (pluralize, singularize, camelize, underscore, etc.) and customization points (Inflector.inflections).

##### File structure
- Top level: configuration files (.eslintrc, .babelrc, rollup.config.js, .travis.yml, Makefile), package.json, README.
- src/ directory: individual modules—Inflector.js, Transliterator.js, applyInflections.js and one file per inflection function (pluralize.js, singularize.js, camelize.js, etc.).
- src/util: helper functions (isFunction.js).
- test/ directory: test/cases.js and test/index.js driving the test suite.

##### README for additional insights
- Confirms the API exported by index.js, build targets (CommonJS, ES module, UMD), zero‐dependency claim, and how to add custom inflection rules.
- Explains usage in Node.js and UMD in the browser.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Source Modules Layer
    subgraph "Source Modules" 
        direction TB
        Inflector["Inflector class"]:::source
        TransliteratorCore["Transliterator core"]:::source
        TransliterationRules["transliterations.js"]:::source
        ApplyInflections["applyInflections engine"]:::source
        InflectionsRegistry["Inflections registry API"]:::source
        subgraph "Inflection Functions"
            direction TB
            Camelize["camelize.js"]:::source
            Capitalize["capitalize.js"]:::source
            Classify["classify.js"]:::source
            Constantify["constantify.js"]:::source
            Dasherize["dasherize.js"]:::source
            Defaults["defaults.js"]:::source
            ForeignKey["foreignKey.js"]:::source
            Humanize["humanize.js"]:::source
            Ordinal["ordinal.js"]:::source
            Ordinalize["ordinalize.js"]:::source
            Parameterize["parameterize.js"]:::source
            Pluralize["pluralize.js"]:::source
            Singularize["singularize.js"]:::source
            Tableize["tableize.js"]:::source
            Titleize["titleize.js"]:::source
            TransliterateFunc["transliterate.js"]:::source
            Underscore["underscore.js"]:::source
        end
        Util["isFunction.js"]:::source
        Index["index.js (Entry Point)"]:::source
    end

    %% Build & Test Layer
    subgraph "Build & Test Pipeline"
        direction TB
        Babel["Babel (.babelrc)"]:::pipeline
        Rollup["Rollup bundler"]:::pipeline
        subgraph "Tests"
            direction TB
            TestIndex["test/index.js"]:::pipeline
            TestCases["test/cases.js"]:::pipeline
        end
        CI["Travis CI (.travis.yml) & Makefile"]:::pipeline
    end

    %% Distribution Artifacts
    subgraph "Distribution Artifacts"
        direction TB
        DistCJS["CommonJS bundle"]:::dist
        DistESM["ES Module bundle"]:::dist
        DistUMD["UMD bundle"]:::dist
    end

    %% Consumers
    subgraph "Consumers"
        direction TB
        NodeConsumer["Node.js App"]:::external
        BrowserConsumer["Browser (Global)"]:::external
    end

    %% Relationships
    TransliteratorCore -->|"uses rules"| TransliterationRules
    Inflector -->|"delegates to"| ApplyInflections
    Inflector -->|"uses transliterator"| TransliteratorCore
    Inflector -->|"exposes"| InflectionsRegistry
    ApplyInflections -->|"calls functions"| Camelize
    ApplyInflections -->|"calls functions"| Capitalize
    ApplyInflections -->|"calls functions"| Classify
    ApplyInflections -->|"calls functions"| Constantify
    ApplyInflections -->|"calls functions"| Dasherize
    ApplyInflections -->|"calls functions"| Defaults
    ApplyInflections -->|"calls functions"| ForeignKey
    ApplyInflections -->|"calls functions"| Humanize
    ApplyInflections -->|"calls functions"| Ordinal
    ApplyInflections -->|"calls functions"| Ordinalize
    ApplyInflections -->|"calls functions"| Parameterize
    ApplyInflections -->|"calls functions"| Pluralize
    ApplyInflections -->|"calls functions"| Singularize
    ApplyInflections -->|"calls functions"| Tableize
    ApplyInflections -->|"calls functions"| Titleize
    ApplyInflections -->|"calls functions"| TransliterateFunc
    ApplyInflections -->|"calls functions"| Underscore
    Util --> Inflector
    Util --> ApplyInflections
    Util --> TransliteratorCore

    Index -->|"imports all modules"| Inflector
    Index --> TransliteratorCore
    Index --> TransliterationRules
    Index --> ApplyInflections
    Index --> InflectionsRegistry
    Index --> Camelize
    Index --> Capitalize
    Index --> Classify
    Index --> Constantify
    Index --> Dasherize
    Index --> Defaults
    Index --> ForeignKey
    Index --> Humanize
    Index --> Ordinal
    Index --> Ordinalize
    Index --> Parameterize
    Index --> Pluralize
    Index --> Singularize
    Index --> Tableize
    Index --> Titleize
    Index --> TransliterateFunc
    Index --> Underscore

    Index -->|"entry to build"| Rollup
    Babel --> Rollup
    Rollup --> DistCJS
    Rollup --> DistESM
    Rollup --> DistUMD

    TestIndex -->|"tests modules"| Inflector
    TestIndex --> TestCases
    TestCases --> AppliedTests["runs against modules"]:::pipeline
    AppliedTests --> Inflector

    CI -->|"runs"| TestIndex
    CI -->|"runs build"| Rollup

    DistCJS -->|"consumed by"| NodeConsumer
    DistESM --> NodeConsumer
    DistUMD -->|"script tag"| BrowserConsumer

    %% Click Events
    click Inflector "https://github.com/martinandert/inflected/blob/master/src/Inflector.js"
    click TransliteratorCore "https://github.com/martinandert/inflected/blob/master/src/Transliterator.js"
    click TransliterationRules "https://github.com/martinandert/inflected/blob/master/src/transliterations.js"
    click ApplyInflections "https://github.com/martinandert/inflected/blob/master/src/applyInflections.js"
    click InflectionsRegistry "https://github.com/martinandert/inflected/blob/master/src/inflections.js"
    click Camelize "https://github.com/martinandert/inflected/blob/master/src/camelize.js"
    click Capitalize "https://github.com/martinandert/inflected/blob/master/src/capitalize.js"
    click Classify "https://github.com/martinandert/inflected/blob/master/src/classify.js"
    click Constantify "https://github.com/martinandert/inflected/blob/master/src/constantify.js"
    click Dasherize "https://github.com/martinandert/inflected/blob/master/src/dasherize.js"
    click Defaults "https://github.com/martinandert/inflected/blob/master/src/defaults.js"
    click ForeignKey "https://github.com/martinandert/inflected/blob/master/src/foreignKey.js"
    click Humanize "https://github.com/martinandert/inflected/blob/master/src/humanize.js"
    click Ordinal "https://github.com/martinandert/inflected/blob/master/src/ordinal.js"
    click Ordinalize "https://github.com/martinandert/inflected/blob/master/src/ordinalize.js"
    click Parameterize "https://github.com/martinandert/inflected/blob/master/src/parameterize.js"
    click Pluralize "https://github.com/martinandert/inflected/blob/master/src/pluralize.js"
    click Singularize "https://github.com/martinandert/inflected/blob/master/src/singularize.js"
    click Tableize "https://github.com/martinandert/inflected/blob/master/src/tableize.js"
    click Titleize "https://github.com/martinandert/inflected/blob/master/src/titleize.js"
    click TransliterateFunc "https://github.com/martinandert/inflected/blob/master/src/transliterate.js"
    click Underscore "https://github.com/martinandert/inflected/blob/master/src/underscore.js"
    click Util "https://github.com/martinandert/inflected/blob/master/src/util/isFunction.js"
    click Index "https://github.com/martinandert/inflected/blob/master/src/index.js"
    click Babel "https://github.com/martinandert/inflected/blob/master/src/.babelrc"
    click Rollup "https://github.com/martinandert/inflected/blob/master/rollup.config.js"
    click TestIndex "https://github.com/martinandert/inflected/blob/master/test/index.js"
    click TestCases "https://github.com/martinandert/inflected/blob/master/test/cases.js"
    click CI "https://github.com/martinandert/inflected/blob/master/.travis.yml"
    click CI "https://github.com/martinandert/inflected/tree/master/Makefile"

    %% Styles
    classDef source fill:#DCEFFF,stroke:#0366D6,color:#0366D6;
    classDef pipeline fill:#FFF5C4,stroke:#DAA520,color:#A67C00;
    classDef dist fill:#DFFFE0,stroke:#228B22,color:#006400;
    classDef external fill:#F0F0F0,stroke:#888888,color:#555555;
```
