# guilegaton/htmlparser architecture

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

- Interactive diagram: https://gitdiagram.com/guilegaton/htmlparser
- Repository: https://github.com/guilegaton/htmlparser

## Overview

HtmlParser is a .NET library for defining HTML templates with fluent, tag-specific builders, matching those templates against a document, and mapping matched content into a model. The apparent workflow is template construction, node-tree representation, document search, then model population. The README also advertises HTML-string template support, but the supplied excerpts do not expose its implementation or the library’s public orchestration entry point. Connections below are limited to relationships visible in excerpts or the source index.

Main entry points: [`HtmlParser/Builders/BaseBlockBuilder.cs`](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Builders/BaseBlockBuilder.cs) (Base block builder), [`HtmlParser/Models/Node.cs`](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Models/Node.cs) (Node model), [`HtmlParser/Interfaces/INode.cs`](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Interfaces/INode.cs) (Node contract), [`HtmlParser/Business/ParsingService.cs`](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Business/ParsingService.cs) (Model parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_template["Template construction"]
  node_builder_api["Builder API<br/>[INodeBuilder.cs]"]
  node_base_builder["Base block builder"]
  node_tag_builders["Tag builders"]
  node_custom_builder["Custom block builder"]
end

subgraph group_representation["Node representation"]
  node_builder_node["Builder node<br/>[BuilderNode.cs]"]
  node_html_node["HTML node<br/>[HtmlNode.cs]"]
  node_node_base["Node model<br/>[Node.cs]"]
  node_node_contract["Node contract<br/>[INode.cs]"]
end

subgraph group_matching["Document matching"]
  node_html_nodes_builder["HTML-to-nodes builder"]
  node_search["Template search<br/>[SearchService.cs]"]
end

subgraph group_mapping["Model mapping"]
  node_parsing["Model parser<br/>[ParsingService.cs]"]
  node_lambda_extensions["Property assignment"]
  node_mapping_errors["Mapping exceptions"]
end

node_caller(("Library caller"))
node_html["HTML document"]

node_caller -.->|"configures template"| node_builder_api
node_builder_api -.->|"exposes builders"| node_base_builder
node_base_builder -->|"creates tag builders"| node_tag_builders
node_base_builder -->|"creates custom builder"| node_custom_builder
node_builder_node -->|"inherits from"| node_node_base
node_html_node -->|"inherits from"| node_node_base
node_node_base -->|"implements"| node_node_contract
node_html_nodes_builder -->|"builds nodes"| node_html_node
node_search -->|"matches nodes"| node_node_contract
node_html -.->|"searched document"| node_search
node_parsing -->|"reads matched nodes"| node_node_contract
node_parsing -->|"sets properties"| node_lambda_extensions
node_lambda_extensions -->|"throws mapping errors"| node_mapping_errors

click node_builder_api "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Interfaces/INodeBuilder.cs"
click node_base_builder "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Builders/BaseBlockBuilder.cs"
click node_tag_builders "https://github.com/guilegaton/htmlparser/tree/master/HtmlParser/Builders/Blocks"
click node_custom_builder "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Builders/CustomBlockBuilder.cs"
click node_builder_node "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Models/BuilderNode.cs"
click node_html_node "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Models/HtmlNode.cs"
click node_node_base "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Models/Node.cs"
click node_node_contract "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Interfaces/INode.cs"
click node_html_nodes_builder "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Business/HtmlToNodesBuilder.cs"
click node_search "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Business/SearchService.cs"
click node_parsing "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Business/ParsingService.cs"
click node_lambda_extensions "https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Extensions/LambdaExtensions.cs"
click node_mapping_errors "https://github.com/guilegaton/htmlparser/tree/master/HtmlParser/Exceptions"

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_builder_api,node_base_builder,node_tag_builders,node_custom_builder toneBlue
class node_builder_node,node_html_node,node_node_base,node_node_contract toneAmber
class node_html_nodes_builder,node_search toneMint
class node_parsing,node_lambda_extensions,node_mapping_errors toneRose
class node_caller,node_html toneIndigo
```

## Components

### Template construction

- [Builder API](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Interfaces/INodeBuilder.cs): `HtmlParser/Interfaces/INodeBuilder.cs`
- [Base block builder](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Builders/BaseBlockBuilder.cs): `HtmlParser/Builders/BaseBlockBuilder.cs`
- [Tag builders](https://github.com/guilegaton/htmlparser/tree/master/HtmlParser/Builders/Blocks): `HtmlParser/Builders/Blocks`
- [Custom block builder](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Builders/CustomBlockBuilder.cs): `HtmlParser/Builders/CustomBlockBuilder.cs`

### Node representation

- [Builder node](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Models/BuilderNode.cs): `HtmlParser/Models/BuilderNode.cs`
- [HTML node](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Models/HtmlNode.cs): `HtmlParser/Models/HtmlNode.cs`
- [Node model](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Models/Node.cs): `HtmlParser/Models/Node.cs`
- [Node contract](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Interfaces/INode.cs): `HtmlParser/Interfaces/INode.cs`

### Document matching

- [HTML-to-nodes builder](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Business/HtmlToNodesBuilder.cs): `HtmlParser/Business/HtmlToNodesBuilder.cs`
- [Template search](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Business/SearchService.cs): `HtmlParser/Business/SearchService.cs`

### Model mapping

- [Model parser](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Business/ParsingService.cs): `HtmlParser/Business/ParsingService.cs`
- [Property assignment](https://github.com/guilegaton/htmlparser/blob/master/HtmlParser/Extensions/LambdaExtensions.cs): `HtmlParser/Extensions/LambdaExtensions.cs`
- [Mapping exceptions](https://github.com/guilegaton/htmlparser/tree/master/HtmlParser/Exceptions): `HtmlParser/Exceptions`

### Other components

- **Library caller**
- **HTML document**

## Connections

- Library caller → Builder API: configures template
- Builder API → Base block builder: exposes builders (evidence: `HtmlParser/Builders/BaseBlockBuilder.cs`)
- Base block builder → Tag builders: creates tag builders (evidence: `HtmlParser/Builders/BaseBlockBuilder.cs`)
- Base block builder → Custom block builder: creates custom builder (evidence: `HtmlParser/Builders/BaseBlockBuilder.cs`)
- Builder node → Node model: inherits from (evidence: `HtmlParser/Models/BuilderNode.cs`)
- HTML node → Node model: inherits from (evidence: `HtmlParser/Models/HtmlNode.cs`)
- Node model → Node contract: implements (evidence: `HtmlParser/Models/Node.cs`)
- HTML-to-nodes builder → HTML node: builds nodes (evidence: `HtmlParser/Business/HtmlToNodesBuilder.cs`)
- Template search → Node contract: matches nodes (evidence: `HtmlParser/Business/SearchService.cs`)
- HTML document → Template search: searched document
- Model parser → Node contract: reads matched nodes (evidence: `HtmlParser/Business/ParsingService.cs`)
- Model parser → Property assignment: sets properties (evidence: `HtmlParser/Business/ParsingService.cs`)
- Property assignment → Mapping exceptions: throws mapping errors (evidence: `HtmlParser/Extensions/LambdaExtensions.cs`)
