# ppenumatsa1/poc-insurance-quotes architecture

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

- Interactive diagram: https://gitdiagram.com/ppenumatsa1/poc-insurance-quotes
- Repository: https://github.com/ppenumatsa1/poc-insurance-quotes

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Insurance Quotes”) with:
- A React SPA frontend
- An ASP.NET Core 8.0 REST API backend
- Azure infrastructure defined via Bicep
- GitHub CI/CD for both frontend and backend
- Purpose: allow users to fetch auto insurance quotes via authenticated API calls, deployable to Azure.

##### File Structure
- frontend/InsuranceQuotes.UI → React app (public, src, AuthProvider, components)
- backend/InsuranceQuotes.Api → ASP.NET Core API (Controllers, Models, Services)
- infra/ → Bicep templates for Azure resources (app services, key vault, monitoring)
- .github/workflows → CI pipelines for backend and frontend

##### README for Additional Insights
- Azure AD integration (Entra ID) for auth (client and API apps)
- Swagger UI for API docs
- Azure Developer CLI (azd) used for unified provisioning & deployment

##### Main Components
a. Presentation Tier
- React SPA (InsuranceQuotes.UI)
- AuthProvider handling Azure AD tokens
b. API Tier
- ASP.NET Core API (QuotesController)
- QuoteService (business logic)
- Quote model
c. Authentication & Authorization
- Microsoft Entra ID (Azure AD)
d. Infrastructure & Deployment
- Azure Static Web App (hosts React)
- Azure App Service (hosts API)
- App Service Plan
- Azure Key Vault (stores secrets/app settings)
- Application Insights (monitoring)
- Bicep templates (infra as code)
e. DevOps
- GitHub Actions (frontend-ci.yml, backend-ci.yml)
- Azure Developer CLI (azd)

##### Relationships and Data Flow
- User → React app (HTTPS)
- React app ↔ Azure AD (OpenID Connect / OAuth2) for tokens
- React app → API (HTTPS + Bearer token)
- API → Key Vault (for any secret retrieval)
- API → (In-memory or persisted) Quote data via QuoteService
- GitHub Actions → Azure (CI/CD pipelines)

##### Architectural Patterns & Principles
- Layered architecture in the API (Controllers → Services → Models)
- SPA + API separation
- Infrastructure as Code (Bicep)
- CI/CD with GitHub Actions
- Externalized configuration (appsettings.json, .env for frontend)
- Dev/prod environment isolation via azd environments

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Tier
    subgraph "Presentation Tier"
        SPA["React SPA"]:::front
        AuthProv["AuthProvider"]:::front
        QuoteCard["QuoteCard Component"]:::front
        SPAEntry["SPA Entry Point"]:::front
        SPAConfig["SPA Configuration"]:::front
        PublicConfig["Static Web App Config"]:::front
    end

    %% API Tier
    subgraph "API Tier"
        API["ASP.NET Core API"]:::api
        QuotesCtrl["QuotesController"]:::api
        QuoteSvc["QuoteService"]:::api
        QuoteModel["Quote Model"]:::api
        APIConfig["API Configuration"]:::api
        EnvExample["Env Variables Example"]:::api
    end

    %% External Auth
    AzureAD["Microsoft Entra ID (Azure AD)"]:::infra

    %% Infrastructure
    subgraph "Infrastructure"
        IaC["Bicep Main Template"]:::infra
        BicepApi["API App Bicep"]:::infra
        BicepWeb["Web App Bicep"]:::infra
        BicepPlan["App Service Plan Bicep"]:::infra
        BicepKV["Key Vault Bicep"]:::infra
        BicepMonitor["Monitoring Bicep"]:::infra
        Swa["Azure Static Web App"]:::infra
        AppSvc["Azure App Service"]:::infra
        Plan["App Service Plan"]:::infra
        KeyVault["Azure Key Vault"]:::infra
        Insights["Application Insights"]:::infra
    end

    %% DevOps
    subgraph "DevOps"
        GHFront["GitHub Actions - Frontend CI/CD"]:::devops
        GHBack["GitHub Actions - Backend CI/CD"]:::devops
        Azd["Azure Developer CLI (azd)"]:::devops
    end

    %% Data and Control Flows
    User[/"User"/] -->|Uses| SPA
    SPAEntry -->|Renders| SPA
    SPAEntry -->|Configures| SPAConfig
    SPAEntry -->|Initializes Auth| AuthProv
    SPAEntry -->|Displays| QuoteCard
    SPA -->|Requests Token| AzureAD
    AuthProv -->|Fetches Token| AzureAD
    SPA -->|Calls API| API
    API -->|Retrieves Secret| KeyVault
    API -->|Sends Telemetry| Insights
    QuotesCtrl -->|Invokes| QuoteSvc
    QuoteSvc -->|Uses Model| QuoteModel
    API -->|Loads Config| APIConfig
    API -->|Loads Env Vars| EnvExample

    IaC -->|Deploys| BicepApi
    IaC -->|Deploys| BicepWeb
    IaC -->|Deploys| BicepPlan
    IaC -->|Deploys| BicepKV
    IaC -->|Deploys| BicepMonitor
    IaC -->|Provisions| Swa
    IaC -->|Provisions| AppSvc
    IaC -->|Creates| Plan
    IaC -->|Creates| KeyVault
    IaC -->|Creates| Insights

    GHFront -->|CI/CD| IaC
    GHBack -->|CI/CD| IaC
    Azd -->|Orchestrates| IaC

    %% Click Events
    click SPA "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/frontend/InsuranceQuotes.UI"
    click AuthProv "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/frontend/InsuranceQuotes.UI/src/AuthProvider.js"
    click QuoteCard "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/frontend/InsuranceQuotes.UI/src/components/QuoteCard.js"
    click SPAEntry "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/frontend/InsuranceQuotes.UI/src/index.js"
    click SPAConfig "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/frontend/InsuranceQuotes.UI/src/authConfig.js"
    click PublicConfig "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/frontend/InsuranceQuotes.UI/public/staticwebapp.config.json"
    click API "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/backend/InsuranceQuotes.Api"
    click QuotesCtrl "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/backend/InsuranceQuotes.Api/Controllers/QuotesController.cs"
    click QuoteSvc "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/backend/InsuranceQuotes.Api/Services/QuoteService.cs"
    click QuoteModel "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/backend/InsuranceQuotes.Api/Models/Quote.cs"
    click APIConfig "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/backend/InsuranceQuotes.Api/appsettings.json"
    click EnvExample "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/backend/InsuranceQuotes.Api/.env.example"
    click IaC "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/infra/main.bicep"
    click BicepApi "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/infra/app/api.bicep"
    click BicepWeb "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/infra/app/web.bicep"
    click BicepPlan "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/infra/core/host/appserviceplan.bicep"
    click BicepKV "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/infra/core/security/keyvault.bicep"
    click BicepMonitor "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/infra/core/monitor/monitoring.bicep"
    click GHFront "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/.github/workflows/frontend-ci.yml"
    click GHBack "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/.github/workflows/backend-ci.yml"
    click Azd "https://github.com/ppenumatsa1/poc-insurance-quotes/blob/main/azure.yaml"

    %% Styles
    classDef front fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef api fill:#d4edda,stroke:#333,stroke-width:1px
    classDef infra fill:#d1ecf1,stroke:#333,stroke-width:1px
    classDef devops fill:#ffe5b4,stroke:#333,stroke-width:1px
```
