# microsoft/power-bi-embedded-contoso-sales-demo architecture

> Architecture diagram of the GitHub repository microsoft/power-bi-embedded-contoso-sales-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/power-bi-embedded-contoso-sales-demo
- Repository: https://github.com/microsoft/power-bi-embedded-contoso-sales-demo

## Overview

Contoso Sales Demo is a React/.NET sales portal centered on embedding an interactive Power BI report, with role-based access and Dataverse writeback. The main user path is login, report embedding and customization, then optional report export or sales-record edits. The graph preserves documented report interactions and sales-management capabilities; unsampled modules are represented only where the tree or README supports them. Some client-to-server writeback and authentication wiring is not shown, so those relationships are omitted.

Main entry points: [`ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx) (Embedded report page), [`ContosoSalesDemo/Controllers/PowerBiController.cs`](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Controllers/PowerBiController.cs) (Power BI API), [`ContosoSalesDemo/Services/AadService.cs`](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/AadService.cs) (Aad token service), [`ContosoSalesDemo/ClientApp/src/App.tsx`](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/App.tsx) (App routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Sales portal"]
  node_app["App routing<br/>[App.tsx]"]
  node_login["Login and roles<br/>[Login.tsx]"]
  node_leadform["Lead editing<br/>[EditLeadForm.tsx]"]
  node_opportunityform["Opportunity editing"]
  node_saveform["Form submission<br/>[SaveData.ts]"]
end

subgraph group_analytics["Embedded analytics"]
  node_embedpage["Embedded report page<br/>[EmbedPage.tsx]"]
  node_visualgroup["Visual layout<br/>[VisualGroup.ts]"]
  node_reportconfig["Report configuration<br/>[reportConfig.ts]"]
  node_personalise["Report personalization<br/>[PersonaliseBar.tsx]"]
  node_bookmarks["Bookmarks<br/>[BookmarksList.tsx]"]
  node_exportui["Export controls<br/>[Export.tsx]"]
end

subgraph group_server["Application API"]
  node_authcontroller["Authentication API"]
  node_powerbicontroller["Power BI API"]
  node_dataversecontroller["Dataverse API"]
  node_embedservice["Embed token service<br/>[EmbedService.cs]"]
  node_exportservice["Report export service<br/>[ExportService.cs]"]
end

subgraph group_identity["Identity services"]
  node_aadservice["Aad token service<br/>[AadService.cs]"]
  node_jwttokens["JWT generation<br/>[JwtTokenService.cs]"]
end

subgraph group_data["Sales data"]
  node_dataverseservice["Dataverse operations"]
end

node_salesperson(("Salesperson"))
node_powerbi["Power BI service"]
node_dataverse[("Microsoft Dataverse")]
node_entra["Microsoft Entra ID"]
node_keyvault[("Azure Key Vault")]
node_msal["MSAL.NET"]

node_salesperson -->|"uses"| node_app
node_app -.->|"shows when unauthenticated"| node_login
node_app -->|"renders"| node_embedpage
node_embedpage -->|"fetches embed params"| node_powerbicontroller
node_powerbicontroller -->|"generates embed params"| node_embedservice
node_embedservice -->|"requests embed token"| node_powerbi
node_embedpage -->|"uses visual layouts"| node_visualgroup
node_visualgroup -->|"reads configuration"| node_reportconfig
node_embedpage -->|"renders controls"| node_personalise
node_embedpage -->|"renders list"| node_bookmarks
node_embedpage -->|"renders edit form"| node_leadform
node_embedpage -.->|"supports editing"| node_opportunityform
node_leadform -.->|"uses submission"| node_saveform
node_opportunityform -->|"uses submission"| node_saveform
node_exportui -.->|"requests export"| node_powerbicontroller
node_powerbicontroller -->|"gets exported file"| node_exportservice
node_exportservice -->|"exports report"| node_powerbi
node_authcontroller -->|"generates token"| node_jwttokens
node_powerbicontroller -.->|"routes edits"| node_dataversecontroller
node_dataversecontroller -->|"delegates operations"| node_dataverseservice
node_dataverseservice -->|"reads and writes"| node_dataverse
node_embedservice -->|"gets access token"| node_aadservice
node_exportservice -->|"gets access token"| node_aadservice
node_dataverseservice -->|"gets access token"| node_aadservice
node_aadservice -->|"acquires token"| node_msal
node_jwttokens -->|"signs JWT"| node_keyvault
node_aadservice -->|"authenticates service principal"| node_entra

click node_app "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/App.tsx"
click node_login "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Login/Login.tsx"
click node_embedpage "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx"
click node_visualgroup "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/VisualGroup.ts"
click node_reportconfig "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/reportConfig.ts"
click node_personalise "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/PersonaliseBar/PersonaliseBar.tsx"
click node_bookmarks "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/BookmarksList/BookmarksList.tsx"
click node_exportui "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/AnalyticsPopup/Export/Export.tsx"
click node_leadform "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Forms/EditLeadForm.tsx"
click node_opportunityform "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Forms/UpdateOpportunityForm.tsx"
click node_saveform "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Forms/SaveData.ts"
click node_authcontroller "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Controllers/BasicAuthenticationController.cs"
click node_powerbicontroller "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Controllers/PowerBiController.cs"
click node_dataversecontroller "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Controllers/DataverseController.cs"
click node_embedservice "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/EmbedService.cs"
click node_exportservice "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/ExportService.cs"
click node_dataverseservice "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/DataverseService.cs"
click node_aadservice "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/AadService.cs"
click node_jwttokens "https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/JwtTokenService.cs"

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_app,node_login,node_leadform,node_opportunityform,node_saveform toneBlue
class node_embedpage,node_visualgroup,node_reportconfig,node_personalise,node_bookmarks,node_exportui,node_dataverse,node_keyvault toneAmber
class node_authcontroller,node_powerbicontroller,node_dataversecontroller,node_embedservice,node_exportservice toneMint
class node_aadservice,node_jwttokens toneRose
class node_dataverseservice,node_salesperson,node_powerbi,node_entra,node_msal toneIndigo
```

## Components

### Sales portal

- [App routing](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/App.tsx): `ContosoSalesDemo/ClientApp/src/App.tsx`
- [Login and roles](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Login/Login.tsx): `ContosoSalesDemo/ClientApp/src/components/Login/Login.tsx`
- [Lead editing](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Forms/EditLeadForm.tsx): `ContosoSalesDemo/ClientApp/src/components/Forms/EditLeadForm.tsx`
- [Opportunity editing](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Forms/UpdateOpportunityForm.tsx): `ContosoSalesDemo/ClientApp/src/components/Forms/UpdateOpportunityForm.tsx`
- [Form submission](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/Forms/SaveData.ts): `ContosoSalesDemo/ClientApp/src/components/Forms/SaveData.ts`

### Embedded analytics

- [Embedded report page](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx): `ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`
- [Visual layout](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/VisualGroup.ts): `ContosoSalesDemo/ClientApp/src/components/VisualGroup.ts`
- [Report configuration](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/reportConfig.ts): `ContosoSalesDemo/ClientApp/src/reportConfig.ts`
- [Report personalization](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/PersonaliseBar/PersonaliseBar.tsx): `ContosoSalesDemo/ClientApp/src/components/PersonaliseBar/PersonaliseBar.tsx`
- [Bookmarks](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/BookmarksList/BookmarksList.tsx): `ContosoSalesDemo/ClientApp/src/components/BookmarksList/BookmarksList.tsx`
- [Export controls](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/ClientApp/src/components/AnalyticsPopup/Export/Export.tsx): `ContosoSalesDemo/ClientApp/src/components/AnalyticsPopup/Export/Export.tsx`

### Application API

- [Authentication API](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Controllers/BasicAuthenticationController.cs): `ContosoSalesDemo/Controllers/BasicAuthenticationController.cs`
- [Power BI API](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Controllers/PowerBiController.cs): `ContosoSalesDemo/Controllers/PowerBiController.cs`
- [Dataverse API](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Controllers/DataverseController.cs): `ContosoSalesDemo/Controllers/DataverseController.cs`
- [Embed token service](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/EmbedService.cs): `ContosoSalesDemo/Services/EmbedService.cs`
- [Report export service](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/ExportService.cs): `ContosoSalesDemo/Services/ExportService.cs`

### Identity services

- [Aad token service](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/AadService.cs): `ContosoSalesDemo/Services/AadService.cs`
- [JWT generation](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/JwtTokenService.cs): `ContosoSalesDemo/Services/JwtTokenService.cs`

### Sales data

- [Dataverse operations](https://github.com/microsoft/power-bi-embedded-contoso-sales-demo/blob/main/ContosoSalesDemo/Services/DataverseService.cs): `ContosoSalesDemo/Services/DataverseService.cs`

### Other components

- **Salesperson**
- **Power BI service**
- **Microsoft Dataverse**
- **Microsoft Entra ID**
- **Azure Key Vault**
- **MSAL.NET**

## Connections

- Salesperson → App routing: uses (evidence: `README.md`)
- App routing → Login and roles: shows when unauthenticated
- App routing → Embedded report page: renders (evidence: `ContosoSalesDemo/ClientApp/src/App.tsx`)
- Embedded report page → Power BI API: fetches embed params (evidence: `ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`)
- Power BI API → Embed token service: generates embed params (evidence: `ContosoSalesDemo/Controllers/PowerBiController.cs`)
- Embed token service → Power BI service: requests embed token (evidence: `ContosoSalesDemo/Services/EmbedService.cs`)
- Embedded report page → Visual layout: uses visual layouts (evidence: `ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`)
- Visual layout → Report configuration: reads configuration (evidence: `ContosoSalesDemo/ClientApp/src/components/VisualGroup.ts`)
- Embedded report page → Report personalization: renders controls (evidence: `ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`)
- Embedded report page → Bookmarks: renders list (evidence: `ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`)
- Embedded report page → Lead editing: renders edit form (evidence: `ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`)
- Embedded report page → Opportunity editing: supports editing (evidence: `ContosoSalesDemo/ClientApp/src/components/EmbedPage/EmbedPage.tsx`)
- Lead editing → Form submission: uses submission
- Opportunity editing → Form submission: uses submission (evidence: `ContosoSalesDemo/ClientApp/src/components/Forms/UpdateOpportunityForm.tsx`)
- Export controls → Power BI API: requests export
- Power BI API → Report export service: gets exported file (evidence: `ContosoSalesDemo/Controllers/PowerBiController.cs`)
- Report export service → Power BI service: exports report (evidence: `ContosoSalesDemo/Services/ExportService.cs`)
- Authentication API → JWT generation: generates token (evidence: `ContosoSalesDemo/Controllers/BasicAuthenticationController.cs`)
- Power BI API → Dataverse API: routes edits
- Dataverse API → Dataverse operations: delegates operations (evidence: `ContosoSalesDemo/Controllers/DataverseController.cs`)
- Dataverse operations → Microsoft Dataverse: reads and writes (evidence: `ContosoSalesDemo/Services/DataverseService.cs`)
- Embed token service → Aad token service: gets access token (evidence: `ContosoSalesDemo/Services/EmbedService.cs`)
- Report export service → Aad token service: gets access token (evidence: `ContosoSalesDemo/Services/ExportService.cs`)
- Dataverse operations → Aad token service: gets access token (evidence: `ContosoSalesDemo/Services/DataverseService.cs`)
- Aad token service → MSAL.NET: acquires token (evidence: `ContosoSalesDemo/Services/AadService.cs`)
- JWT generation → Azure Key Vault: signs JWT (evidence: `ContosoSalesDemo/Services/JwtTokenService.cs`)
- Aad token service → Microsoft Entra ID: authenticates service principal (evidence: `ContosoSalesDemo/Services/AadService.cs`)
