# wit-ai/wit-go architecture

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

- Interactive diagram: https://gitdiagram.com/wit-ai/wit-go
- Repository: https://github.com/wit-ai/wit-go

## Overview

##### Project type and purpose
- This is an open-source Go client library (“SDK”) for the Wit.ai HTTP API. Its sole purpose is to allow Go programs to call Wit.ai endpoints, marshal request payloads, unmarshal JSON responses into strongly typed Go structs, and expose a clean Go-native interface.

##### File structure
- Top-level files/apps.go, dictation.go, entity.go, export.go, intent.go, language_detection.go, message.go, trait.go, utterance.go, witai.go each implement one area of the API.
- apps_test.go, dictation_test.go, etc. validate each module’s behavior.
- go.mod declares dependencies.
- testdata/ contains fixtures for integration tests.
- .github/workflows/test.yaml defines CI steps (unit & integration).

##### README for additional insights
- Usage snippet shows:
- Instantiating a witai.Client with a token
- Calling client.Parse (MessageRequest → MessageResponse)
- Integration tests require an environment variable token.
- The library is organized around distinct APIs: apps, message parsing, entity management, language detection, dictation, intent and trait extraction, export.

##### Elements
- From User Code to witai.Client
- From Client/Domain to HTTP Transport
- From HTTP Transport to Wit.ai API (and back)
- From CI pipeline to running tests (unit & integration)
- Internal library code (light blue)

##### Detailed capture of essential elements
- “Client” as the orchestrator that imports each domain package.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation / User Code"
        UC["User Code"]:::consumer
    end

    %% Client Layer
    subgraph "Client Layer"
        CL["witai.Client"]:::client
    end

    %% Domain Model
    subgraph "Domain Model"
        subgraph "Domain Packages"
            Apps["Apps API"]:::domain
            Message["Message Parsing API"]:::domain
            Entity["Entity Management API"]:::domain
            Intent["Intent Extraction API"]:::domain
            Trait["Trait Extraction API"]:::domain
            Utterance["Utterance API"]:::domain
            Export["Export API"]:::domain
            Language["Language Detection API"]:::domain
            Dictation["Dictation API"]:::domain
        end
    end

    %% Infrastructure
    subgraph "Infrastructure / Configuration"
        HT["HTTP Transport"]:::infra
        Mod["go.mod"]:::infra
    end

    %% External Services
    subgraph "External Services"
        Wit["Wit.ai HTTP API"]:::external
    end

    %% Continuous Integration
    subgraph "Continuous Integration"
        CI["GitHub Actions CI"]:::ci
        UT["Unit Tests"]:::ci
        IT["Integration Tests"]:::ci
    end

    %% Connections
    UC -->|"instantiates"| CL
    CL -->|"calls endpoint wrappers"| Apps
    CL -->|"calls endpoint wrappers"| Message
    CL -->|"calls endpoint wrappers"| Entity
    CL -->|"calls endpoint wrappers"| Intent
    CL -->|"calls endpoint wrappers"| Trait
    CL -->|"calls endpoint wrappers"| Utterance
    CL -->|"calls endpoint wrappers"| Export
    CL -->|"calls endpoint wrappers"| Language
    CL -->|"calls endpoint wrappers"| Dictation

    Apps -->|"uses"| HT
    Message -->|"uses"| HT
    Entity -->|"uses"| HT
    Intent -->|"uses"| HT
    Trait -->|"uses"| HT
    Utterance -->|"uses"| HT
    Export -->|"uses"| HT
    Language -->|"uses"| HT
    Dictation -->|"uses"| HT

    HT -->|"sends JSON over HTTP"| Wit
    Wit -->|"returns JSON response"| HT

    UC -.->|"override HTTPClient"| HT

    CI --> UT
    CI --> IT
    UT --> CL
    UT --> Apps
    UT --> Message
    UT --> Entity
    UT --> Intent
    UT --> Trait
    UT --> Utterance
    UT --> Export
    UT --> Language
    UT --> Dictation
    IT --> HT
    IT --> Wit

    %% Click Events
    click CL "https://github.com/wit-ai/wit-go/blob/main/witai.go"
    click CL "https://github.com/wit-ai/wit-go/blob/main/witai_test.go"
    click Apps "https://github.com/wit-ai/wit-go/blob/main/apps.go"
    click Apps "https://github.com/wit-ai/wit-go/blob/main/apps_test.go"
    click Message "https://github.com/wit-ai/wit-go/blob/main/message.go"
    click Message "https://github.com/wit-ai/wit-go/blob/main/message_test.go"
    click Entity "https://github.com/wit-ai/wit-go/blob/main/entity.go"
    click Entity "https://github.com/wit-ai/wit-go/blob/main/entity_test.go"
    click Intent "https://github.com/wit-ai/wit-go/blob/main/intent.go"
    click Intent "https://github.com/wit-ai/wit-go/blob/main/intent_test.go"
    click Trait "https://github.com/wit-ai/wit-go/blob/main/trait.go"
    click Trait "https://github.com/wit-ai/wit-go/blob/main/trait_test.go"
    click Utterance "https://github.com/wit-ai/wit-go/blob/main/utterance.go"
    click Utterance "https://github.com/wit-ai/wit-go/blob/main/utterance_test.go"
    click Export "https://github.com/wit-ai/wit-go/blob/main/export.go"
    click Export "https://github.com/wit-ai/wit-go/blob/main/export_test.go"
    click Language "https://github.com/wit-ai/wit-go/blob/main/language_detection.go"
    click Language "https://github.com/wit-ai/wit-go/blob/main/language_detection_test.go"
    click Dictation "https://github.com/wit-ai/wit-go/blob/main/dictation.go"
    click Dictation "https://github.com/wit-ai/wit-go/blob/main/dictation_test.go"
    click Mod "https://github.com/wit-ai/wit-go/blob/main/go.mod"
    click IT "https://github.com/wit-ai/wit-go/blob/main/integration_test.go"
    click IT "https://github.com/wit-ai/wit-go/tree/main/testdata/"
    click CI "https://github.com/wit-ai/wit-go/blob/main/.github/workflows/test.yaml"

    %% Styles
    classDef consumer fill:#ccffcc,stroke:#006600,color:#006600
    classDef client fill:#cce5ff,stroke:#004080,color:#004080
    classDef domain fill:#e6f2ff,stroke:#3385ff,color:#004080
    classDef infra fill:#fff2cc,stroke:#ffbb33,color:#805500
    classDef external fill:#f2dede,stroke:#d9534f,color:#a94442
    classDef ci fill:#ffe6cc,stroke:#ff8000,color:#994d00
```
