# demz20/azuremediaservicesmvc architecture

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

- Interactive diagram: https://gitdiagram.com/demz20/azuremediaservicesmvc
- Repository: https://github.com/demz20/azuremediaservicesmvc

## Overview

##### Project type and purpose
- This is a full-stack ASP.NET MVC web application that demonstrates end-to-end video upload, encoding, and playback using Azure Media Services.
- Users authenticate via ASP.NET Identity, upload videos through the MVC site, and the app uses Azure Media Services SDK to store, encode, and stream videos.

##### File structure
- Top-level project “AzureMediaServiceMVC” contains the usual MVC folders:
- Controllers (AccountController, HomeController, ManageController, VideoController)
- Models (AspNetIdentity plus Azure Media Services entities & context)
- Views (Account, Home, Manage, Video + shared layouts)
- Scripts & Content (JS libraries, CSS, jQuery UI themes)
- App_Start (authentication & routing configuration)
- Configuration files (Web.config, BundleConfig, Startup.Auth, MediaServicesCustomPreset.xml)
- There is no separate backend service or microservice—everything lives in one IIS-hosted MVC app.
- External dependency: Azure Media Services (and underlying Blob Storage), plus a local/remote SQL database for Identity.

##### README for additional insights
- Purpose: upload videos, show upload progress, show encoding jobs, play videos when ready.
- The demo uses Azure Media Encoder presets (MediaServicesCustomPreset.xml) to transcode uploads.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        UploadScript["azure-media-services-upload.js"]:::frontend
        Content["Site.css, bootstrap.css, themes"]:::frontend
        ViewsClient["Views (*.cshtml)"]:::frontend
    end

    %% Web Application Layer
    subgraph "Web Application (IIS-hosted ASP.NET MVC)" 
        direction TB
        subgraph "UI Layer"
            direction TB
            Views["Razor Views"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AccountController["AccountController"]:::backend
            HomeController["HomeController"]:::backend
            ManageController["ManageController"]:::backend
            VideoController["VideoController"]:::backend
        end
        subgraph "Business & Data Models"
            direction TB
            subgraph "ASP.NET Identity Models"
                IdentityModels["IdentityModels.cs"]:::backend
                AccountViewModels["AccountViewModels.cs"]:::backend
                ManageViewModels["ManageViewModels.cs"]:::backend
                IdentityConfig["IdentityConfig.cs"]:::backend
                StartupOWIN["Startup.cs"]:::backend
            end
            subgraph "Azure Media Services SDK"
                AMSContext["AzureMediaServicesContext.cs"]:::backend
                AzureMediaAsset["AzureMediaAsset.cs"]:::backend
                CloudFile["CloudFile.cs"]:::backend
                VideoModel["Video.cs"]:::backend
                VideoViewModel["VideoViewModel.cs"]:::backend
                TokenResult["TokenResult.cs"]:::backend
            end
        end
        subgraph "Configuration & Startup"
            direction TB
            BundleConfig["BundleConfig.cs"]:::backend
            RouteConfig["RouteConfig.cs"]:::backend
            FilterConfig["FilterConfig.cs"]:::backend
            AuthConfig["Startup.Auth.cs"]:::backend
            Preset["MediaServicesCustomPreset.xml"]:::backend
            WebConfig["Web.config"]:::backend
            GlobalApp["Global.asax.cs"]:::backend
            ProjectFile["AzureMediaServiceMVC.csproj"]:::backend
            Solution["AzureMediaServicesDemo.sln"]:::backend
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SQLDB[(SQL Database)]:::database
        subgraph "Azure Media Services" 
            direction TB
            BlobStorage[(Blob Storage)]:::azure
            Encoder["Media Encoder"]:::azure
            Streaming["Streaming Endpoint"]:::azure
        end
    end

    %% Data Flows
    UploadScript -->|"requests UI"| Views
    Content --> Views
    ViewsClient --> Views
    Views -->|"HTTP Requests"| AccountController
    Views -->|"HTTP Requests"| HomeController
    Views -->|"HTTP Requests"| ManageController
    Views -->|"HTTP Requests"| VideoController

    AccountController -->|"Identity operations"| IdentityModels
    HomeController -->|"reads data"| AMSContext
    ManageController -->|"manages user data"| IdentityModels
    VideoController -->|"upload & encode"| AMSContext

    AccountController -->|"reads/writes"| SQLDB
    ManageController -->|"reads/writes"| SQLDB

    VideoController -->|"CreateAsset & Locator"| BlobStorage
    VideoController -->|"Submit Encoding Job"| Encoder
    VideoController -.->|"Poll Job Status"| Encoder
    Encoder -->|"Outputs encoded asset"| BlobStorage
    VideoController -->|"Fetch Streaming URL"| Streaming

    VideoController -->|"returns URL via AJAX"| UploadScript
    UploadScript -->|"embed player"| Streaming

    %% Click Events
    click UploadScript "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Scripts/azure-media-services-upload.js"
    click Content "https://github.com/demz20/azuremediaservicesmvc/tree/master/AzureMediaServiceMVC/Content"
    click ViewsClient "https://github.com/demz20/azuremediaservicesmvc/tree/master/AzureMediaServiceMVC/Views"
    click AccountController "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Controllers/AccountController.cs"
    click HomeController "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Controllers/HomeController.cs"
    click ManageController "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Controllers/ManageController.cs"
    click VideoController "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Controllers/VideoController.cs"
    click IdentityModels "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/AspNetIdentity/IdentityModels.cs"
    click AccountViewModels "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/AspNetIdentity/AccountViewModels.cs"
    click ManageViewModels "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/AspNetIdentity/ManageViewModels.cs"
    click IdentityConfig "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/App_Start/IdentityConfig.cs"
    click StartupOWIN "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Startup.cs"
    click AMSContext "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/Azure/AzureMediaServicesContext.cs"
    click AzureMediaAsset "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/Azure/AzureMediaAsset.cs"
    click CloudFile "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/Azure/CloudFile.cs"
    click VideoModel "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/Azure/Video.cs"
    click VideoViewModel "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/Azure/VideoViewModel.cs"
    click TokenResult "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Models/Azure/TokenResult.cs"
    click BundleConfig "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/App_Start/BundleConfig.cs"
    click RouteConfig "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/App_Start/RouteConfig.cs"
    click FilterConfig "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/App_Start/FilterConfig.cs"
    click AuthConfig "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/App_Start/Startup.Auth.cs"
    click Preset "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/MediaServicesCustomPreset.xml"
    click WebConfig "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Web.config"
    click GlobalApp "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Global.asax.cs"
    click ProjectFile "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/AzureMediaServiceMVC.csproj"
    click Solution "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServicesDemo.sln"
    click JQueryUI "https://github.com/demz20/azuremediaservicesmvc/blob/master/AzureMediaServiceMVC/Scripts/jquery-ui-1.12.1.js"

    %% Styles
    classDef frontend fill:#D6E9FE,stroke:#4B8FBD
    classDef backend fill:#C8E6C9,stroke:#388E3C
    classDef azure fill:#E8F5E9,stroke:#2E7D32
    classDef database fill:#FFF3E0,stroke:#FB8C00
```
