# revdotcom/revai-node-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/revdotcom/revai-node-sdk
- Repository: https://github.com/revdotcom/revai-node-sdk

## Overview

##### Project Type and Purpose
- Type: Open-source Node.js SDK wrapping the Rev AI REST and streaming APIs.
- Purpose: Provide developers with a set of client classes to submit audio/video for transcription, translation, summarization, sentiment/topic analysis, language identification, streaming transcription, and custom-vocabulary management.

##### File Structure
- src/
– api-client.ts, custom-vocabularies-client.ts, language-id-client.ts, sentiment-analysis-client.ts, streaming-client.ts, topic-extraction-client.ts
– base-api-client.ts (abstract base for REST clients)
– api-request-handler.ts (HTTP transport via axios)
- examples/ (sample usage code showing integration points)
- test/unit (Jest unit tests with mocks) & test/integration (live API tests)
- build scripts (TypeScript → JavaScript), configuration (tsconfig.json, jest configs), CI/CD (GitHub workflows, Jenkinsfile), Dockerfile.

##### Extract Key Insights from the README
- The SDK exposes three main clients:
– RevAiApiClient (asynchronous REST API)
– RevAiStreamingClient (WebSocket streaming API)
– RevAiCustomVocabulariesClient (custom vocabulary REST API)
- Features covered: job submission, status polling, transcript retrieval (text, JSON, captions), summaries, translations, streaming events, custom vocab lifecycle.

– **Developer/User**: Imports the SDK into their application
– **SDK Layer** (in your package)
- **Client Classes** (public API)
– RevAiApiClient
– RevAiStreamingClient
– RevAiCustomVocabulariesClient
- **Core Transport**
– ApiRequestHandler (HTTP via axios)
– WebSocket handler (built into streaming-client.ts)
- **BaseApiClient** (common logic: auth headers, endpoint URLs)
– **Build & Packaging**
- TypeScript compiler → dist/
- npm packaging
– **Tests**
- Unit tests (mocks)
- Integration tests (real API)
– **Examples**: reference implementations showing usage patterns

– Developer → imports Client Classes
– Client Classes → call BaseApiClient → uses ApiRequestHandler to send HTTP requests to Rev AI REST endpoints
– RevAiStreamingClient → opens WebSocket connection to Rev AI streaming endpoint
– ApiRequestHandler ↔ axios / HTTP transport
– Model Layer ↔ Client Classes (serialization/deserialization)
– Build & Packaging → produces SDK consumed by Developer and Examples
– Tests → invoke Client Classes via mocks or live API

c. Architectural Patterns & Principles
– Layered architecture: Public API → Core logic → Transport → External services
– Separation of concerns: each analysis feature has its own client and model sub-package
– Extensibility: new features can add clients and models in the same pattern
– DRY via BaseApiClient and shared ApiRequestHandler

d. Key Technologies/Frameworks
– Node.js, TypeScript
– axios for HTTP
– WebSocket (native) for streaming
– Jest for testing
– npm for packaging
– GitHub Actions / Jenkins for CI/CD
– Docker (for containerized builds/tests)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer
    Developer["Developer / User"]:::external

    %% SDK Layer
    subgraph "SDK Layer"
        direction TB
        RevAiApiClient["RevAiApiClient"]:::codeModules
        RevAiStreamingClient["RevAiStreamingClient"]:::codeModules
        RevAiCustomVocabulariesClient["RevAiCustomVocabulariesClient"]:::codeModules
        BaseApiClient["BaseApiClient"]:::codeModules
        ApiRequestHandler["ApiRequestHandler"]:::codeModules
        ModelLayer["Model Layer (DTOs)"]:::codeModules
    end

    %% External Services
    subgraph "External Rev AI Services"
        direction TB
        RESTAPI["Rev AI REST API"]:::external
        StreamingAPI["Rev AI Streaming API"]:::external
    end

    %% Build & Packaging
    subgraph "Build & Packaging" 
        direction TB
        TSConfig["tsconfig.json"]:::build
        BuildScripts["Build Scripts"]:::build
        Dockerfile["Dockerfile"]:::build
        CICDPipelines["CI/CD Pipelines"]:::build
    end

    %% Examples
    Examples["Examples"]:::examples

    %% Tests
    subgraph "Tests"
        direction TB
        UnitTests["Unit Tests"]:::tests
        IntegrationTests["Integration Tests"]:::tests
    end

    %% Relationships
    Developer -->|"imports"| RevAiApiClient
    Developer -->|"imports"| RevAiStreamingClient
    Developer -->|"imports"| RevAiCustomVocabulariesClient

    RevAiApiClient -->|"extends / uses"| BaseApiClient
    RevAiStreamingClient -->|"uses WebSocket"| StreamingAPI
    RevAiCustomVocabulariesClient -->|"extends / uses"| BaseApiClient

    BaseApiClient -->|"calls"| ApiRequestHandler
    ApiRequestHandler -->|"HTTP requests"| RESTAPI

    RevAiApiClient -->|"serialize/deserialize"| ModelLayer
    RevAiStreamingClient -->|"serialize/deserialize"| ModelLayer
    RevAiCustomVocabulariesClient -->|"serialize/deserialize"| ModelLayer

    BuildScripts --> TSConfig
    BuildScripts --> Dockerfile
    CICDPipelines --> BuildScripts
    BuildScripts -->|"produce dist/ package"| Developer

    Examples -->|"demo usage of"| RevAiApiClient
    Examples -->|"demo usage of"| RevAiStreamingClient
    Examples -->|"demo usage of"| RevAiCustomVocabulariesClient

    UnitTests --> RevAiApiClient
    UnitTests --> RevAiStreamingClient
    UnitTests --> RevAiCustomVocabulariesClient
    UnitTests --> ApiRequestHandler

    IntegrationTests --> RESTAPI
    IntegrationTests --> RevAiApiClient
    IntegrationTests --> RevAiStreamingClient
    IntegrationTests --> RevAiCustomVocabulariesClient

    %% Click Events
    click RevAiApiClient "https://github.com/revdotcom/revai-node-sdk/blob/develop/src/api-client.ts"
    click RevAiStreamingClient "https://github.com/revdotcom/revai-node-sdk/blob/develop/src/streaming-client.ts"
    click RevAiCustomVocabulariesClient "https://github.com/revdotcom/revai-node-sdk/blob/develop/src/custom-vocabularies-client.ts"
    click BaseApiClient "https://github.com/revdotcom/revai-node-sdk/blob/develop/src/base-api-client.ts"
    click ApiRequestHandler "https://github.com/revdotcom/revai-node-sdk/blob/develop/src/api-request-handler.ts"
    click ModelLayer "https://github.com/revdotcom/revai-node-sdk/tree/develop/src/models/"
    click Examples "https://github.com/revdotcom/revai-node-sdk/tree/develop/examples/"
    click UnitTests "https://github.com/revdotcom/revai-node-sdk/tree/develop/test/unit/"
    click IntegrationTests "https://github.com/revdotcom/revai-node-sdk/tree/develop/test/integration/"
    click TSConfig "https://github.com/revdotcom/revai-node-sdk/blob/develop/tsconfig.json"
    click BuildScripts "https://github.com/revdotcom/revai-node-sdk/blob/develop/build_release_package_json.js"
    click Dockerfile "https://github.com/revdotcom/revai-node-sdk/tree/develop/Dockerfile"
    click CICDPipelines "https://github.com/revdotcom/revai-node-sdk/tree/develop/JenkinsFile"

    %% Styles
    classDef codeModules fill:#cce5ff,stroke:#0366d6,color:#000;
    classDef external fill:#d4edda,stroke:#28a745,color:#000;
    classDef tests fill:#fff3cd,stroke:#ffc107,color:#000;
    classDef examples fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef build fill:#e2e3ff,stroke:#6f42c1,color:#000;
```
