# open-draft/until architecture

> Architecture diagram of the GitHub repository open-draft/until, 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/open-draft/until
- Repository: https://github.com/open-draft/until

## Overview

##### Project type and purpose
- This is an **open-source JavaScript/TypeScript utility library** published to NPM (`@open-draft/until`).
- Purpose: provide a single `until()` function that wraps `Promise` calls with consistent error/data output.

##### File structure
- Top-level files:
- `package.json`, `pnpm-lock.yaml` (package manifest and lock)
- `.github/workflows/ci.yml` (CI pipeline)
- `jest.config.js` (test runner)
- `tsup.config.ts` (bundler config)
- `ossjs.release.config.js` (release automation)
- `src/` (source code) with:
– `index.ts` (entry point)
– `until.ts` (core implementation)
– `until.test.ts` (unit tests)
- No frontend/backend split—this is a library.

##### README for additional insights
- Describes the API (`until()`), usage examples (JS & TS), and rationale.

##### Main components and their interactions
a. **Source Code**
- `until.ts`: Core logic
- `index.ts`: Exports API
- `until.test.ts`: Unit tests for core logic
b. **Build & Test**
- **Tsup** (bundler) compiles TypeScript → JavaScript, generates type declarations
- **Jest** runs unit tests against source code
c. **CI/CD Pipeline**
- **GitHub Actions** (`ci.yml`):
1. Checkout code
2. Install dependencies
3. Run lint/type-check
4. Run tests (Jest)
5. Bundle (Tsup)
6. Publish to NPM (via `ossjs.release.config.js`)
d. **Consumers & Registry**
- **NPM Registry**: hosts published package
- **Library Consumers**: downstream applications import `@open-draft/until`

##### Architectural patterns and design principles
- Single-responsibility: one core module (`until`)
- Test-driven: unit tests live alongside implementation
- CI-driven release: automated build/test/publish
- Minimal external dependencies
- Clear separation: source, tests, build config, CI config

##### Putting it all together
- **Left side:** Developer commits code → GitHub repo.
- **Center top:** CI pipeline (checkout → install → lint/type-check → test → bundle → publish).
- **Center bottom:** Modules and tools:
┌───────────┐      ┌─────────┐
│ index.ts  ├─┬─▶  │ until.ts │
└───────────┘ │   └─────────┘
│         ▲
▼         │
┌─────────┐  │
│ tests   ├──┘
└─────────┘
- **Right side:** NPM registry → Consumers import library.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    Developer(["Developer"]):::actor
    Consumer(["Consumer"]):::actor

    %% CI Pipeline
    CI["GitHub Actions (ci.yml)"]:::ci
    click CI "https://github.com/open-draft/until/blob/main/.github/workflows/ci.yml"

    %% Source Code Modules
    subgraph "Source Code"
        index["index.ts"]:::source
        core["until.ts"]:::source
        tests["until.test.ts"]:::source
    end
    click index "https://github.com/open-draft/until/blob/main/src/index.ts"
    click core "https://github.com/open-draft/until/blob/main/src/until.ts"
    click tests "https://github.com/open-draft/until/blob/main/src/until.test.ts"

    %% Configuration & Docs
    subgraph "Configs & Docs"
        manifest["package.json"]:::config
        lock["pnpm-lock.yaml"]:::config
        tsconfig["tsconfig.json"]:::config
        readme["README.md"]:::config
    end
    click manifest "https://github.com/open-draft/until/blob/main/package.json"
    click lock "https://github.com/open-draft/until/blob/main/pnpm-lock.yaml"
    click tsconfig "https://github.com/open-draft/until/blob/main/tsconfig.json"
    click readme "https://github.com/open-draft/until/blob/main/README.md"

    %% Build & Test Tools
    tsupcfg["tsup.config.ts"]:::tool
    jestcfg["jest.config.js"]:::tool
    ossjs["ossjs.release.config.js"]:::tool
    jest["Jest"]:::tool
    tsup["Tsup"]:::tool

    click tsupcfg "https://github.com/open-draft/until/blob/main/tsup.config.ts"
    click jestcfg "https://github.com/open-draft/until/blob/main/jest.config.js"
    click ossjs "https://github.com/open-draft/until/blob/main/ossjs.release.config.js"

    %% Registry
    npmReg["NPM Registry"]:::registry

    %% Relationships
    Developer -->|commits to| CI
    CI -->|lint & type-check| tsconfig
    CI -->|run tests| jest
    jest -->|tests| tests
    tests -->|imports| core
    CI -->|bundle| tsup
    tsup -->|bundles| core
    tsup -->|bundles| index
    CI -->|publish via ossjs| npmReg
    npmReg -->|installs| Consumer

    %% Tools Config Connections
    tsup --> tsupcfg
    jest --> jestcfg
    CI --> ossjs

    %% Config feeds
    core -->|metadata| manifest
    core -->|lock dependencies| lock
    manifest -->|docs| readme

    %% Styles
    classDef actor fill:#dddddd,stroke:#888;
    classDef source fill:#cce5ff,stroke:#004085;
    classDef tool fill:#d4edda,stroke:#155724;
    classDef ci fill:#ffe5b4,stroke:#cc8400;
    classDef registry fill:#e2d1f9,stroke:#663399;
    classDef config fill:#f0f0f0,stroke:#888;
```
