# microsoft/kiota-typescript architecture

> Architecture diagram of the GitHub repository microsoft/kiota-typescript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/kiota-typescript
- Repository: https://github.com/microsoft/kiota-typescript

## Overview

##### Main Components

a. Core Layer (Abstractions Package):
- Authentication Providers
- Serialization Core
- Request/Response Handling
- Store Management
- Base Client Infrastructure

b. HTTP Implementation Layer:
- Fetch Implementation
- Middleware Pipeline
- Request Adapters

c. Serialization Implementations:
- JSON Serialization
- Form Serialization
- Multipart Serialization
- Text Serialization

d. Authentication Implementations:
- Azure Authentication
- SharePoint Framework (SPFx) Authentication

##### Relationships and Flow

**┌─────────────────────────────────────────────────────────┐**
- Client Applications                   │
- ┬─────────────────────────┘
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Bundle Package                       │
- ┬─────────────────────────┘
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Core Abstractions Layer                   │
- ┬─────────────┬────────────────┬───────────┤
- Authentication│Serialization│Request Handling│  Store    │
- Interface   │  Interface  │   Interface    │Interface  │
- ┴─────────────┴────────────────┴───────────┘
- ▲              ▲              ▲            ▲

**┌───────┴──────┐ ┌────┴─────┐ ┌──────┴───────┐ ┌─┴────────┐**
- Authentication│ │Serializer │ │HTTP Client   │ │Store     │
- Implementations│ │Implementations│Implementations│Implementations│
- ┘ └──────────┘ └──────────────┘ └──────────┘

##### Important Elements to Highlight

a. Middleware Pipeline:
**Request → [Middleware Chain] → HTTP Client → Response**
- Chaos Handler
- Compression Handler
- Retry Handler
- Telemetry Handler
- User Agent Handler

b. Serialization Support:
- JSON
- Form
- Multipart
- Text

##### Implementation Details

Technical aspects:
- TypeScript implementation
- Browser and Node.js support
- Middleware pattern
- Plugin architecture for authentication
- Extensible serialization system

##### Integration Points
- External service connections
- Authentication providers
- HTTP endpoints
- Client application integration points

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client ["Client Applications"]
        App[Client App]
    end

    subgraph Bundle ["Bundle Package"]
        DefaultImpl["Default Implementation"]:::bundle
    end

    subgraph Core ["Core Abstractions Layer"]
        Auth["Authentication Interface"]:::core
        Serial["Serialization Interface"]:::core
        ReqRes["Request/Response Interface"]:::core
        Store["Store Management"]:::core
    end

    subgraph HTTP ["HTTP Implementation Layer"]
        FetchImpl["Fetch Implementation"]:::http
        subgraph Middleware ["Middleware Pipeline"]
            direction TB
            Chaos["Chaos Handler"]:::middleware
            Compress["Compression Handler"]:::middleware
            Retry["Retry Handler"]:::middleware
            Telemetry["Telemetry Handler"]:::middleware
            UserAgent["User Agent Handler"]:::middleware
        end
    end

    subgraph SerialImpl ["Serialization Implementations"]
        direction TB
        JSON["JSON Serialization"]:::serialization
        Form["Form Serialization"]:::serialization
        Multipart["Multipart Serialization"]:::serialization
        Text["Text Serialization"]:::serialization
    end

    subgraph AuthImpl ["Authentication Implementations"]
        direction TB
        Azure["Azure Authentication"]:::authentication
        SPFx["SPFx Authentication"]:::authentication
    end

    %% Relationships
    App --> DefaultImpl
    DefaultImpl --> Core
    Core --> HTTP
    Core --> SerialImpl
    Core --> AuthImpl
    FetchImpl --> Middleware

    %% Click Events
    click Auth "https://github.com/microsoft/kiota-typescript/tree/main/packages/abstractions/src/authentication/"
    click Serial "https://github.com/microsoft/kiota-typescript/tree/main/packages/abstractions/src/serialization/"
    click ReqRes "https://github.com/microsoft/kiota-typescript/blob/main/packages/abstractions/src/requestAdapter.ts"
    click Store "https://github.com/microsoft/kiota-typescript/tree/main/packages/abstractions/src/store/"
    click FetchImpl "https://github.com/microsoft/kiota-typescript/blob/main/packages/http/fetch/src/fetchRequestAdapter.ts"
    click Middleware "https://github.com/microsoft/kiota-typescript/tree/main/packages/http/fetch/src/middlewares/"
    click JSON "https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/json/"
    click Form "https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/form/"
    click Multipart "https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/multipart/"
    click Text "https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/text/"
    click Azure "https://github.com/microsoft/kiota-typescript/tree/main/packages/authentication/azure/"
    click SPFx "https://github.com/microsoft/kiota-typescript/tree/main/packages/authentication/spfx/"
    click Chaos "https://github.com/microsoft/kiota-typescript/blob/main/packages/http/fetch/src/middlewares/chaosHandler.ts"
    click Compress "https://github.com/microsoft/kiota-typescript/blob/main/packages/http/fetch/src/middlewares/compressionHandler.ts"
    click Retry "https://github.com/microsoft/kiota-typescript/blob/main/packages/http/fetch/src/middlewares/retryHandler.ts"
    click Telemetry "https://github.com/microsoft/kiota-typescript/blob/main/packages/http/fetch/src/middlewares/telemetryHandler.ts"
    click UserAgent "https://github.com/microsoft/kiota-typescript/blob/main/packages/http/fetch/src/middlewares/userAgentHandler.ts"
    click DefaultImpl "https://github.com/microsoft/kiota-typescript/blob/main/packages/bundle/src/defaultRequestAdapter.ts"
    click Bundle "https://github.com/microsoft/kiota-typescript/tree/main/packages/bundle/"

    %% Styling
    classDef core fill:#2374ab
    classDef http fill:#48a9a6
    classDef middleware fill:#4ea5d9
    classDef serialization fill:#9149d9
    classDef authentication fill:#d98c49
    classDef bundle fill:#d94949

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        HTTPLegend["HTTP Components"]:::http
        MiddlewareLegend["Middleware Components"]:::middleware
        SerialLegend["Serialization Components"]:::serialization
        AuthLegend["Authentication Components"]:::authentication
        BundleLegend["Bundle Components"]:::bundle
    end
```
