# whiplashscorpion/ari architecture

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

- Interactive diagram: https://gitdiagram.com/whiplashscorpion/ari
- Repository: https://github.com/whiplashscorpion/ari

## Overview

##### Project type and purpose
- It provides commands, event parsing, and a pluggable module system to build higher-level apps on top of Asterisk.

##### File structure
- Top-level Go files represent logical layers or components:
- config_objects.go – definitions for configuration structures (connection parameters, authentication).
- endpoints.go – networking details (how to open/maintain the AMI/TCP connection).
- command_structs.go / command_client.go – data models for commands and the client API to send commands.
- event_structs.go – data models for events returned by Asterisk.
- modules.go – plug-in hooks or module registration.
- applications.go, bridges.go, channels.go, playbacks.go – high-level abstractions for specific AMI subjects.
- logging.go – centralized logging facility.
- go.mod declares dependencies.
- No HTTP/server code or UI, so it’s a pure library/tool.

##### README (empty)
- No extra hints. Proceed from naming conventions and Go idioms.

- Major design patterns: “Plugin registration”, “Layered parsing → dispatch”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Configuration
    Config["Config Store"]:::config

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Endpoint["Endpoint Connector"]:::infra
        Logging["Logging Subsystem"]:::infra
    end

    %% Domain Layer
    subgraph "Domain Layer"
        CmdModel["Command API Data Models"]:::domain
        CmdClient["Command API Client"]:::domain
        EventProc["Event Processor"]:::domain
    end

    %% Extension Layer
    subgraph "Extension Layer"
        ModuleMgr["Module Manager"]:::extension
        AppMod["Applications Module"]:::extension
        BridgeMod["Bridges Module"]:::extension
        ChannelMod["Channels Module"]:::extension
        PlaybackMod["Playbacks Module"]:::extension
    end

    %% External Systems
    subgraph "External Systems"
        Asterisk["Asterisk AMI Server"]:::external
        ClientApp["Client Application"]:::external
    end

    %% Data Flows
    Config -->|load config| Endpoint
    Endpoint -->|"Authenticate / KeepAlive"| Asterisk
    Asterisk -->|"Event Stream"| Endpoint
    Endpoint -->|"EventReceived"| EventProc
    EventProc -->|"DispatchEvent"| ModuleMgr
    ModuleMgr -->|"Invoke Actions"| CmdClient
    CmdClient -->|"SendCommand"| Endpoint
    Endpoint -->|"Response"| CmdModel
    ClientApp -->|"Uses Library"| ModuleMgr

    %% Logging flows
    Endpoint -->|"log"| Logging
    CmdModel -->|"log"| Logging
    CmdClient -->|"log"| Logging
    EventProc -->|"log"| Logging
    ModuleMgr -->|"log"| Logging
    AppMod -->|"log"| Logging
    BridgeMod -->|"log"| Logging
    ChannelMod -->|"log"| Logging
    PlaybackMod -->|"log"| Logging

    %% Click events
    click Config "https://github.com/whiplashscorpion/ari/blob/main/config_objects.go"
    click Endpoint "https://github.com/whiplashscorpion/ari/blob/main/endpoints.go"
    click CmdModel "https://github.com/whiplashscorpion/ari/blob/main/command_structs.go"
    click CmdClient "https://github.com/whiplashscorpion/ari/blob/main/command_client.go"
    click EventProc "https://github.com/whiplashscorpion/ari/blob/main/event_structs.go"
    click ModuleMgr "https://github.com/whiplashscorpion/ari/blob/main/modules.go"
    click AppMod "https://github.com/whiplashscorpion/ari/blob/main/applications.go"
    click BridgeMod "https://github.com/whiplashscorpion/ari/blob/main/bridges.go"
    click ChannelMod "https://github.com/whiplashscorpion/ari/blob/main/channels.go"
    click PlaybackMod "https://github.com/whiplashscorpion/ari/blob/main/playbacks.go"
    click Logging "https://github.com/whiplashscorpion/ari/blob/main/logging.go"
    click Asterisk "https://github.com/whiplashscorpion/ari/blob/main/asterisk.go"

    %% Styles
    classDef infra fill:#D6E9FF,stroke:#4A90E2,stroke-width:1px
    classDef domain fill:#E8F5E9,stroke:#43A047,stroke-width:1px
    classDef extension fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#9E9E9E,stroke-width:1px
    classDef config fill:#F3E5F5,stroke:#8E24AA,stroke-width:1px
```
