# langchain-ai/langsmith-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/langchain-ai/langsmith-sdk
- Repository: https://github.com/langchain-ai/langsmith-sdk

## Overview

##### Major Project Components
- Python SDK – This is located under the “python” directory. Note the “python/langsmith” package that contains core modules (e.g., anonymizer, evaluation, CLI, environment, wrappers) and the extensive tests and docs folders.
- JavaScript/TypeScript SDK – Found under the “js” directory. This module includes utilities (such as singletons and wrappers), evaluation logic, client integrations, and a comprehensive set of tests.
- Rust Components – Under the “rust” directory, you have crates such as “langsmith-pyo3” (which bridges Python with Rust using pyo3) and “langsmith-tracing-client” (which focuses on benchmarking and tracing client functionality).
- Auxiliary and Supporting Files – There are GitHub workflows, continuous integration actions, testing scripts, OpenAPI specification for API interactions, and documentation files (in markdown and ReadTheDocs configuration).

##### Relationships and Interactions
- Each SDK (Python, JS, and Rust) exposes client functionality that wraps native libraries (e.g., “wrap_openai” or “wrapOpenAI”) to incorporate LangSmith tracing and logging.
- In a typical usage scenario, an end-user application will import the SDK (from either Python or JS) and invoke the provided “traceable” methods. These methods decorate or wrap the language model APIs so that evaluation and logging data is sent to the LangSmith platform.
- The Rust crates serve as performance-critical components. For example, “langsmith-pyo3” provides Python bindings for tracing by leveraging Rust’s speed, while “langsmith-tracing-client” contains low-level functionality to process streaming and multipart data.
- Testing components are illustrated by various “tests” folders across languages, which validate the integration and performance of these SDKs.
- CI/CD pipelines orchestrated via GitHub Actions and workflows ensure that tests, linter checks, and builds for all three language components are properly executed.

##### Architectural Patterns and Design Principles
- Layered Architecture – Each language-specific SDK is separated from the “core” LangSmith platform communication logic.
- Wrapper/Decorator Pattern – Both Python and JS SDKs use wrappers (evident from “traceable” modules and “wrap_openai/wrapOpenAI”) to enhance native client requests with telemetry and debugging information.
- Modularity – The repository’s structure is modular, with a distinct separation between source code, tests, CI/CD configurations, and documentation. This helps in maintaining clear boundaries between components.
- Abstraction of Integration Points – The use of “evaluation”, “anonymizer”, and “wrappers” indicates a clear abstraction between capturing diagnostic information from language models and sending it to the LangSmith central service.

## Diagram (Mermaid)

```mermaid
graph TD
    Client["Client Application"]:::external
    API["LangSmith Platform API"]:::external

    subgraph "Python SDK"
        P_Core["Langsmith Package (Core Modules & Wrappers)"]:::python
        P_Tests["Tests"]:::python
        P_Docs["Documentation"]:::python
    end

    subgraph "JavaScript/TypeScript SDK"
        JS_Source["Source Modules (Wrappers & Evaluation)"]:::js
        JS_Tests["Tests"]:::js
        JS_Config["Configuration (package.json)"]:::js
    end

    subgraph "Rust Components"
        R_Pyo3["langsmith-pyo3 (pyo3 Bindings)"]:::rust
        R_Tracing["langsmith-tracing-client (Tracing & Benchmarking)"]:::rust
    end

    subgraph "CI/CD & Auxiliary Files"
        CI_CD["GitHub Workflows & Configurations"]:::cicd
    end

    %% Connections
    Client -->|"calls"| P_Core
    Client -->|"calls"| JS_Source

    P_Core -->|"bindings"| R_Pyo3
    P_Core -->|"logs_to"| API
    JS_Source -->|"logs_to"| API

    R_Pyo3 -->|"sends_trace_data"| API
    R_Tracing -->|"processes_tracing"| API

    CI_CD -->|"tests_builds"| P_Core
    CI_CD -->|"tests_builds"| JS_Source
    CI_CD -->|"tests_builds"| R_Tracing

    %% Click Events
    click P_Core "https://github.com/langchain-ai/langsmith-sdk/tree/main/python/langsmith"
    click P_Tests "https://github.com/langchain-ai/langsmith-sdk/tree/main/python/tests"
    click P_Docs "https://github.com/langchain-ai/langsmith-sdk/tree/main/python/docs"
    click JS_Source "https://github.com/langchain-ai/langsmith-sdk/tree/main/js/src"
    click JS_Tests "https://github.com/langchain-ai/langsmith-sdk/tree/main/js/src/tests"
    click JS_Config "https://github.com/langchain-ai/langsmith-sdk/blob/main/js/package.json"
    click R_Pyo3 "https://github.com/langchain-ai/langsmith-sdk/tree/main/rust/crates/langsmith-pyo3"
    click R_Tracing "https://github.com/langchain-ai/langsmith-sdk/tree/main/rust/crates/langsmith-tracing-client"
    click CI_CD "https://github.com/langchain-ai/langsmith-sdk/tree/main/.github/"

    %% Styles
    classDef python fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef js fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef rust fill:#FF6347,stroke:#333,stroke-width:2px;
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef cicd fill:#DA70D6,stroke:#333,stroke-width:2px;
```
