# seanl01/autodiff-ts architecture

> Architecture diagram of the GitHub repository seanl01/autodiff-ts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/seanl01/autodiff-ts
- Repository: https://github.com/seanl01/autodiff-ts

## Overview

##### Project type and purpose
- This is a TypeScript library (no “frontend” or “backend” sub-dirs) whose sole purpose is to provide automatic differentiation capabilities for mathematical expressions.
- The README confirms that “autodiff-ts” exposes functions to compute gradients via forward- or reverse-mode differentiation.

##### File structure
- Top level files:
- index.ts – the library’s public API entry point
- types.ts – core type definitions (e.g. DualNumber, Node, Graph)
- main.test.ts – test suite exercising the API
- tsconfig.json, package.json, bun.lock, package-lock.json – build and dependency configurations
- No subdirectories implies a single-module library. The key code lives in index.ts (importing types.ts and any helper modules).

##### Detail
- Call out the type-level API (types.ts) separately from executable logic (index.ts)
- Both forward and reverse differentiation paths

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Interfaces
    Consumer["External Consumer"]:::external
    TestSuite["Test Suite\n(main.test.ts)"]:::external

    %% Public API Layer
    PublicAPI["Public API\n(index.ts)"]:::code

    %% Core Components
    subgraph "Core Components"
        TypeDefs["Type Definitions\n(types.ts)"]:::data
        subgraph "Differentiation Engine"
            ForwardMode["Forward Mode"]:::code
            ReverseMode["Reverse Mode"]:::code
        end
    end

    %% Build & Configuration
    subgraph "Build & Config"
        TSConfig["tsconfig.json"]:::config
        PackageJson["package.json"]:::config
        BunLock["bun.lock"]:::config
        PackageLock["package-lock.json"]:::config
    end

    %% Data Flow
    Consumer -->|"uses API"| PublicAPI
    TestSuite -->|"tests API"| PublicAPI

    PublicAPI -->|"reads types"| TypeDefs
    PublicAPI -->|"executes forward"| ForwardMode
    PublicAPI -->|"executes reverse"| ReverseMode

    ForwardMode -->|"updates graph"| TypeDefs
    ReverseMode -->|"updates graph"| TypeDefs

    %% Click Events
    click PublicAPI "https://github.com/seanl01/autodiff-ts/blob/main/index.ts"
    click TypeDefs "https://github.com/seanl01/autodiff-ts/blob/main/types.ts"
    click ForwardMode "https://github.com/seanl01/autodiff-ts/blob/main/index.ts"
    click ReverseMode "https://github.com/seanl01/autodiff-ts/blob/main/index.ts"
    click TestSuite "https://github.com/seanl01/autodiff-ts/blob/main/main.test.ts"
    click TSConfig "https://github.com/seanl01/autodiff-ts/blob/main/tsconfig.json"
    click PackageJson "https://github.com/seanl01/autodiff-ts/blob/main/package.json"
    click BunLock "https://github.com/seanl01/autodiff-ts/blob/main/bun.lock"
    click PackageLock "https://github.com/seanl01/autodiff-ts/blob/main/package-lock.json"

    %% Styles
    classDef code fill:#AED6F1,stroke:#2E86C1,stroke-width:1px;
    classDef data fill:#A9DFBF,stroke:#229954,stroke-width:1px;
    classDef config fill:#D7DBDD,stroke:#7B7D7D,stroke-width:1px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:1px;
```
