# hakchi06/html-data-extractor architecture

> Architecture diagram of the GitHub repository hakchi06/html-data-extractor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hakchi06/html-data-extractor
- Repository: https://github.com/hakchi06/html-data-extractor

## Overview

1. **Repository type and purpose**
   - This is a small .NET 8 solution centered on a reusable HTML parsing library.
   - The main goal is to transform an input HTML string containing a table into a structured `TableData` object.

2. **Primary architectural boundary**
   - The core boundary is between **string-based HTML input** and **typed parsed output**.
   - The library does not fetch pages, call external services, or manage persistence; it only processes HTML already supplied by the caller.

3. **Core project**
   - `HtmlDataExtractor.Core` contains the actual parsing logic and data contracts.
   - This is the reusable subsystem that other application layers would depend on.

4. **Parser contract**
   - `IHtmlParser` defines the abstraction for parser implementations.
   - This boundary allows the parsing behavior to be swapped or extended without changing consumers.

5. **Parser implementation**
   - `HtmlTableParser` is the concrete implementation.
   - Its flow is: load HTML, find the first `<table>`, read headers from `<thead>`, iterate rows in `<tbody>`, and build record dictionaries keyed by header text.

6. **Data model**
   - `TableData` is the output shape of the system.
   - It holds the extracted headers, the list of records, and the total record count, making the result easy to serialize or consume downstream.

7. **Cell value resolution**
   - The parser resolves each cell by priority: visible text first, then image `src`, then link `href`.
   - This detail matters architecturally because it makes the parser useful for mixed-content tables, not just plain-text tables.

8. **Application layer placeholder**
   - `HtmlDataExtractor.Api` exists as a separate project, but the README indicates it is “coming soon.”
   - In the current repository, the API project is best treated as a future delivery boundary rather than a fully realized subsystem.

9. **Test architecture**
   - `HtmlDataExtractor.Tests` validates parser behavior with real HTML fixtures in `TestData`.
   - The tests focus on parser correctness against representative table structures rather than mocking external systems.

10. **Representative data flow**
   - Input: raw HTML string.
   - Processing: parser selects first table, extracts headers and rows, maps cells to header names.
   - Output: `TableData` object suitable for JSON serialization or downstream processing.

11. **Technology and runtime**
   - The solution targets **.NET 8** and uses standard C# project separation for core logic, tests, and API shell.
   - Serialization in the README example uses `System.Text.Json`, but serialization is not part of the core parser itself.

12. **Tooling and delivery**
   - CI is configured via GitHub Actions in `.github/workflows/ci.yml`.
   - This suggests automated build/test validation for the library and its parser tests on each change.

13. **Expected diagram emphasis**
   - A clear architecture diagram should show:
     - caller-provided HTML input entering the core parser,
     - the parser extracting structure from table markup,
     - `TableData` as the output boundary,
     - tests feeding sample HTML into the same parser,
     - and the API project as a future integration layer rather than a current runtime dependency.

Main entry points: [`src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs`](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs) (Table parser), [`src/HtmlDataExtractor.Core/Models/TableData.cs`](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Models/TableData.cs) (Table data), [`tests/HtmlDataExtractor.Tests/HtmlTableParserTests.cs`](https://github.com/hakchi06/html-data-extractor/blob/main/tests/HtmlDataExtractor.Tests/HtmlTableParserTests.cs) (Parser tests), [`HtmlDataExtractor.sln`](https://github.com/hakchi06/html-data-extractor/blob/main/HtmlDataExtractor.sln) (Solution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo_core["Core library"]
  node_html_input["HTML input<br/>string html"]
  node_parser_contract{{"Parser contract<br/>interface<br/>[IHtmlParser.cs]"}}
  node_table_parser["Table parser<br/>html parser<br/>[HtmlTableParser.cs]"]
  node_table_select["Pick table<br/>table selection<br/>[HtmlTableParser.cs]"]
  node_header_extract["Read headers<br/>header extraction<br/>[HtmlTableParser.cs]"]
  node_row_extract["Read rows<br/>row extraction<br/>[HtmlTableParser.cs]"]
  node_cell_resolve["Resolve cell<br/>cell mapping<br/>[HtmlTableParser.cs]"]
  node_table_data[("Table data<br/>output model<br/>[TableData.cs]")]
  node_consumer_output["Structured output<br/>serialized data"]
end

subgraph group_repo_tests["Tests"]
  node_parser_tests["Parser tests<br/>test suite"]
  node_test_fixtures["HTML fixtures<br/>test data<br/>[TestData]"]
end

subgraph group_repo_api["API shell"]
  node_api_shell(("API shell<br/>future api<br/>[Program.cs]"))
end

subgraph group_repo_ci["CI"]
  node_ci_workflow["CI workflow<br/>github actions<br/>[ci.yml]"]
end

node_solution["Solution"]
node_readme["README<br/>usage docs<br/>[README.md]"]

node_html_input -->|"parse"| node_table_parser
node_parser_contract -->|"implemented by"| node_table_parser
node_table_parser -->|"select"| node_table_select
node_table_select -->|"headers"| node_header_extract
node_table_select -->|"body rows"| node_row_extract
node_row_extract -->|"cells"| node_cell_resolve
node_header_extract -->|"schema"| node_table_data
node_row_extract -->|"records"| node_table_data
node_cell_resolve -->|"values"| node_table_data
node_table_data -->|"serialize"| node_consumer_output
node_test_fixtures -->|"inputs"| node_parser_tests
node_parser_tests -->|"exercise"| node_table_parser
node_table_parser -.->|"future use"| node_api_shell
node_ci_workflow -->|"runs"| node_parser_tests
node_solution -->|"includes"| node_parser_contract
node_solution -->|"includes"| node_parser_tests
node_solution -->|"includes"| node_api_shell
node_readme -.->|"describes"| node_table_parser
node_readme -.->|"describes"| node_table_data

click node_parser_contract "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Interfaces/IHtmlParser.cs"
click node_table_parser "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs"
click node_table_select "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs"
click node_header_extract "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs"
click node_row_extract "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs"
click node_cell_resolve "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs"
click node_table_data "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Models/TableData.cs"
click node_parser_tests "https://github.com/hakchi06/html-data-extractor/blob/main/tests/HtmlDataExtractor.Tests/HtmlTableParserTests.cs"
click node_test_fixtures "https://github.com/hakchi06/html-data-extractor/blob/main/tests/HtmlDataExtractor.Tests/TestData"
click node_api_shell "https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Api/Program.cs"
click node_ci_workflow "https://github.com/hakchi06/html-data-extractor/blob/main/.github/workflows/ci.yml"
click node_solution "https://github.com/hakchi06/html-data-extractor/blob/main/HtmlDataExtractor.sln"
click node_readme "https://github.com/hakchi06/html-data-extractor/blob/main/README.md"

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_html_input,node_parser_contract,node_table_parser,node_table_select,node_header_extract,node_row_extract,node_cell_resolve,node_table_data,node_consumer_output toneBlue
class node_parser_tests,node_test_fixtures toneAmber
class node_api_shell toneMint
class node_ci_workflow toneRose
class node_solution,node_readme toneNeutral
```

## Components

### Core library

Reusable HTML table parsing boundary and data contracts.

- **HTML input**: string html · Caller-supplied HTML string containing a table.
- [Parser contract](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Interfaces/IHtmlParser.cs): interface · Abstracts parsing so implementations can be swapped without changing consumers. · `src/HtmlDataExtractor.Core/Interfaces/IHtmlParser.cs`
- [Table parser](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs): html parser · Concrete parser that loads HTML, finds the first table, and builds table output. · `src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs`
- [Pick table](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs): table selection · Selects the first <table> element from the input HTML. · `src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs`
- [Read headers](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs): header extraction · Reads column names from the table header section. · `src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs`
- [Read rows](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs): row extraction · Iterates table body rows and aligns cells to headers. · `src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs`
- [Resolve cell](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs): cell mapping · Uses visible text first, then image src, then link href when a cell is mixed content. · `src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs`
- [Table data](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Core/Models/TableData.cs): output model · Structured output with headers, record list, and total record count. · `src/HtmlDataExtractor.Core/Models/TableData.cs`
- **Structured output**: serialized data · Downstream-ready result, often serialized or consumed by another layer.

### Tests

Parser validation against representative HTML fixtures.

- [Parser tests](https://github.com/hakchi06/html-data-extractor/blob/main/tests/HtmlDataExtractor.Tests/HtmlTableParserTests.cs): test suite · Validates parser behavior against representative HTML structures. · `tests/HtmlDataExtractor.Tests/HtmlTableParserTests.cs`
- [HTML fixtures](https://github.com/hakchi06/html-data-extractor/blob/main/tests/HtmlDataExtractor.Tests/TestData): test data · Real HTML samples used to exercise table parsing scenarios. · `tests/HtmlDataExtractor.Tests/TestData`

### API shell

Placeholder application layer for future integration.

- [API shell](https://github.com/hakchi06/html-data-extractor/blob/main/src/HtmlDataExtractor.Api/Program.cs): future api · Placeholder application layer; currently not a realized runtime subsystem. · `src/HtmlDataExtractor.Api/Program.cs`

### CI

Automated build and test workflow.

- [CI workflow](https://github.com/hakchi06/html-data-extractor/blob/main/.github/workflows/ci.yml): github actions · Automated build and test validation on change. · `.github/workflows/ci.yml`

### Other components

- [Solution](https://github.com/hakchi06/html-data-extractor/blob/main/HtmlDataExtractor.sln): .NET 8 solution · Top-level solution tying together core, tests, and API projects. · `HtmlDataExtractor.sln`
- [README](https://github.com/hakchi06/html-data-extractor/blob/main/README.md): usage docs · Documents the parsing flow and intended usage. · `README.md`

## Connections

- HTML input → Table parser: parse · Supplied HTML enters the parser.
- Parser contract → Table parser: implemented by · The concrete parser fulfills the contract.
- Table parser → Pick table: select · Parser starts by choosing the first table.
- Pick table → Read headers: headers · After locating a table, headers are extracted.
- Pick table → Read rows: body rows · The table body is traversed row by row.
- Read rows → Resolve cell: cells · Each cell is normalized into a usable value.
- Read headers → Table data: schema · Header names define the output record shape.
- Read rows → Table data: records · Parsed rows become record dictionaries.
- Resolve cell → Table data: values · Resolved cell values populate record fields.
- Table data → Structured output: serialize · The structured model can be serialized or consumed downstream.
- HTML fixtures → Parser tests: inputs · Fixture HTML feeds parser tests.
- Parser tests → Table parser: exercise · Tests run the same parser implementation.
- Table parser → API shell: future use · The API layer may later host or expose the parser.
- CI workflow → Parser tests: runs · CI validates the test suite automatically.
- Solution → Parser contract: includes · The solution organizes the core library projects.
- Solution → Parser tests: includes · The solution includes the test project.
- Solution → API shell: includes · The solution includes the API project.
- README → Table parser: describes · Documentation explains the parser flow and behavior.
- README → Table data: describes · Documentation shows the output contract.
