# alevander23/anti-bullying-app architecture

> Architecture diagram of the GitHub repository alevander23/anti-bullying-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alevander23/anti-bullying-app
- Repository: https://github.com/alevander23/anti-bullying-app

## Overview

The repository appears to support an anti-bullying reporting and ticketing product, with a client-facing app, a staff app, Firebase functions, and a separate authenticated media server. The supplied tree contains no README or Dart application sources, so client workflows and app-to-backend wiring are only represented where the backend behavior is evidenced; platform launchers and build files are excluded.

Main entry points: [`storage_server/index.js`](https://github.com/alevander23/anti-bullying-app/blob/main/storage_server/index.js) (Staff file serving), [`cloud_functions/functions/index.js`](https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js) (Ticket status trigger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ticket_ops["Ticket operations"]
  node_ticket_api["Ticket callables<br/>[index.js]"]
  node_ticket_events["Ticket status trigger<br/>[index.js]"]
end

subgraph group_reporting["School reporting"]
  node_report_api["Report and school config<br/>[index.js]"]
end

subgraph group_identity["Identity and trust"]
  node_identity_api["Identity and role<br/>[index.js]"]
  node_trust_calc["Trust factor calculation<br/>[index.js]"]
end

subgraph group_media["Media storage"]
  node_upload_api["Upload endpoint<br/>[index.js]"]
  node_download_api["Staff file serving<br/>[index.js]"]
end

node_client(("Client app user"))
node_staff(("Staff user"))
node_firebase_auth["Firebase Authentication"]
node_firestore[("Cloud Firestore")]
node_local_files[("Upload directory")]

node_client -->|"calls ticket functions"| node_ticket_api
node_staff -->|"calls ticket functions"| node_ticket_api
node_ticket_api -->|"reads and writes"| node_firestore
node_firestore -->|"triggers on update"| node_ticket_events
node_ticket_events -->|"calculates trust"| node_trust_calc
node_ticket_events -->|"updates trust data"| node_firestore
node_client -->|"submits report"| node_report_api
node_report_api -->|"reads school and saves report"| node_firestore
node_identity_api -->|"checks role"| node_firestore
node_identity_api -->|"sets user claims"| node_firebase_auth
node_client -->|"uploads media"| node_upload_api
node_upload_api -->|"verifies token"| node_firebase_auth
node_upload_api -->|"saves validated file"| node_local_files
node_staff -->|"requests media"| node_download_api
node_download_api -->|"verifies token"| node_firebase_auth
node_download_api -->|"checks admin status"| node_firestore
node_download_api -->|"serves file"| node_local_files

click node_ticket_api "https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js"
click node_ticket_events "https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js"
click node_report_api "https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js"
click node_identity_api "https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js"
click node_trust_calc "https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js"
click node_upload_api "https://github.com/alevander23/anti-bullying-app/blob/main/storage_server/index.js"
click node_download_api "https://github.com/alevander23/anti-bullying-app/blob/main/storage_server/index.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_ticket_api,node_ticket_events,node_client,node_staff toneBlue
class node_report_api,node_firestore,node_local_files toneAmber
class node_identity_api,node_trust_calc toneMint
class node_upload_api,node_download_api toneRose
class node_firebase_auth toneIndigo
```

## Components

### Ticket operations

- [Ticket callables](https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js): `cloud_functions/functions/index.js`
- [Ticket status trigger](https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js): `cloud_functions/functions/index.js`

### School reporting

- [Report and school config](https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js): `cloud_functions/functions/index.js`

### Identity and trust

- [Identity and role](https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js): `cloud_functions/functions/index.js`
- [Trust factor calculation](https://github.com/alevander23/anti-bullying-app/blob/main/cloud_functions/functions/index.js): `cloud_functions/functions/index.js`

### Media storage

- [Upload endpoint](https://github.com/alevander23/anti-bullying-app/blob/main/storage_server/index.js): `storage_server/index.js`
- [Staff file serving](https://github.com/alevander23/anti-bullying-app/blob/main/storage_server/index.js): `storage_server/index.js`

### Other components

- **Client app user**
- **Staff user**
- **Firebase Authentication**
- **Cloud Firestore**
- **Upload directory**

## Connections

- Client app user → Ticket callables: calls ticket functions
- Staff user → Ticket callables: calls ticket functions
- Ticket callables → Cloud Firestore: reads and writes
- Cloud Firestore → Ticket status trigger: triggers on update
- Ticket status trigger → Trust factor calculation: calculates trust
- Ticket status trigger → Cloud Firestore: updates trust data
- Client app user → Report and school config: submits report
- Report and school config → Cloud Firestore: reads school and saves report
- Identity and role → Cloud Firestore: checks role
- Identity and role → Firebase Authentication: sets user claims
- Client app user → Upload endpoint: uploads media
- Upload endpoint → Firebase Authentication: verifies token
- Upload endpoint → Upload directory: saves validated file
- Staff user → Staff file serving: requests media
- Staff file serving → Firebase Authentication: verifies token
- Staff file serving → Cloud Firestore: checks admin status
- Staff file serving → Upload directory: serves file
