How hakchi06/html-data-extractor works
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: HtmlTableParser.cs Table parser · TableData.cs Table data · HtmlTableParserTests.cs Parser tests · HtmlDataExtractor.sln Solution
Components 15
Core library
Reusable HTML table parsing boundary and data contracts.
- HTML input · Caller-supplied HTML string containing a table.
- Parser contract · Abstracts parsing so implementations can be swapped without changing consumers.
src/HtmlDataExtractor.Core/Interfaces/IHtmlParser.cs - Table parser · Concrete parser that loads HTML, finds the first table, and builds table output.
src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs - Pick table · Selects the first <table> element from the input HTML.
src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs - Read headers · Reads column names from the table header section.
src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs - Read rows · Iterates table body rows and aligns cells to headers.
src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs - Resolve cell · Uses visible text first, then image src, then link href when a cell is mixed content.
src/HtmlDataExtractor.Core/Parsers/HtmlTableParser.cs - Table data · Structured output with headers, record list, and total record count.
src/HtmlDataExtractor.Core/Models/TableData.cs - Structured output · Downstream-ready result, often serialized or consumed by another layer.
Tests
Parser validation against representative HTML fixtures.
- Parser tests · Validates parser behavior against representative HTML structures.
tests/HtmlDataExtractor.Tests/HtmlTableParserTests.cs - HTML fixtures · Real HTML samples used to exercise table parsing scenarios.
tests/HtmlDataExtractor.Tests/TestData
API shell
Placeholder application layer for future integration.
- API shell · Placeholder application layer; currently not a realized runtime subsystem.
src/HtmlDataExtractor.Api/Program.cs
CI
Automated build and test workflow.
- CI workflow · Automated build and test validation on change.
.github/workflows/ci.yml
Connections 19
- 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.