# fahad09belal/apbnmessageportal architecture

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

- Interactive diagram: https://gitdiagram.com/fahad09belal/apbnmessageportal
- Repository: https://github.com/fahad09belal/apbnmessageportal

## Overview

The tree suggests a web-based squad message portal, with account-deletion endpoints and a service worker for push notifications. The main page and database schema are present but not excerpted, and the README is empty, so the portal’s message workflow and schema details cannot be mapped reliably. The account endpoints verify sessions with Supabase Auth; admin deletion additionally checks a profile’s role and ban status. Deleting an account is documented to cascade to messages. Edges show only relationships evidenced by excerpts.

Main entry points: [`sw.js`](https://github.com/fahad09belal/apbnmessageportal/blob/main/sw.js) (Push service worker), [`supabase/functions/delete-account/index.ts`](https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/functions/delete-account/index.ts) (Delete own account), [`supabase/functions/admin-delete-user/index.ts`](https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/functions/admin-delete-user/index.ts) (Admin user deletion), [`supabase/schema.sql`](https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/schema.sql) (Profiles and messages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Portal"]
  node_webapp["Web portal<br/>[index.html]"]
end

subgraph group_accounts["Account management"]
  node_delete_account["Delete own account<br/>[index.ts]"]
  node_admin_delete["Admin user deletion<br/>[index.ts]"]
  node_profiles[("Profiles and messages<br/>[schema.sql]")]
end

subgraph group_notifications["Notifications"]
  node_service_worker["Push service worker<br/>[sw.js]"]
end

node_user(("Portal user"))
node_supabase_auth["Supabase Auth"]
node_push_server["Push server"]
node_browser["Browser notifications"]

node_delete_account -->|"validates and deletes"| node_supabase_auth
node_admin_delete -->|"validates and deletes"| node_supabase_auth
node_admin_delete -->|"checks admin role"| node_profiles
node_delete_account -->|"deletion cascades"| node_profiles
node_push_server -.->|"sends push"| node_service_worker
node_service_worker -->|"shows notification"| node_browser
node_browser -->|"clicks notification"| node_service_worker
node_service_worker -->|"focuses or opens"| node_webapp

click node_webapp "https://github.com/fahad09belal/apbnmessageportal/blob/main/index.html"
click node_delete_account "https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/functions/delete-account/index.ts"
click node_admin_delete "https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/functions/admin-delete-user/index.ts"
click node_profiles "https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/schema.sql"
click node_service_worker "https://github.com/fahad09belal/apbnmessageportal/blob/main/sw.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_webapp,node_user,node_browser toneBlue
class node_delete_account,node_admin_delete,node_profiles toneAmber
class node_service_worker,node_push_server toneMint
class node_supabase_auth toneIndigo
```

## Components

### Portal

- [Web portal](https://github.com/fahad09belal/apbnmessageportal/blob/main/index.html): `index.html`

### Account management

- [Delete own account](https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/functions/delete-account/index.ts): `supabase/functions/delete-account/index.ts`
- [Admin user deletion](https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/functions/admin-delete-user/index.ts): `supabase/functions/admin-delete-user/index.ts`
- [Profiles and messages](https://github.com/fahad09belal/apbnmessageportal/blob/main/supabase/schema.sql): `supabase/schema.sql`

### Notifications

- [Push service worker](https://github.com/fahad09belal/apbnmessageportal/blob/main/sw.js): `sw.js`

### Other components

- **Portal user**
- **Supabase Auth**
- **Push server**
- **Browser notifications**

## Connections

- Delete own account → Supabase Auth: validates and deletes (evidence: `supabase/functions/delete-account/index.ts`)
- Admin user deletion → Supabase Auth: validates and deletes (evidence: `supabase/functions/admin-delete-user/index.ts`)
- Admin user deletion → Profiles and messages: checks admin role (evidence: `supabase/functions/admin-delete-user/index.ts`)
- Delete own account → Profiles and messages: deletion cascades (evidence: `supabase/functions/delete-account/index.ts`)
- Push server → Push service worker: sends push
- Push service worker → Browser notifications: shows notification (evidence: `sw.js`)
- Browser notifications → Push service worker: clicks notification (evidence: `sw.js`)
- Push service worker → Web portal: focuses or opens (evidence: `sw.js`)
