# mattherman/mbdotnet architecture

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

- Interactive diagram: https://gitdiagram.com/mattherman/mbdotnet
- Repository: https://github.com/mattherman/mbdotnet

## Overview

##### Main Components

a. Core Components:
- MountebankClient (Main entry point)
- Request Proxy Layer
- Model Layer
- HTTP Client Wrapper

b. Key Abstractions:
- Imposters (HTTP, HTTPS, SMTP, TCP)
- Stubs
- Predicates
- Responses

**┌─ Application Layer ─────────────────────────────────────┐**

- ┌─ Client Interface ─┐    ┌─ Request Proxy ─┐        │
- IClient         │──→ │ IRequestProxy    │        │
- MountebankClient│    │ MountebankProxy │        │
- ┘    └────────────────┘         │
- ↓                     ↓                  │
- ┌─ HTTP Client Wrapper ────────┘                 │
- IHttpClientWrapper                          │
- HttpClientWrapper                           │

- Domain Model Layer ──────────────────────────────────┤

- ┌─ Imposters ─┐   ┌─ Stubs ─┐   ┌─ Predicates ─┐   │
- HTTP        │   │ HttpStub │   │ Contains     │   │
- HTTPS       │←──│ TcpStub  │←──│ Equals      │   │
- SMTP        │   └─────────┘   │ Matches     │   │
- TCP         │                 └────────────┘   │
- ┘                                   │

- ┌─ Responses ────┐   ┌─ Request Models ┐           │
- IsResponse     │   │ HttpRequest     │           │
- FaultResponse  │   │ SmtpRequest     │           │
- ProxyResponse  │   │ TcpRequest      │           │
- ┘   └───────────────┘           │

- ┘

##### Important Relationships to Highlight
- MountebankClient implements IClient
- MountebankClient uses IRequestProxy
- All Imposters inherit from base Imposter class
- Stubs contain Predicates and Responses
- Request Models are used by Predicates

##### Implementation Details to Note
- The library targets .NET Standard 1.3
- Supports multiple imposter types
- Uses fluent interface pattern for configuration
- Handles serialization/deserialization of requests/responses

##### Notes for Implementation
- Version information
- Unsupported features (inject response, certain behaviors)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Application
        subgraph ClientInterface
            IClient["IClient"]:::interface
            MbClient["MountebankClient"]:::implementation
        end

        subgraph RequestProxy
            IReqProxy["IRequestProxy"]:::interface
            MbProxy["MountebankRequestProxy"]:::implementation
        end

        subgraph HttpWrapper
            IHttpClient["IHttpClientWrapper"]:::interface
            HttpClient["HttpClientWrapper"]:::implementation
        end
    end

    subgraph DomainModel
        subgraph Imposters
            BaseImp["Base Imposter"]:::model
            HttpImp["HTTP Imposter"]:::model
            HttpsImp["HTTPS Imposter"]:::model
            SmtpImp["SMTP Imposter"]:::model
            TcpImp["TCP Imposter"]:::model
        end

        subgraph Stubs
            BaseStub["Base Stub"]:::model
            HttpStub["HTTP Stub"]:::model
            TcpStub["TCP Stub"]:::model
        end

        subgraph Predicates
            BasePred["Base Predicate"]:::model
            ContainsPred["Contains Predicate"]:::model
            EqualsPred["Equals Predicate"]:::model
            MatchesPred["Matches Predicate"]:::model
        end

        subgraph Responses
            BaseResp["Base Response"]:::model
            IsResp["Is Response"]:::model
            FaultResp["Fault Response"]:::model
            ProxyResp["Proxy Response"]:::model
        end

        subgraph RequestModels
            BaseReq["Base Request"]:::model
            HttpReq["HTTP Request"]:::model
            SmtpReq["SMTP Request"]:::model
            TcpReq["TCP Request"]:::model
        end
    end

    %% Relationships
    IClient --> MbClient
    MbClient --> IReqProxy
    IReqProxy --> MbProxy
    MbProxy --> IHttpClient
    IHttpClient --> HttpClient

    BaseImp --> HttpImp & HttpsImp & SmtpImp & TcpImp
    BaseStub --> HttpStub & TcpStub
    BasePred --> ContainsPred & EqualsPred & MatchesPred
    BaseResp --> IsResp & FaultResp & ProxyResp
    BaseReq --> HttpReq & SmtpReq & TcpReq

    %% Click events
    click IClient "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/IClient.cs"
    click MbClient "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/MountebankClient.cs"
    click IReqProxy "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/IRequestProxy.cs"
    click MbProxy "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/MountebankRequestProxy.cs"
    click IHttpClient "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/IHttpClientWrapper.cs"
    click HttpClient "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/HttpClientWrapper.cs"
    click BaseImp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Imposters/Imposter.cs"
    click HttpImp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Imposters/HttpImposter.cs"
    click HttpsImp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Imposters/HttpsImposter.cs"
    click SmtpImp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Imposters/SmtpImposter.cs"
    click TcpImp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Imposters/TcpImposter.cs"
    click BaseStub "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Stubs/Stub.cs"
    click HttpStub "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Stubs/HttpStub.cs"
    click TcpStub "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Stubs/TcpStub.cs"
    click BasePred "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Predicates/Predicate.cs"
    click ContainsPred "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Predicates/ContainsPredicate.cs"
    click EqualsPred "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Predicates/EqualsPredicate.cs"
    click MatchesPred "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Predicates/MatchesPredicate.cs"
    click BaseResp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Responses/Response.cs"
    click IsResp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Responses/IsResponse.cs"
    click FaultResp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Responses/FaultResponse.cs"
    click ProxyResp "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Responses/ProxyResponse.cs"
    click BaseReq "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Requests/Request.cs"
    click HttpReq "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Requests/HttpRequest.cs"
    click SmtpReq "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Requests/SmtpRequest.cs"
    click TcpReq "https://github.com/mattherman/mbdotnet/blob/master/MbDotNet/Models/Requests/TcpRequest.cs"

    %% Styling
    classDef interface fill:#f9f,stroke:#333,stroke-width:2px
    classDef implementation fill:#bbf,stroke:#333,stroke-width:2px
    classDef model fill:#bfb,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Interface["Interface"]:::interface
        Implementation["Implementation"]:::implementation
        Model["Model"]:::model
    end
```
