# wanderson304/script-zeus-365 architecture

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

- Interactive diagram: https://gitdiagram.com/wanderson304/script-zeus-365
- Repository: https://github.com/wanderson304/script-zeus-365

## Overview

##### Project type and purpose
- From the README and file tree, “Script Zeus 365” is an open-source PowerShell administrative tool (packaged as Script-Zeus.rar) for Microsoft 365.
- Its purpose is to let a 365 administrator select reporting modules (SharePoint, Exchange, Teams, Entra ID), authenticate via Microsoft Graph, pull data, and export formatted CSVs and dashboards via Excel/Power Query.

##### File structure
- Top-level: LICENSE, README.md, Script-Zeus.rar
- A main driver script (e.g., Main.ps1) that presents a console menu
- Subfolders or .ps1 modules for each service (SharePoint, Exchange, Teams, Entra ID)
- Common utilities for Graph authentication (token management), CSV export, logging
- Possibly config files for tenant/app registration (client ID, scopes)

##### README for additional insights
- Requirements: PowerShell 7+, Excel 2016+ (Power Query)
- Migration note: switched from MSOnline module to MS Graph PowerShell
- Workflow: choose module → connect to 365 resources → export CSVs → generate dashboard

##### Components & Interactions
a. Main components
- User (365 Administrator)
- PowerShell runtime (v7+)
- Script core (Main.ps1 / entry point)
- Module components:
- SharePoint Reports Module
- Exchange Reports Module
- Teams Reports Module
- Entra ID Reports Module
- Auth component (Graph Authentication / Token Cache)
- Microsoft Graph API (cloud endpoint)
- Data stores / outputs: CSV files in file system
- Excel (Power Query dashboard consumer)

b. Relationships / data flow
1. Admin invokes the PowerShell script in the console.
2. Main.ps1 loads configuration and displays menu.
3. Upon user selection, Main.ps1 calls the chosen module.
4. Module uses the Auth component to obtain a Graph access token (OAuth2 device code or interactive).
5. Module issues HTTP requests to Microsoft Graph endpoints (e.g., /sites, /groups, /teams, /users)
6. Graph returns JSON datasets.
7. Module parses JSON, formats into tabular objects, calls CSV-export utility.
8. CSV files land on disk.
9. (Optional) Excel Power Query opens CSVs, builds an automatic dashboard.

c. Architectural patterns / design principles
- Modular design: each service has its own .ps1 module
- Single responsibility: Auth, API calls, data formatting, CSV export separated
- Reusable utilities: token management, logging, CSV writer
- Interactive CLI UI for orchestration

d. Key technologies & libraries
- PowerShell 7+ core scripting
- Microsoft.Graph PowerShell SDK (Graph PowerShell modules)
- CSV file I/O (Import-Csv / Export-Csv)
- Excel Power Query (for dashboard)
- OAuth2 device code / interactive authentication

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and UI
    Admin["365 Administrator"]:::user
    CLI["PowerShell CLI"]:::user

    Admin -->|"invoke script"| CLI
    CLI -->|"starts"| Core

    %% Core and Config
    Core["Script Core\n(Main.ps1)"]:::script
    Config["Configuration File\n(Settings.json)"]:::util

    Core -->|"load config"| Config
    Core -->|"display menu"| Modules

    %% Modules Subgraph
    subgraph "Report Modules"
        direction TB
        SP["SharePoint Reports Module"]:::script
        EX["Exchange Reports Module"]:::script
        TE["Teams Reports Module"]:::script
        EN["Entra ID Reports Module"]:::script
    end

    Core -->|"select module"| SP
    Core -->|"select module"| EX
    Core -->|"select module"| TE
    Core -->|"select module"| EN

    %% Utilities and Services
    Auth["Auth Utility\n(Token Management)"]:::util
    CsvUtil["CSV Export Utility"]:::util
    LogUtil["Logging Utility"]:::util
    GraphAPI["Microsoft Graph API"]:::external

    SP -->|"Authenticate"| Auth
    EX -->|"Authenticate"| Auth
    TE -->|"Authenticate"| Auth
    EN -->|"Authenticate"| Auth

    Auth -->|"OAuth2 Device Code / Interactive"| GraphAPI
    GraphAPI -->|"returns JSON"| Auth

    SP -->|"GET /sites, /lists"| GraphAPI
    EX -->|"GET /mail, /groups"| GraphAPI
    TE -->|"GET /teams, /channels"| GraphAPI
    EN -->|"GET /users, /roles"| GraphAPI

    SP -->|"Export-CSV"| CsvUtil
    EX -->|"Export-CSV"| CsvUtil
    TE -->|"Export-CSV"| CsvUtil
    EN -->|"Export-CSV"| CsvUtil

    SP -->|"Log actions"| LogUtil
    EX -->|"Log actions"| LogUtil
    TE -->|"Log actions"| LogUtil
    EN -->|"Log actions"| LogUtil

    CsvUtil -->|"writes"| CSVStore["CSV Files"]:::datastore
    CSVStore -->|"consumed by"| Excel["Excel Power Query Dashboard"]:::external

    %% Documentation
    README["README.md"]:::util
    LICENSE["LICENSE"]:::util

    %% Click Events
    click Core "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Main.ps1"
    click SP "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Modules/SharePointReports.ps1"
    click EX "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Modules/ExchangeReports.ps1"
    click TE "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Modules/TeamsReports.ps1"
    click EN "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Modules/EntraIDReports.ps1"
    click Auth "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Utils/Auth.ps1"
    click CsvUtil "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Utils/CsvExport.ps1"
    click LogUtil "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Utils/Logging.ps1"
    click Config "https://github.com/wanderson304/script-zeus-365/blob/main/Script-Zeus.rar/Config/Settings.json"
    click README "https://github.com/wanderson304/script-zeus-365/blob/main/README.md"
    click LICENSE "https://github.com/wanderson304/script-zeus-365/tree/main/LICENSE"

    %% Styles
    classDef user fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef script fill:#D9F7BE,stroke:#22863A,color:#22863A
    classDef util fill:#E3FCEF,stroke:#2EA043,color:#2EA043
    classDef external fill:#FFE7BA,stroke:#D18616,color:#D18616
    classDef datastore fill:#F0F0F0,stroke:#6A737D,color:#6A737D
```
