# microsoft/generative-ai-for-beginners-dotnet architecture

> Architecture diagram of the GitHub repository microsoft/generative-ai-for-beginners-dotnet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/generative-ai-for-beginners-dotnet
- Repository: https://github.com/microsoft/generative-ai-for-beginners-dotnet

## Overview

##### Project Type & Purpose
- This repository is a **multi‐lesson educational course** for .NET developers, not a monolithic production app.
- It delivers hands-on **code samples** (console apps, a Python API server, a Blazor chat client, an SSE server) and **documentation** (Markdown lessons and translations).
- It demonstrates interactions with AI providers: **GitHub Models**, **Azure OpenAI**, **Ollama (local models)**, and **Docker Model Runner**.

##### File Structure
Top-level components:
- `.devcontainer/` → VS Code dev-container definitions for **GitHub Codespaces** or local Docker environments.
- `01-IntroToGenAI`…`05-ResponsibleGenAI`, `10-WhatsNew/` → Separate lesson folders, each with:
– `readme.md`, `images/` → lesson documentation.
– `src/` (in lessons 2–4) → C# / Python projects.
- `04-PracticalSamples/src/src/` → three sub-projects:
– `McpSample.AppHost` (console host)
– `McpSample.AspNetCoreSseServer` (ASP .NET Core SSE server)
– `McpSample.Chat` (Blazor WebAssembly/Server chat UI)
– `McpSample.ServiceDefaults` (shared library)
- `03-CoreGenerativeAITechniques/src/` → dozens of individual .NET console projects demonstrating AI techniques.
- `translations/` → localized copies of all Markdown docs.
- `.github/workflows/` → CI workflows for linting docs, welcoming contributions, etc.

##### Key Insights from README
- This is a **course framework**, not a deployed system.
- It uses **devcontainers**, **Codespaces**, and optional **local** vs **cloud** AI providers.
- It outlines **five lessons**: basics, setup, core techniques, practical samples, responsible AI.

##### Main Components
a. **Developer Environment**
– GitHub Codespaces / VS Code + `.devcontainer` → pre-configured dev environment
b. **Version Control & CI**
– GitHub repo → .github/workflows → documentation validation, PR checks
c. **Lesson Modules** (logical group)
– “Intro to GenAI” → pure docs
– “Setup Dev Environment” → C# console apps (BasicChat)
– “Core Techniques” → multiple .NET console samples + Python API server
– “Practical Samples” → ASP .NET SSE server + Blazor UI + console host + shared library
– “Responsible GenAI” → docs
d. **AI Providers & Runtimes**
– GitHub Models (hosted inference)
– Azure OpenAI Services
– Local Models via Ollama / Docker Model Runner
e. **Runtime Interactions**
– Console Apps / Blazor UI → call Microsoft.Extensions.AI / Semantic Kernel SDK → provider endpoints
– Python ParksInformationServer → local HTTP API for OpenAPI agent demos

##### Relationships & Data Flows
– Developer spins up **Codespace/devcontainer** → clones repo → selects lesson → runs sample.
– Sample code uses **AI SDK** (Semantic Kernel / Microsoft.Extensions.AI) to send requests to a chosen **Model Provider** (GitHub Models, AOAI, Ollama).
– In Practical Samples:
- Blazor Chat UI ↔ SSE Server over HTTP (EventSource)
- SSE Server ↔ MCP Host (console host library) for advanced interactions
– Python ParksInformationServer hosts an OpenAPI endpoint that .NET agent demos call.

##### Architectural Patterns & Design Principles
– **Modular Lesson Isolation**: each lesson folder is self-contained.
– **Separation of Concerns**:
- Docs vs code samples
- Shared libraries (`McpSample.ServiceDefaults`) vs host/app layers
– **Plug-in AI Provider** approach via dependency injection (SDK)
– **Polyglot demos**: .NET + Python components interacting via HTTP/OpenAPI

##### Detailed Elements
– Labels: component names must match repo folders (e.g., `03-CoreGenerativeAITechniques`).
– Interaction lines:
- DevContainer → .NET & Python Runtimes
- . NET Samples → AI Providers
- Blazor UI ↔ SSE Server
- Agent demos → Python ParksInformationServer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & Dev Environment (Blue)
    subgraph "Developer Environment" 
        direction TB
        Codespace["GitHub Codespaces / VS Code"]:::dev
        DevContainer[".devcontainer"]:::dev
    end
    click DevContainer "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/.devcontainer/devcontainer.json"
    click DevContainer "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/.devcontainer/Ollama/devcontainer.json"

    %% Version Control & CI (Gray)
    subgraph "Version Control & CI" 
        direction TB
        Repo["GitHub Repo (Course)"]:::ci
        CI[".github/workflows"]:::ci
    end
    Repo -->|git clone| Codespace
    click CI "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/.github/workflows/validate-documentation-links.yml"
    click CI "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/.github/workflows/profanity-filter.yml"
    click CI "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/.github/workflows/stale-bot.yml"
    click CI "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/.github/workflows/welcome-issue.yml"
    click CI "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/.github/workflows/welcome-pr.yml"

    %% Lesson Modules & Code Samples (Green)
    subgraph "Lesson Modules" 
        direction TB
        subgraph "01-IntroToGenAI (Docs)" 
            direction TB
            IntroDocs["readme.md + images"]:::lesson
            click IntroDocs "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/01-IntroToGenAI/readme.md"
            click IntroDocs "https://github.com/microsoft/generative-ai-for-beginners-dotnet/tree/main/01-IntroToGenAI/images/"
        end

        subgraph "02-SetupDevEnvironment" 
            direction TB
            SetupDocs["readme.md + tutorials"]:::lesson
            click SetupDocs "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/02-SetupDevEnvironment/readme.md"
            SetupAzure["getting-started-azure-openai.md"]:::lesson
            click SetupAzure "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/02-SetupDevEnvironment/getting-started-azure-openai.md"
            SetupOllama["getting-started-ollama.md"]:::lesson
            click SetupOllama "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/02-SetupDevEnvironment/getting-started-ollama.md"
            subgraph "BasicChat Samples"
                BasicMEAI["BasicChat-01MEAI"]:::sample
                BasicOllama["BasicChat-03Ollama"]:::sample
            end
            click BasicMEAI "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/02-SetupDevEnvironment/src/BasicChat-01MEAI/Program.cs"
            click BasicOllama "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/02-SetupDevEnvironment/src/BasicChat-03Ollama/Program.cs"
        end

        subgraph "03-CoreGenerativeAITechniques" 
            direction TB
            CoreDocs["readme.md"]:::lesson
            click CoreDocs "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/03-CoreGenerativeAITechniques/readme.md"
            CoreSamples["Multiple C# console samples"]:::sample
            click CoreSamples "https://github.com/microsoft/generative-ai-for-beginners-dotnet/tree/main/03-CoreGenerativeAITechniques/src/"
            PythonServer["Python ParksInformationServer"]:::python
            click PythonServer "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/03-CoreGenerativeAITechniques/src/AgentLabs-03-PythonParksInformationServer/app/app.py"
        end

        subgraph "04-PracticalSamples" 
            direction TB
            PracticalDocs["readme.md"]:::lesson
            click PracticalDocs "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/04-PracticalSamples/readme.md"
            subgraph "Samples"
                MCPHost["McpSample.AppHost"]:::sample
                SSEServer["McpSample.AspNetCoreSseServer"]:::sample
                BlazorUI["McpSample.Chat"]:::sample
                ServiceLib["McpSample.ServiceDefaults"]:::lib
            end
            click MCPHost "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/04-PracticalSamples/src/src/McpSample.AppHost/Program.cs"
            click SSEServer "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/04-PracticalSamples/src/src/McpSample.AspNetCoreSseServer/Program.cs"
            click BlazorUI "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/04-PracticalSamples/src/src/McpSample.Chat/Program.cs"
            click ServiceLib "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/04-PracticalSamples/src/src/McpSample.ServiceDefaults/Extensions.cs"
        end

        subgraph "05-ResponsibleGenAI (Docs)" 
            direction TB
            RespDocs["readme.md + images"]:::lesson
            click RespDocs "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/05-ResponsibleGenAI/readme.md"
            click RespDocs "https://github.com/microsoft/generative-ai-for-beginners-dotnet/tree/main/05-ResponsibleGenAI/images/"
        end

        Translations["translations/ (Localized docs)"]:::lesson
        click Translations "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/translations/<lang>/**/readme.md"
        click Translations "https://github.com/microsoft/generative-ai-for-beginners-dotnet/blob/main/translations/<lang>/03-CoreGenerativeAITechniques/src/AgentLabs-03-PythonParksInformationServer/README.md"
    end

    %% AI Providers & Runtime Services (Orange)
    subgraph "AI Providers & Runtimes" 
        direction TB
        GitHubModels["GitHub Models"]:::cloud
        AzureOpenAI["Azure OpenAI Services"]:::cloud
        Ollama["Local Models (Ollama)"]:::cloud
        DockerRunner["Docker Model Runner"]:::cloud
    end

    %% Runtime Interactions
    Codespace -->|run sample| SetupDocs
    Codespace -->|run sample| CoreSamples
    Codespace -->|run sample| MCPHost
    Codespace -->|run sample| BlazorUI

    BasicMEAI -->|AI request/response| GitHubModels
    BasicMEAI -->|AI request/response| AzureOpenAI
    BasicOllama -->|AI request/response| Ollama

    CoreSamples -->|AI request/response| AzureOpenAI
    PythonServer -->|HTTP API calls| CoreSamples

    MCPHost -->|Library calls| ServiceLib
    SSEServer -->|SSE events| BlazorUI
    BlazorUI -->|HTTP| SSEServer
    SSEServer -->|AI request/response| DockerRunner

    %% Documentation & Policies (Gray)
    subgraph "Root Docs & Policies" 
        direction TB
        RootDocs["README.md, CODE_OF_CONDUCT, CONTRIBUTING, LICENSE, SECURITY, SUPPORT"]:::doc
    end

    Repo --> RootDocs

    %% Styles
    classDef dev fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef ci fill:#F0F0F0,stroke:#999999,color:#333333;
    classDef lesson fill:#E6FFED,stroke:#28A745,color:#28A745;
    classDef sample fill:#E6FFED,stroke:#28A745,color:#28A745;
    classDef python fill:#E6FFED,stroke:#28A745,color:#28A745;
    classDef lib fill:#E6FFED,stroke:#28A745,color:#28A745;
    classDef cloud fill:#FFF5E5,stroke:#D69E00,color:#D69E00;
    classDef doc fill:#F0F0F0,stroke:#999999,color:#333333;
```
