# beanhsiang/embedding-markitdown-into-dotnet-demo architecture

> Architecture diagram of the GitHub repository beanhsiang/embedding-markitdown-into-dotnet-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/beanhsiang/embedding-markitdown-into-dotnet-demo
- Repository: https://github.com/beanhsiang/embedding-markitdown-into-dotnet-demo

## Overview

##### Main Components
- .NET Application: Represented by the CSharpConsoleApp (located in the dotnet directory). This is the primary driver that initializes the Python environment, invokes the Python script, and displays the results.
- Python Script/Environment: Found in the python directory (demo.py and requirements.txt). This component handles PDF processing via the MarkItDown library.
- Assets: A resource component that includes the PDF file (test.pdf) used for demonstration.
- Integration Layer: Although not explicitly a separate directory, consider the CSnakes.Runtime library integration as a key bridging element between the .NET application and the Python environment.
- External Dependencies: Note the use of MarkItDown (a Python library) and environment specifications like .NET 6.0+ SDK and Python 3.9+ (or as noted, Python 3.12 in the README).

##### Relationships and Interactions
- The .NET console application (CSharpConsoleApp) is the entry point. It is responsible for:
- Initializing and configuring the Python runtime.
- Invoking the Python script (demo.py) using CSnakes.Runtime.
- Receiving and processing the results generated by the Python script.
- The Python script uses the MarkItDown library:
- Processes the PDF document (assets/test.pdf).
- Returns extracted text or processed data back to the .NET application.
- A call from the .NET component to the Python component.
- Data flow from the assets (PDF file) into the Python script.
- The feedback from processing results being routed back into the .NET application.

##### Architectural Patterns and Design Principles
- Cross-language Integration: Emphasize how the project seamlessly integrates two different runtime environments (.NET and Python) using an interop library (CSnakes.Runtime).

##### Final Touches
- Every component is clearly visible and identifiable.
- Aim for a detailed yet clean visual separation of components and layers – the clearer the distinctions, the easier it will be for any stakeholder or team member to understand the embedded architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% .NET Environment
    subgraph ".NET Environment"
        A["CSharpConsoleApp"]:::dotnet
        B["CSnakes.Runtime Integration"]:::integration
        A -->|"initializes"| B
    end

    %% Python Environment
    subgraph "Python Environment"
        C["Python Script (demo.py)"]:::python
        C -->|"processes using"| D["MarkItDown Library"]:::external
    end

    %% Assets
    E["PDF Asset (test.pdf)"]:::assets

    %% External Dependencies
    subgraph "External Dependencies"
        F[".NET 6.0+ SDK"]:::external
        G["Python 3.12+"]:::external
    end

    %% Relationships
    B -->|"invokes"| C
    E -->|"provides"| C
    C -->|"returns data"| A
    F -.-> A
    G -.-> C

    %% Click Events
    click A "https://github.com/beanhsiang/embedding-markitdown-into-dotnet-demo/blob/main/dotnet/CSharpConsoleApp/Program.cs"
    click B "https://github.com/beanhsiang/embedding-markitdown-into-dotnet-demo/blob/main/dotnet/CSharpConsoleApp/CSharpConsoleApp.csproj"
    click C "https://github.com/beanhsiang/embedding-markitdown-into-dotnet-demo/blob/main/python/demo.py"
    click E "https://github.com/beanhsiang/embedding-markitdown-into-dotnet-demo/blob/main/assets/test.pdf"

    %% Styles
    classDef dotnet fill:#d4e6f1,stroke:#1f618d,stroke-width:2px;
    classDef python fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef integration fill:#f5b041,stroke:#9c640c,stroke-width:2px;
    classDef assets fill:#a3e4d7,stroke:#117864,stroke-width:2px;
    classDef external fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
```
