# ruiromano/pbip-demo architecture

> Architecture diagram of the GitHub repository ruiromano/pbip-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ruiromano/pbip-demo
- Repository: https://github.com/ruiromano/pbip-demo

## Overview

##### Project Type and Purpose
- This is a PBIP “folder‐based” Power BI project. It organizes two Semantic Models (Model01, Model02) and four Reports (Report01–Report04), and provides CI/CD pipelines and best-practice analysis.
- Purpose: manage Power BI artifacts (models, reports, themes) in source control, automate validation (BPA) and deploy to a Fabric workspace via REST APIs and fabric-cicd CLI.

##### File Structure
- Top-level:
– .bpa: best practice analysis scripts & data (bpa.ps1, JSON reports)
– .github/workflows: GitHub Actions (bpa.yml, deploy.yml)
– .resources: reusable themes and TMDL fragments
– Model01.SemanticModel & Model02.SemanticModel: folder-based PBIX definitions, TMDL files (tables, relationships, roles, perspectives)
– Report01.Report … Report04.Report: each report’s definition (.pbir), pages, visuals, static resources
– deploy.py: Python script for local deployment with fabric-cicd CLI
- Key patterns: Separation of semantic models vs reports; CI/CD via GitHub Actions; scripts for local invocation.

##### README Insights
- CI/CD instructions: service principal, secrets, fabric-cicd, REST API
- Two workflows: bpa (best practice analysis) & deploy (push content to Fabric)

##### Main Components
A. Source Control & CI/CD
1. GitHub Repository
2. GitHub Actions – bpa.yml (Best Practice Analysis)
3. GitHub Actions – deploy.yml (Deployment)
B. Scripts & CLIs
1. PowerShell script (.bpa/bpa.ps1)
2. Python script (deploy.py) & fabric-cicd CLI
C. Security / Credentials
1. Service Principal (client ID/secret/tenant) stored in GitHub Secrets
D. Power BI Artifacts
1. Semantic Models (Model01, Model02)
2. Reports (Report01–Report04)
3. Shared Resources (.resources folder)
E. Fabric Environment
1. Fabric CRUD REST API endpoints
2. Target Fabric Workspace (content endpoint)

##### Relationships & Data Flows
- Developer pushes code → GitHub Actions trigger
– bpa.yml runs bpa.ps1 → outputs rules report to .bpa/
– deploy.yml uses deploy.py + fabric-cicd → calls Fabric REST API using SP → uploads models & reports to workspace
- deploy.py (local) → fabric-cicd → Fabric REST API → workspace

##### Architectural Patterns & Principles
- Folder-based PBIP for modularity & source control
- Separation of concerns: models vs reports vs themes
- CI/CD pipelines for validation (BPA) and deployment
- Infrastructure as code style via fabric-cicd CLI and scripts

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Source Control & CI/CD"
    Repo["GitHub Repository"]:::sourcecontrol
    BPAWorkflow["bpa.yml"]:::cicd
    DeployWorkflow["deploy.yml"]:::cicd
  end

  subgraph "Validation"
    PScript["bpa.ps1"]:::script
    BPA_JSON1["bpa-rules-report.json"]:::artifacts
    BPA_JSON2["bpa-rules-semanticmodel.json"]:::artifacts
  end

  subgraph "Deployment"
    DeployScript["deploy.py"]:::script
    FabricCLI["fabric-cicd CLI"]:::script
    ServicePrincipal["Service Principal"]:::security
    RESTAPI["Fabric REST API"]:::services
    Workspace["Fabric Workspace"]:::services
  end

  subgraph "Artifacts"
    SharedResources[".resources"]:::artifacts
    Model01["Model01.SemanticModel"]:::artifacts
    Model02["Model02.SemanticModel"]:::artifacts
    Report01["Report01.Report"]:::artifacts
    Report02["Report02.Report"]:::artifacts
    Report03["Report03.Report"]:::artifacts
    Report04["Report04.Report"]:::artifacts
  end

  Repo -->|push triggers| BPAWorkflow
  Repo -->|push triggers| DeployWorkflow

  BPAWorkflow -->|runs| PScript
  PScript -->|outputs| BPA_JSON1
  PScript -->|outputs| BPA_JSON2

  DeployWorkflow -->|executes| DeployScript
  DeployWorkflow -->|invokes| FabricCLI
  DeployWorkflow -. uses secrets .-> ServicePrincipal

  DeployScript -->|calls| FabricCLI
  FabricCLI -->|calls| RESTAPI
  ServicePrincipal -->|authenticates| RESTAPI
  RESTAPI -->|deploys to| Workspace

  Report01 -->|references| Model01
  Report02 -->|references| Model01
  Report03 -->|references| Model01
  Report04 -->|references| Model02

  SharedResources --- Artifacts

  click BPAWorkflow "https://github.com/ruiromano/pbip-demo/blob/main/.github/workflows/bpa.yml"
  click DeployWorkflow "https://github.com/ruiromano/pbip-demo/blob/main/.github/workflows/deploy.yml"
  click PScript "https://github.com/ruiromano/pbip-demo/blob/main/.bpa/bpa.ps1"
  click BPA_JSON1 "https://github.com/ruiromano/pbip-demo/blob/main/.bpa/bpa-rules-report.json"
  click BPA_JSON2 "https://github.com/ruiromano/pbip-demo/blob/main/.bpa/bpa-rules-semanticmodel.json"
  click DeployScript "https://github.com/ruiromano/pbip-demo/blob/main/deploy.py"
  click SharedResources "https://github.com/ruiromano/pbip-demo/blob/main/.resources"
  click Model01 "https://github.com/ruiromano/pbip-demo/blob/main/Model01.SemanticModel"
  click Model02 "https://github.com/ruiromano/pbip-demo/blob/main/Model02.SemanticModel"
  click Report01 "https://github.com/ruiromano/pbip-demo/blob/main/Report01.Report"
  click Report02 "https://github.com/ruiromano/pbip-demo/blob/main/Report02.Report"
  click Report03 "https://github.com/ruiromano/pbip-demo/blob/main/Report03.Report"
  click Report04 "https://github.com/ruiromano/pbip-demo/blob/main/Report04.Report"

  classDef sourcecontrol fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
  classDef cicd fill:#E6FFEA,stroke:#28a745,color:#28a745;
  classDef script fill:#FFF5BA,stroke:#DAA520,color:#DAA520;
  classDef security fill:#FFE6E6,stroke:#d73a49,color:#d73a49;
  classDef services fill:#F3E8FF,stroke:#6f42c1,color:#6f42c1;
  classDef artifacts fill:#F2F2F2,stroke:#6a737d,color:#586069;
```
