# betaflag/react-push-notification-demo architecture

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

- Interactive diagram: https://gitdiagram.com/betaflag/react-push-notification-demo
- Repository: https://github.com/betaflag/react-push-notification-demo

## Overview

This repository is a React client and Node/Express server demo for browser push notifications. The user opens the client, which registers a push service worker, fetches the server’s VAPID public key, subscribes through the browser Push API, and posts the subscription to the server. Clicking “Trigger Notification” calls the server, which looks up that browser’s in-memory subscription and sends a push. The push worker displays the notification. The client also includes an optional, separately registered app service worker for caching/offline behavior. Edges reflect the shown source and README; the external push-delivery hop is implied, not shown.

Main entry points: [`server/server.js`](https://github.com/betaflag/react-push-notification-demo/blob/master/server/server.js) (Express API), [`client/src/pushServiceWorker.js`](https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/pushServiceWorker.js) (Push Registration), [`client/src/index.js`](https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/index.js) (Client Entry), [`client/src/App.js`](https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/App.js) (React App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_app["React App<br/>[App.js]"]
  node_entry["Client Entry<br/>[index.js]"]
  node_app_worker["App Service Worker<br/>[serviceWorker.js]"]
end

subgraph group_registration["Push Registration"]
  node_registration_flow["Push Registration"]
  node_push_worker["Push Service Worker"]
end

subgraph group_server["Push Server"]
  node_api["Express API<br/>[server.js]"]
  node_subscriptions[("Memory Subscriptions<br/>[server.js]")]
  node_vapid["VAPID Configuration<br/>[server.js]"]
end

subgraph group_delivery["Push Delivery"]
end

node_user(("User"))
node_browser["Browser APIs"]
node_push_service["Push Service"]

node_user -->|"uses"| node_app
node_entry -->|"renders"| node_app
node_entry -->|"unregisters"| node_app_worker
node_entry -->|"registers"| node_registration_flow
node_registration_flow -->|"registers worker"| node_browser
node_registration_flow -->|"fetches VAPID key"| node_api
node_api -->|"serves public key"| node_vapid
node_registration_flow -->|"subscribes"| node_browser
node_registration_flow -->|"posts subscription"| node_api
node_api -->|"stores subscription"| node_subscriptions
node_app -->|"requests notification"| node_api
node_api -->|"reads subscription"| node_subscriptions
node_api -->|"sends push"| node_push_service
node_push_service -.->|"delivers push"| node_push_worker
node_push_worker -->|"shows notification"| node_browser
node_app_worker -->|"uses service worker APIs"| node_browser

click node_app "https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/App.js"
click node_entry "https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/index.js"
click node_app_worker "https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/serviceWorker.js"
click node_registration_flow "https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/pushServiceWorker.js"
click node_push_worker "https://github.com/betaflag/react-push-notification-demo/blob/master/client/public/push-service-worker.js"
click node_api "https://github.com/betaflag/react-push-notification-demo/blob/master/server/server.js"
click node_subscriptions "https://github.com/betaflag/react-push-notification-demo/blob/master/server/server.js"
click node_vapid "https://github.com/betaflag/react-push-notification-demo/blob/master/server/server.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_entry,node_app_worker,node_user,node_browser toneBlue
class node_registration_flow,node_push_worker toneAmber
class node_api,node_subscriptions,node_vapid toneMint
class node_push_service toneIndigo
```

## Components

### React Client

- [React App](https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/App.js): `client/src/App.js`
- [Client Entry](https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/index.js): `client/src/index.js`
- [App Service Worker](https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/serviceWorker.js): `client/src/serviceWorker.js`

### Push Registration

- [Push Registration](https://github.com/betaflag/react-push-notification-demo/blob/master/client/src/pushServiceWorker.js): `client/src/pushServiceWorker.js`
- [Push Service Worker](https://github.com/betaflag/react-push-notification-demo/blob/master/client/public/push-service-worker.js): `client/public/push-service-worker.js`

### Push Server

- [Express API](https://github.com/betaflag/react-push-notification-demo/blob/master/server/server.js): `server/server.js`
- [Memory Subscriptions](https://github.com/betaflag/react-push-notification-demo/blob/master/server/server.js): `server/server.js`
- [VAPID Configuration](https://github.com/betaflag/react-push-notification-demo/blob/master/server/server.js): `server/server.js`

### Other components

- **User**
- **Browser APIs**
- **Push Service**

## Connections

- User → React App: uses
- Client Entry → React App: renders (evidence: `client/src/index.js`)
- Client Entry → App Service Worker: unregisters (evidence: `client/src/index.js`)
- Client Entry → Push Registration: registers (evidence: `client/src/index.js`)
- Push Registration → Browser APIs: registers worker (evidence: `client/src/pushServiceWorker.js`)
- Push Registration → Express API: fetches VAPID key (evidence: `client/src/pushServiceWorker.js`)
- Express API → VAPID Configuration: serves public key (evidence: `server/server.js`)
- Push Registration → Browser APIs: subscribes (evidence: `client/src/pushServiceWorker.js`)
- Push Registration → Express API: posts subscription (evidence: `client/src/pushServiceWorker.js`)
- Express API → Memory Subscriptions: stores subscription (evidence: `server/server.js`)
- React App → Express API: requests notification (evidence: `client/src/App.js`)
- Express API → Memory Subscriptions: reads subscription (evidence: `server/server.js`)
- Express API → Push Service: sends push (evidence: `server/server.js`)
- Push Service → Push Service Worker: delivers push
- Push Service Worker → Browser APIs: shows notification (evidence: `client/public/push-service-worker.js`)
- App Service Worker → Browser APIs: uses service worker APIs (evidence: `client/src/serviceWorker.js`)
