# sbaker/imitto architecture

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

- Interactive diagram: https://gitdiagram.com/sbaker/imitto
- Repository: https://github.com/sbaker/imitto

## Overview

IMITTO is a .NET messaging library for asynchronous in-memory and distributed events over a binary protocol. A client connects, authenticates, registers topic mappings, and exchanges event notifications; consumers receive decoded packages. On the server, connections and event notifications are accepted and routed to subscriptions. Local events, topic matching, channels, and dependency-injection setup support these workflows. The graph reflects the sampled client/server and registration code plus README capabilities; some protocol internals and unsampled stages are represented only at subsystem level.

Main entry points: [`src/IMitto/Net/Clients/MittoClientEventManager.cs`](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Clients/MittoClientEventManager.cs) (Client event manager), [`src/IMitto/Net/Server/ServerEventManager.cs`](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Server/ServerEventManager.cs) (Server event manager), [`src/IMitto/Local/MittoLocalEvents.cs`](https://github.com/sbaker/imitto/blob/main/src/IMitto/Local/MittoLocalEvents.cs) (Local event hub), [`src/IMitto/Net/Clients/MittoClient.cs`](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Clients/MittoClient.cs) (Client host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client runtime"]
  node_client["Client host<br/>[MittoClient.cs]"]
  node_clientevents["Client event manager"]
  node_consumers["Package consumers"]
end

subgraph group_server["Server runtime"]
  node_server["Server request handler"]
  node_serverevents["Server event manager"]
  node_listener["Event listener"]
  node_connections["Connection context"]
end

subgraph group_messaging["Messaging core"]
  node_local["Local event hub"]
  node_subscriptions["Subscriptions<br/>[Subscription.cs]"]
  node_repository[("Subscription store")]
  node_topics["Topic parser<br/>[TopicParser.cs]"]
  node_channels["Async channels"]
  node_di["Service registration"]
end

subgraph group_transport["Protocol and transport"]
  node_protocol["Binary protocol<br/>[MittoTransport.cs]"]
  node_socket["Pipeline socket"]
  node_pipes["Duplex pipe<br/>[MittoDuplexPipe.cs]"]
end

node_app(("Application"))

node_app -->|"starts client"| node_client
node_client -->|"runs event loops"| node_clientevents
node_clientevents -->|"invokes consumers"| node_consumers
node_clientevents -->|"reads packages"| node_channels
node_clientevents -.->|"sends requests"| node_protocol
node_app -.->|"sends requests"| node_server
node_server -->|"writes events"| node_channels
node_serverevents -->|"reads connections"| node_channels
node_serverevents -->|"polls connections"| node_listener
node_listener -.->|"handles connection"| node_connections
node_serverevents -->|"publishes events"| node_local
node_local -.->|"invokes subscriptions"| node_subscriptions
node_subscriptions -.->|"uses storage"| node_repository
node_local -.->|"matches topics"| node_topics
node_di -->|"registers client"| node_client
node_di -->|"registers manager"| node_clientevents
node_socket -->|"uses pipe"| node_pipes
node_socket -.->|"transports packages"| node_protocol

click node_client "https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Clients/MittoClient.cs"
click node_clientevents "https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Clients/MittoClientEventManager.cs"
click node_consumers "https://github.com/sbaker/imitto/blob/main/src/IMitto/Consumers/IMittoPackageConsumer.cs"
click node_server "https://github.com/sbaker/imitto/blob/main/src/IMitto.Server/MittoServerRequestHandler.cs"
click node_serverevents "https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Server/ServerEventManager.cs"
click node_listener "https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/MittoEventListener.cs"
click node_connections "https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/ConnectionContext.cs"
click node_local "https://github.com/sbaker/imitto/blob/main/src/IMitto/Local/MittoLocalEvents.cs"
click node_subscriptions "https://github.com/sbaker/imitto/blob/main/src/IMitto/Subscription.cs"
click node_repository "https://github.com/sbaker/imitto/blob/main/src/IMitto/Storage/SubscriptionRepository.cs"
click node_topics "https://github.com/sbaker/imitto/blob/main/src/IMitto/Topics/TopicParser.cs"
click node_channels "https://github.com/sbaker/imitto/blob/main/src/IMitto/Channels/MittoBoundedChannelProvider.cs"
click node_di "https://github.com/sbaker/imitto/blob/main/src/IMitto.Extensions.DependencyInjection/Extensions/ServiceCollectionExtensions.Clients.cs"
click node_protocol "https://github.com/sbaker/imitto/blob/main/src/IMitto/Protocols/V1/MittoTransport.cs"
click node_socket "https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/MittoPipelineSocket.cs"
click node_pipes "https://github.com/sbaker/imitto/blob/main/src/IMitto/Pipelines/MittoDuplexPipe.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_clientevents,node_consumers toneBlue
class node_server,node_serverevents,node_listener,node_connections toneAmber
class node_local,node_subscriptions,node_repository,node_topics,node_channels,node_di toneMint
class node_protocol,node_socket,node_pipes toneRose
class node_app toneIndigo
```

## Components

### Client runtime

- [Client host](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Clients/MittoClient.cs): `src/IMitto/Net/Clients/MittoClient.cs`
- [Client event manager](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Clients/MittoClientEventManager.cs): `src/IMitto/Net/Clients/MittoClientEventManager.cs`
- [Package consumers](https://github.com/sbaker/imitto/blob/main/src/IMitto/Consumers/IMittoPackageConsumer.cs): `src/IMitto/Consumers/IMittoPackageConsumer.cs`

### Server runtime

- [Server request handler](https://github.com/sbaker/imitto/blob/main/src/IMitto.Server/MittoServerRequestHandler.cs): `src/IMitto.Server/MittoServerRequestHandler.cs`
- [Server event manager](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/Server/ServerEventManager.cs): `src/IMitto/Net/Server/ServerEventManager.cs`
- [Event listener](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/MittoEventListener.cs): `src/IMitto/Net/MittoEventListener.cs`
- [Connection context](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/ConnectionContext.cs): `src/IMitto/Net/ConnectionContext.cs`

### Messaging core

- [Local event hub](https://github.com/sbaker/imitto/blob/main/src/IMitto/Local/MittoLocalEvents.cs): `src/IMitto/Local/MittoLocalEvents.cs`
- [Subscriptions](https://github.com/sbaker/imitto/blob/main/src/IMitto/Subscription.cs): `src/IMitto/Subscription.cs`
- [Subscription store](https://github.com/sbaker/imitto/blob/main/src/IMitto/Storage/SubscriptionRepository.cs): `src/IMitto/Storage/SubscriptionRepository.cs`
- [Topic parser](https://github.com/sbaker/imitto/blob/main/src/IMitto/Topics/TopicParser.cs): `src/IMitto/Topics/TopicParser.cs`
- [Async channels](https://github.com/sbaker/imitto/blob/main/src/IMitto/Channels/MittoBoundedChannelProvider.cs): `src/IMitto/Channels/MittoBoundedChannelProvider.cs`
- [Service registration](https://github.com/sbaker/imitto/blob/main/src/IMitto.Extensions.DependencyInjection/Extensions/ServiceCollectionExtensions.Clients.cs): `src/IMitto.Extensions.DependencyInjection/Extensions/ServiceCollectionExtensions.Clients.cs`

### Protocol and transport

- [Binary protocol](https://github.com/sbaker/imitto/blob/main/src/IMitto/Protocols/V1/MittoTransport.cs): `src/IMitto/Protocols/V1/MittoTransport.cs`
- [Pipeline socket](https://github.com/sbaker/imitto/blob/main/src/IMitto/Net/MittoPipelineSocket.cs): `src/IMitto/Net/MittoPipelineSocket.cs`
- [Duplex pipe](https://github.com/sbaker/imitto/blob/main/src/IMitto/Pipelines/MittoDuplexPipe.cs): `src/IMitto/Pipelines/MittoDuplexPipe.cs`

### Other components

- **Application**

## Connections

- Application → Client host: starts client (evidence: `src/IMitto/Net/Clients/MittoClient.cs`)
- Client host → Client event manager: runs event loops (evidence: `src/IMitto/Net/Clients/MittoClient.cs`)
- Client event manager → Package consumers: invokes consumers (evidence: `src/IMitto/Net/Clients/MittoClientEventManager.cs`)
- Client event manager → Async channels: reads packages (evidence: `src/IMitto/Net/Clients/MittoClientEventManager.cs`)
- Client event manager → Binary protocol: sends requests
- Application → Server request handler: sends requests
- Server request handler → Async channels: writes events (evidence: `src/IMitto.Server/MittoServerRequestHandler.cs`)
- Server event manager → Async channels: reads connections (evidence: `src/IMitto/Net/Server/ServerEventManager.cs`)
- Server event manager → Event listener: polls connections (evidence: `src/IMitto/Net/Server/ServerEventManager.cs`)
- Event listener → Connection context: handles connection
- Server event manager → Local event hub: publishes events (evidence: `src/IMitto/Net/Server/ServerEventManager.cs`)
- Local event hub → Subscriptions: invokes subscriptions
- Subscriptions → Subscription store: uses storage
- Local event hub → Topic parser: matches topics
- Service registration → Client host: registers client (evidence: `src/IMitto.Extensions.DependencyInjection/Extensions/ServiceCollectionExtensions.Clients.cs`)
- Service registration → Client event manager: registers manager (evidence: `src/IMitto.Extensions.DependencyInjection/Extensions/ServiceCollectionExtensions.Clients.cs`)
- Pipeline socket → Duplex pipe: uses pipe (evidence: `src/IMitto/Net/MittoPipelineSocket.cs`)
- Pipeline socket → Binary protocol: transports packages
