# tssanjayy/whistledrop architecture

> Architecture diagram of the GitHub repository tssanjayy/whistledrop, 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/tssanjayy/whistledrop
- Repository: https://github.com/tssanjayy/whistledrop

## Overview

WhistleDrop is an anonymous reporting platform: reporters submit concerns and receive private case codes to track outcomes, while moderators authenticate to review, update, and clear eligible reports. Its runtime separates HTTP routing, report/moderation logic, persistence, and file handling. The README documents the responsive web interface and broader capabilities; source excerpts show backend wiring and SQLite operations, but do not show frontend implementation or any moderator-to-reporter reply endpoint.

Main entry points: [`server.js`](https://github.com/tssanjayy/whistledrop/blob/main/server.js) (Express server), [`src/routes/moderator.js`](https://github.com/tssanjayy/whistledrop/blob/main/src/routes/moderator.js) (Moderator routes), [`public/index.html`](https://github.com/tssanjayy/whistledrop/blob/main/public/index.html) (Web interface), [`src/models/reportModel.js`](https://github.com/tssanjayy/whistledrop/blob/main/src/models/reportModel.js) (Report data access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Reporter experience"]
  node_web_ui["Web interface<br/>[index.html]"]
end

subgraph group_api["HTTP API"]
  node_server["Express server<br/>[server.js]"]
  node_public_routes["Report routes<br/>[reports.js]"]
  node_report_logic["Report handling"]
  node_error_handling["Error handling<br/>[errorHandler.js]"]
end

subgraph group_moderation["Moderation"]
  node_moderator_routes["Moderator routes<br/>[moderator.js]"]
  node_moderator_auth["Moderator auth<br/>[auth.js]"]
  node_moderator_logic["Moderation actions"]
end

subgraph group_persistence["Persistence and files"]
  node_upload["Upload handling<br/>[upload.js]"]
  node_report_model["Report data access<br/>[reportModel.js]"]
  node_sqlite[("SQLite database<br/>[database.js]")]
  node_upload_files["Uploaded files"]
end

node_reporter(("Reporter"))
node_moderator(("Moderator"))

node_reporter -.->|"uses"| node_web_ui
node_moderator -.->|"uses"| node_web_ui
node_web_ui -.->|"sends requests"| node_server
node_server -->|"serves static UI"| node_web_ui
node_reporter -->|"submits and tracks"| node_server
node_moderator -->|"manages reports"| node_server
node_server -->|"mounts reports"| node_public_routes
node_server -->|"mounts moderation"| node_moderator_routes
node_server -->|"registers errors"| node_error_handling
node_public_routes -->|"parses uploads"| node_upload
node_public_routes -->|"dispatches requests"| node_report_logic
node_report_logic -->|"reads and writes"| node_report_model
node_moderator_routes -->|"requires key"| node_moderator_auth
node_moderator_routes -->|"dispatches updates"| node_moderator_logic
node_moderator_routes -->|"queries reports"| node_report_model
node_moderator_logic -->|"updates and clears"| node_report_model
node_report_model -->|"queries"| node_sqlite
node_upload -->|"writes files"| node_upload_files
node_report_logic -->|"records file paths"| node_upload_files
node_moderator_routes -->|"downloads attachments"| node_upload_files

click node_web_ui "https://github.com/tssanjayy/whistledrop/blob/main/public/index.html"
click node_server "https://github.com/tssanjayy/whistledrop/blob/main/server.js"
click node_public_routes "https://github.com/tssanjayy/whistledrop/blob/main/src/routes/reports.js"
click node_report_logic "https://github.com/tssanjayy/whistledrop/blob/main/src/controllers/reportController.js"
click node_moderator_routes "https://github.com/tssanjayy/whistledrop/blob/main/src/routes/moderator.js"
click node_moderator_auth "https://github.com/tssanjayy/whistledrop/blob/main/src/middleware/auth.js"
click node_moderator_logic "https://github.com/tssanjayy/whistledrop/blob/main/src/controllers/moderatorController.js"
click node_error_handling "https://github.com/tssanjayy/whistledrop/blob/main/src/middleware/errorHandler.js"
click node_upload "https://github.com/tssanjayy/whistledrop/blob/main/src/middleware/upload.js"
click node_report_model "https://github.com/tssanjayy/whistledrop/blob/main/src/models/reportModel.js"
click node_sqlite "https://github.com/tssanjayy/whistledrop/blob/main/src/database.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_web_ui toneBlue
class node_server,node_public_routes,node_report_logic,node_error_handling toneAmber
class node_moderator_routes,node_moderator_auth,node_moderator_logic toneMint
class node_upload,node_report_model,node_sqlite,node_upload_files toneRose
class node_reporter,node_moderator toneIndigo
```

## Components

### Reporter experience

- [Web interface](https://github.com/tssanjayy/whistledrop/blob/main/public/index.html): `public/index.html`

### HTTP API

- [Express server](https://github.com/tssanjayy/whistledrop/blob/main/server.js): `server.js`
- [Report routes](https://github.com/tssanjayy/whistledrop/blob/main/src/routes/reports.js): `src/routes/reports.js`
- [Report handling](https://github.com/tssanjayy/whistledrop/blob/main/src/controllers/reportController.js): `src/controllers/reportController.js`
- [Error handling](https://github.com/tssanjayy/whistledrop/blob/main/src/middleware/errorHandler.js): `src/middleware/errorHandler.js`

### Moderation

- [Moderator routes](https://github.com/tssanjayy/whistledrop/blob/main/src/routes/moderator.js): `src/routes/moderator.js`
- [Moderator auth](https://github.com/tssanjayy/whistledrop/blob/main/src/middleware/auth.js): `src/middleware/auth.js`
- [Moderation actions](https://github.com/tssanjayy/whistledrop/blob/main/src/controllers/moderatorController.js): `src/controllers/moderatorController.js`

### Persistence and files

- [Upload handling](https://github.com/tssanjayy/whistledrop/blob/main/src/middleware/upload.js): `src/middleware/upload.js`
- [Report data access](https://github.com/tssanjayy/whistledrop/blob/main/src/models/reportModel.js): `src/models/reportModel.js`
- [SQLite database](https://github.com/tssanjayy/whistledrop/blob/main/src/database.js): `src/database.js`
- **Uploaded files**

### Other components

- **Reporter**
- **Moderator**

## Connections

- Reporter → Web interface: uses (evidence: `README.md`)
- Moderator → Web interface: uses (evidence: `README.md`)
- Web interface → Express server: sends requests (evidence: `README.md`)
- Express server → Web interface: serves static UI (evidence: `server.js`)
- Reporter → Express server: submits and tracks (evidence: `README.md`)
- Moderator → Express server: manages reports (evidence: `README.md`)
- Express server → Report routes: mounts reports (evidence: `server.js`)
- Express server → Moderator routes: mounts moderation (evidence: `server.js`)
- Express server → Error handling: registers errors (evidence: `server.js`)
- Report routes → Upload handling: parses uploads (evidence: `src/routes/reports.js`)
- Report routes → Report handling: dispatches requests (evidence: `src/routes/reports.js`)
- Report handling → Report data access: reads and writes (evidence: `src/controllers/reportController.js`)
- Moderator routes → Moderator auth: requires key (evidence: `src/routes/moderator.js`)
- Moderator routes → Moderation actions: dispatches updates (evidence: `src/routes/moderator.js`)
- Moderator routes → Report data access: queries reports (evidence: `src/routes/moderator.js`)
- Moderation actions → Report data access: updates and clears (evidence: `src/controllers/moderatorController.js`)
- Report data access → SQLite database: queries (evidence: `src/models/reportModel.js`)
- Upload handling → Uploaded files: writes files (evidence: `src/middleware/upload.js`)
- Report handling → Uploaded files: records file paths (evidence: `src/controllers/reportController.js`)
- Moderator routes → Uploaded files: downloads attachments (evidence: `src/routes/moderator.js`)
