# johnpapa/shopathome architecture

> Architecture diagram of the GitHub repository johnpapa/shopathome, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/johnpapa/shopathome
- Repository: https://github.com/johnpapa/shopathome

## Overview

##### Project type and purpose
- This is a full-stack sample “Shop at Home” mono-repo demonstrating four interchangeable frontends (Angular, React, Svelte, Vue) each hosted on Azure Static Web Apps, plus two backend API options (Azure Functions and Fastify REST server deployed to Azure Container Apps).
- Purpose: show how to build, run, and deploy a shopping list application using different JS frameworks and two API hosting models.

##### File structure
- Top level:
- .github/workflows – CI/CD pipelines for each frontend via Azure Static Web Apps
- .devcontainer, .vscode – local dev environments
- angular-app, react-app, svelte-app, vue-app – four independent frontends, each structured per framework conventions
- api – Azure Functions project (Node.js) under “api” folder
- fastify-api-server – standalone Fastify server project
- Patterns:
- Frontends all share common components: auth login/logout, header, nav, products and discounts pages, staticwebapp.config.json for routing to /api/*
- API projects share data modules in /shared (product-data.js, discount-data.js, models.js)
- Deployment: GitHub Actions workflows push frontends to Azure Static Web Apps; Fastify server containerized and deployed to Azure Container Apps; Functions app runs under the same Static Web App.

##### Extract README insights
- Describes how to run locally with SWA CLI (frontends + Functions)
- Two backend choices: Azure Functions (in‐repo) or Fastify server (container)
- Hosts frontends at angular.shopathome.dev, react.shopathome.dev, etc.
- API endpoints: /api/products, /api/discounts (GET/POST/PUT/DELETE)

a. Main components (group into layers):
1. Presentation Layer
– Four separate SPA apps (Angular, React, Svelte, Vue)
– Each deployed as Azure Static Web App
2. API Layer
– Azure Functions App (Node.js) under /api
– Fastify Container App (Node.js) under fastify-api-server
3. Data Layer
– In-memory sample data modules (product-data, discount-data)
– Shared models (models.js)
4. DevOps/CICD
– GitHub Actions workflows per frontend
– SWA CLI for local emulation
5. Cloud Infrastructure
– Azure Static Web Apps (hosting SPAs + Functions API)
– Azure Container Apps (hosting Fastify API)
b. Relationships & interactions:
– User browser → (HTTPS) → Static Web App (serves SPA assets)
– SPA makes REST calls to /api/*
– Azure Static Web Apps proxies /api/* calls to either Functions App or Container App endpoint
– API reads/writes data via shared modules (in memory) and returns JSON
c. Architectural patterns / design principles:
– Single-page app frontends with clear separation from backend
– API abstraction layer, RESTful endpoints for product and discount resources
– Mono-repo structure to compare multiple frameworks side by side
– Infrastructure as code via GitHub Actions YAML workflows
d. Key technologies / frameworks:
– Angular CLI, React (Create React App), Svelte (Rollup/Vite), Vue CLI/Vite
– Azure Static Web Apps + SWA CLI
– Azure Functions (JavaScript)
– Fastify (Node.js server framework)
– GitHub Actions for CI/CD

## Diagram (Mermaid)

```mermaid
graph TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["User Browser"] 
        AngularSPA["Angular SPA\n(Azure Static Web Apps)"]:::frontend
        ReactSPA["React SPA\n(Azure Static Web Apps)"]:::frontend
        SvelteSPA["Svelte SPA\n(Azure Static Web Apps)"]:::frontend
        VueSPA["Vue SPA\n(Azure Static Web Apps)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        AzureFunctions["Azure Functions App\n(Node.js)"]:::api
        FastifyAPI["Fastify REST API\n(Node.js Container)"]:::api
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DataFunctions["In-memory Data Modules\n(product-data.js, discount-data.js)"]:::data
        DataFastify["In-memory Data Modules\n(product-data.js, discount-data.js)"]:::data
    end

    %% DevOps / CI-CD
    subgraph "DevOps / CI-CD"
        direction TB
        GitHubActions["GitHub Actions\nworkflows"]:::devops
        SWACLI["SWA CLI\n(local emulation)"]:::devops
        DevContainer[".devcontainer\n(Docker + config)"]:::devops
        VSCode[".vscode\n(Workspace settings)"]:::devops
    end

    %% Cloud Infrastructure
    subgraph "Cloud Infrastructure"
        direction TB
        StaticWebApps["Azure Static Web Apps\n(host SPAs + Functions)"]:::cloud
        ContainerApps["Azure Container Apps\n(host Fastify)"]:::cloud
    end

    %% Relationships
    Browser -->|"HTTPS"| AngularSPA
    Browser -->|"HTTPS"| ReactSPA
    Browser -->|"HTTPS"| SvelteSPA
    Browser -->|"HTTPS"| VueSPA

    AngularSPA -->|"GET/POST /api/*"| StaticWebApps
    ReactSPA -->|"GET/POST /api/*"| StaticWebApps
    SvelteSPA -->|"GET/POST /api/*"| StaticWebApps
    VueSPA -->|"GET/POST /api/*"| StaticWebApps

    StaticWebApps -->|"Proxy /api/*"| AzureFunctions
    StaticWebApps -->|"Proxy /api/*"| ContainerApps

    AzureFunctions -->|"uses"| DataFunctions
    FastifyAPI -->|"uses"| DataFastify

    ContainerApps -->|"hosts"| FastifyAPI

    GitHubActions --> AngularSPA
    GitHubActions --> ReactSPA
    GitHubActions --> SvelteSPA
    GitHubActions --> VueSPA
    GitHubActions --> FastifyAPI

    SWACLI --> AzureFunctions
    SWACLI --> AngularSPA
    SWACLI --> ReactSPA
    SWACLI --> SvelteSPA
    SWACLI --> VueSPA

    DevContainer --> AngularSPA
    DevContainer --> AzureFunctions

    VSCode --> DevContainer

    StaticWebApps --> AzureFunctions
    ContainerApps --> FastifyAPI

    %% Click Events
    click AngularSPA "https://github.com/johnpapa/shopathome/tree/main/angular-app/"
    click ReactSPA "https://github.com/johnpapa/shopathome/tree/main/react-app/"
    click SvelteSPA "https://github.com/johnpapa/shopathome/tree/main/svelte-app/"
    click VueSPA "https://github.com/johnpapa/shopathome/tree/main/vue-app/"
    click AzureFunctions "https://github.com/johnpapa/shopathome/tree/main/api/"
    click FastifyAPI "https://github.com/johnpapa/shopathome/tree/main/fastify-api-server/"
    click DataFunctions "https://github.com/johnpapa/shopathome/tree/main/api/shared/"
    click DataFastify "https://github.com/johnpapa/shopathome/tree/main/fastify-api-server/src/shared/"
    click GitHubActions "https://github.com/johnpapa/shopathome/tree/main/.github/workflows/"
    click DevContainer "https://github.com/johnpapa/shopathome/tree/main/.devcontainer/"
    click VSCode "https://github.com/johnpapa/shopathome/tree/main/.vscode/"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px
    classDef api fill:#90ee90,stroke:#000,stroke-width:1px
    classDef data fill:#ffcc99,stroke:#000,stroke-width:1px
    classDef devops fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef cloud fill:#d8bfd8,stroke:#000,stroke-width:1px
```
