# srajasimman/azure-web-app-bicep architecture

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

- Interactive diagram: https://gitdiagram.com/srajasimman/azure-web-app-bicep
- Repository: https://github.com/srajasimman/azure-web-app-bicep

## Overview

##### Project Type and Purpose
- This repository defines Azure infrastructure (using Bicep) to deploy a two-tier web application consisting of a static frontend and a .NET backend API.
- Purpose: Host a React-based static UI globally via Azure Front Door and run a .NET API with MySQL and object storage in Azure App Service, secured with Okta.

##### File Structure (omitting CI/CD pipelines)
- environments/dev & environments/prod: entry-point Bicep files and parameter sets per environment.
- modules/
- frontend: defines Azure Storage Account (static website) and Front Door.
- backend: defines App Service Plan + App Service, MySQL server, Storage Account (blobs).
- network: defines Virtual Network and subnet for App Service integration.
- security: defines Okta authentication and, in prod, Web Application Firewall rules.

##### Key Architecture Insights from README
- Frontend served from Azure Storage (static website) behind Azure Front Door for global HTTPs distribution.
- Backend: .NET API in App Service Plan, connected to:
- Azure Database for MySQL (persistent relational storage)
- Azure Storage Account for file/object storage
- Okta handles user authentication (OAuth/OIDC).
- Production adds a Web Application Firewall on Front Door.

##### Main Components
a. Frontend Layer
- Azure Storage Account (static website)
- Azure Front Door (global entry point, HTTPS, optional WAF)
b. Backend Layer
- Azure App Service Plan + App Service (host .NET API)
- Azure Database for MySQL
- Azure Storage Account (for blobs)
c. Network
- Virtual Network (App Subnet) linking App Service to protected resources
d. Security
- Okta authentication service (external identity provider)
- (Production only) Web Application Firewall on Front Door
e. Environment Overlays
- “Dev” vs “Prod” tiers differ in SKU sizes, redundancy, WAF enabled in Prod

##### Relationships and Data Flows
- User → Front Door → Storage Account (frontend assets)
- User → Front Door → App Service (API calls)
- App Service ↔ MySQL (data storage)
- App Service ↔ Storage Account (object store)
- App Service & Front Door validate tokens against Okta
- All components sit within or connect to a VNet/subnet for network isolation

##### Architectural Patterns & Principles
- Two-tier separation (static CDN-style frontend vs dynamic API backend)
- Infrastructure as Code (Bicep modules per layer)
- Environment promotion (dev ↔ prod parameterization)
- Defensive perimeter (Front Door + WAF in prod, VNet integration)
- Externalized identity (Okta) for SSO/OIDC

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    User["User"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FrontDoor["Azure Front Door"]:::network
        StaticStorage["Static Website Storage"]:::data
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        subgraph "Azure Network (VNet)"
            direction TB
            VNet["Virtual Network"]:::network
            AppSubnet["App Subnet"]:::network
            AppService["App Service Plan & .NET API"]:::compute
        end
        MySQLDB["Azure Database for MySQL"]:::data
        BlobStorage["Blob/Object Storage"]:::data
    end

    %% Security
    Okta["Okta Authentication (OIDC)"]:::external

    %% Environments
    subgraph "Environments"
        DevOverlay["Dev Environment Overlay"]:::network
        ProdOverlay["Prod Environment Overlay (WAF enabled)"]:::network
    end

    %% Connections
    User -->|"HTTPS"| FrontDoor
    FrontDoor -->|"Serves Static Assets"| StaticStorage
    FrontDoor -->|"Routes API Calls"| AppService
    FrontDoor -->|"Validates Token"| Okta
    AppService -->|"SQL over TLS"| MySQLDB
    AppService -->|"REST API (Blob) over HTTPS"| BlobStorage
    AppService -->|"Validates Token"| Okta
    AppService --- AppSubnet
    AppSubnet --- VNet

    %% Click Events
    click StaticStorage "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/frontend/storage-account.bicep"
    click FrontDoor "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/frontend/front-door.bicep"
    click AppService "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/backend/app-service.bicep"
    click MySQLDB "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/backend/mysql.bicep"
    click BlobStorage "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/backend/storage.bicep"
    click VNet "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/network/vnet.bicep"
    click AppSubnet "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/network/app-subnet.bicep"
    click Okta "https://github.com/srajasimman/azure-web-app-bicep/blob/main/modules/security/okta-authentication.bicep"
    click DevOverlay "https://github.com/srajasimman/azure-web-app-bicep/blob/main/environments/dev/main.bicep"
    click ProdOverlay "https://github.com/srajasimman/azure-web-app-bicep/blob/main/environments/prod/main.bicep"

    %% Styles
    classDef compute fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef data fill:#DFFFD0,stroke:#333,stroke-width:1px
    classDef network fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef external fill:#E1D5E7,stroke:#333,stroke-width:1px
```
