# afsallais/trash-removal architecture

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

- Interactive diagram: https://gitdiagram.com/afsallais/trash-removal
- Repository: https://github.com/afsallais/trash-removal

## Overview

Trash-Removal is a small household web app for tracking weekly kitchen-trash duty, with a Firebase notification backend. The README does not identify which HTML page is the primary interface or describe its data flow, so the page variants are shown without inferred links to backend records. The sampled backend shows Firestore-triggered alert and duty notifications, a scheduled pending-alert fallback, and background push display; frontend-to-Firestore wiring is not shown.

Main entry points: [`functions/index.js`](https://github.com/afsallais/trash-removal/blob/main/functions/index.js) (Notification jobs), [`functions/process-pending-alerts.js`](https://github.com/afsallais/trash-removal/blob/main/functions/process-pending-alerts.js) (Pending alert poller), [`index.html`](https://github.com/afsallais/trash-removal/blob/main/index.html) (Web page), [`index4.html`](https://github.com/afsallais/trash-removal/blob/main/index4.html) (Dashboard page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_household["Household interfaces"]
  node_main_page["Web page<br/>[index.html]"]
  node_dashboard_page["Dashboard page<br/>[index4.html]"]
  node_mobile_page["Mobile page<br/>[mobile.html]"]
  node_tv_page["TV page<br/>[tv.html]"]
end

subgraph group_firebase["Firebase backend"]
  node_firestore[("Firestore")]
  node_event_handlers["Firestore handlers<br/>[index.js]"]
  node_alert_creation["Trash alert<br/>[index.js]"]
  node_alert_cancellation["Alert cancellation<br/>[index.js]"]
  node_duty_completion["Duty completion<br/>[index.js]"]
  node_device_lookup["Device lookup<br/>[index.js]"]
  node_job_claim["Notification jobs<br/>[index.js]"]
  node_pending_poller["Pending alert poller"]
end

subgraph group_push["Push notifications"]
  node_fcm["Firebase Cloud Messaging"]
  node_service_worker["Background push display"]
end

node_household_user(("Household user"))

node_household_user -->|"uses"| node_main_page
node_household_user -->|"uses"| node_dashboard_page
node_household_user -->|"uses"| node_mobile_page
node_household_user -->|"uses"| node_tv_page
node_firestore -->|"dispatches events"| node_event_handlers
node_event_handlers -->|"handles creation"| node_alert_creation
node_event_handlers -->|"handles updates"| node_alert_cancellation
node_event_handlers -->|"handles updates"| node_duty_completion
node_alert_creation -->|"finds recipients"| node_device_lookup
node_alert_cancellation -->|"finds recipients"| node_device_lookup
node_duty_completion -->|"finds recipients"| node_device_lookup
node_device_lookup -->|"reads devices"| node_firestore
node_alert_creation -->|"claims job"| node_job_claim
node_alert_cancellation -->|"claims job"| node_job_claim
node_duty_completion -->|"claims job"| node_job_claim
node_job_claim -->|"stores job state"| node_firestore
node_job_claim -->|"sends messages"| node_fcm
node_pending_poller -->|"reads alerts"| node_firestore
node_pending_poller -.->|"finds recipients"| node_device_lookup
node_pending_poller -->|"sends messages"| node_fcm
node_fcm -.->|"delivers push"| node_service_worker

click node_main_page "https://github.com/afsallais/trash-removal/blob/main/index.html"
click node_dashboard_page "https://github.com/afsallais/trash-removal/blob/main/index4.html"
click node_mobile_page "https://github.com/afsallais/trash-removal/blob/main/mobile.html"
click node_tv_page "https://github.com/afsallais/trash-removal/blob/main/tv.html"
click node_event_handlers "https://github.com/afsallais/trash-removal/blob/main/functions/index.js"
click node_alert_creation "https://github.com/afsallais/trash-removal/blob/main/functions/index.js"
click node_alert_cancellation "https://github.com/afsallais/trash-removal/blob/main/functions/index.js"
click node_duty_completion "https://github.com/afsallais/trash-removal/blob/main/functions/index.js"
click node_device_lookup "https://github.com/afsallais/trash-removal/blob/main/functions/index.js"
click node_job_claim "https://github.com/afsallais/trash-removal/blob/main/functions/index.js"
click node_pending_poller "https://github.com/afsallais/trash-removal/blob/main/functions/process-pending-alerts.js"
click node_service_worker "https://github.com/afsallais/trash-removal/blob/main/firebase-messaging-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_main_page,node_dashboard_page,node_mobile_page,node_tv_page,node_household_user toneBlue
class node_firestore,node_event_handlers,node_alert_creation,node_alert_cancellation,node_duty_completion,node_device_lookup,node_job_claim,node_pending_poller toneAmber
class node_fcm,node_service_worker toneMint
```

## Components

### Household interfaces

- [Web page](https://github.com/afsallais/trash-removal/blob/main/index.html): `index.html`
- [Dashboard page](https://github.com/afsallais/trash-removal/blob/main/index4.html): `index4.html`
- [Mobile page](https://github.com/afsallais/trash-removal/blob/main/mobile.html): `mobile.html`
- [TV page](https://github.com/afsallais/trash-removal/blob/main/tv.html): `tv.html`

### Firebase backend

- **Firestore**
- [Firestore handlers](https://github.com/afsallais/trash-removal/blob/main/functions/index.js): `functions/index.js`
- [Trash alert](https://github.com/afsallais/trash-removal/blob/main/functions/index.js): `functions/index.js`
- [Alert cancellation](https://github.com/afsallais/trash-removal/blob/main/functions/index.js): `functions/index.js`
- [Duty completion](https://github.com/afsallais/trash-removal/blob/main/functions/index.js): `functions/index.js`
- [Device lookup](https://github.com/afsallais/trash-removal/blob/main/functions/index.js): `functions/index.js`
- [Notification jobs](https://github.com/afsallais/trash-removal/blob/main/functions/index.js): `functions/index.js`
- [Pending alert poller](https://github.com/afsallais/trash-removal/blob/main/functions/process-pending-alerts.js): `functions/process-pending-alerts.js`

### Push notifications

- **Firebase Cloud Messaging**
- [Background push display](https://github.com/afsallais/trash-removal/blob/main/firebase-messaging-sw.js): `firebase-messaging-sw.js`

### Other components

- **Household user**

## Connections

- Household user → Web page: uses (evidence: `README.md`)
- Household user → Dashboard page: uses (evidence: `README.md`)
- Household user → Mobile page: uses (evidence: `README.md`)
- Household user → TV page: uses (evidence: `README.md`)
- Firestore → Firestore handlers: dispatches events (evidence: `functions/index.js`)
- Firestore handlers → Trash alert: handles creation (evidence: `functions/index.js`)
- Firestore handlers → Alert cancellation: handles updates (evidence: `functions/index.js`)
- Firestore handlers → Duty completion: handles updates (evidence: `functions/index.js`)
- Trash alert → Device lookup: finds recipients (evidence: `functions/index.js`)
- Alert cancellation → Device lookup: finds recipients (evidence: `functions/index.js`)
- Duty completion → Device lookup: finds recipients (evidence: `functions/index.js`)
- Device lookup → Firestore: reads devices (evidence: `functions/index.js`)
- Trash alert → Notification jobs: claims job (evidence: `functions/index.js`)
- Alert cancellation → Notification jobs: claims job (evidence: `functions/index.js`)
- Duty completion → Notification jobs: claims job (evidence: `functions/index.js`)
- Notification jobs → Firestore: stores job state (evidence: `functions/index.js`)
- Notification jobs → Firebase Cloud Messaging: sends messages (evidence: `functions/index.js`)
- Pending alert poller → Firestore: reads alerts (evidence: `functions/process-pending-alerts.js`)
- Pending alert poller → Device lookup: finds recipients
- Pending alert poller → Firebase Cloud Messaging: sends messages (evidence: `functions/process-pending-alerts.js`)
- Firebase Cloud Messaging → Background push display: delivers push
