# tadeskops/ta-society-helpdesk architecture

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

- Interactive diagram: https://gitdiagram.com/tadeskops/ta-society-helpdesk
- Repository: https://github.com/tadeskops/ta-society-helpdesk

## Overview

This is a residential-society helpdesk and operations backend: residents submit issues (anonymously when enabled), managers triage them, and maintenance/vendors resolve them. The Worker authenticates and authorizes requests, dispatches routes, and persists records in GitHub Issues and repository files. It also exposes separate reservation, EV-charging, treasury, vehicle, and society-management capabilities. The README documents the static Pages UI and Google identity; its source files are not in the supplied tree. Route details beyond the sampled issue, reservation, and EV modules are therefore represented at subsystem level.

Main entry points: [`worker/src/lib/router.ts`](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/router.ts) (Route dispatch), [`worker/src/routes/issues.ts`](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/issues.ts) (Issue intake and triage), [`worker/src/github/client.ts`](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/github/client.ts) (GitHub client), [`worker/src/index.ts`](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/index.ts) (Worker entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Worker runtime"]
  node_worker["Worker entry<br/>[index.ts]"]
  node_router["Route dispatch<br/>[router.ts]"]
  node_context["Request context<br/>[ctx.ts]"]
  node_responses["HTTP envelopes<br/>[envelope.ts]"]
end

subgraph group_access["Identity and policy"]
  node_config["Site configuration<br/>[loader.ts]"]
  node_defaults["Feature defaults<br/>[defaults.ts]"]
  node_identity["Google identity<br/>[jwt.ts]"]
  node_roles["Role resolution<br/>[roles.ts]"]
  node_guards["Access guards<br/>[rbac.ts]"]
end

subgraph group_helpdesk["Issue tracking"]
  node_issues["Issue intake and triage<br/>[issues.ts]"]
  node_issue_domain["Issue operations<br/>[issue.ts]"]
  node_validation["Request validation<br/>[validate.ts]"]
  node_audit["Audit records<br/>[audit.ts]"]
end

subgraph group_operations["Society operations"]
  node_reservations["Facility reservations<br/>[reservations.ts]"]
  node_reservation_rules["Reservation rules<br/>[reservation.ts]"]
  node_ev["EV charging<br/>[ev-charging.ts]"]
  node_ev_booking["EV booking analytics<br/>[ev-booking.ts]"]
  node_ev_mirror["EV report mirror<br/>[ev-mirror.ts]"]
  node_treasury["Treasury<br/>[treasury.ts]"]
  node_vehicles["Vehicle registry<br/>[vehicles.ts]"]
  node_other_routes["Society service routes"]
end

subgraph group_integrations["External services"]
  node_github_api{{"GitHub REST API"}}
  node_github_client["GitHub client<br/>[client.ts]"]
  node_google{{"Google Identity Services"}}
  node_turnstile{{"Cloudflare Turnstile"}}
  node_calendar{{"Google Calendar"}}
end

node_resident(("Resident / operator"))

node_resident -->|"sends requests"| node_worker
node_worker -->|"dispatches routes"| node_router
node_worker -->|"assembles context"| node_context
node_worker -->|"loads configuration"| node_config
node_worker -->|"verifies identity"| node_identity
node_worker -->|"formats responses"| node_responses
node_config -->|"reads config"| node_github_client
node_config -->|"uses defaults"| node_defaults
node_identity -.->|"verifies tokens"| node_google
node_router -->|"routes issue requests"| node_issues
node_router -->|"routes bookings"| node_reservations
node_router -->|"routes EV requests"| node_ev
node_router -->|"routes treasury requests"| node_treasury
node_router -->|"routes vehicle requests"| node_vehicles
node_router -->|"routes other services"| node_other_routes
node_issues -->|"checks access"| node_guards
node_issues -->|"validates input"| node_validation
node_issues -->|"uses issue operations"| node_issue_domain
node_issues -->|"reads and writes issues"| node_github_client
node_issues -->|"records actions"| node_audit
node_issues -.->|"checks submissions"| node_turnstile
node_reservations -->|"checks access"| node_guards
node_reservations -->|"applies booking rules"| node_reservation_rules
node_reservations -->|"reads and writes records"| node_github_client
node_reservations -.->|"mirrors bookings"| node_calendar
node_ev -->|"checks access"| node_guards
node_ev -->|"reads and writes records"| node_github_client
node_ev -->|"aggregates bookings"| node_ev_booking
node_ev -->|"mirrors reports"| node_ev_mirror
node_ev -->|"records actions"| node_audit
node_treasury -->|"reads and writes records"| node_github_client
node_vehicles -->|"uses repository data"| node_github_client
node_github_client -->|"calls REST API"| node_github_api

click node_worker "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/index.ts"
click node_router "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/router.ts"
click node_context "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/ctx.ts"
click node_responses "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/envelope.ts"
click node_config "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/config/loader.ts"
click node_defaults "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/config/defaults.ts"
click node_identity "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/auth/jwt.ts"
click node_roles "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/auth/roles.ts"
click node_guards "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/middleware/rbac.ts"
click node_issues "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/issues.ts"
click node_issue_domain "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/issue.ts"
click node_validation "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/validate.ts"
click node_audit "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/audit.ts"
click node_reservations "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/reservations.ts"
click node_reservation_rules "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/reservation.ts"
click node_ev "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/ev-charging.ts"
click node_ev_booking "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/ev-booking.ts"
click node_ev_mirror "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/ev-mirror.ts"
click node_treasury "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/treasury.ts"
click node_vehicles "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/vehicles.ts"
click node_other_routes "https://github.com/tadeskops/ta-society-helpdesk/tree/main/worker/src/routes"
click node_github_client "https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/github/client.ts"

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_worker,node_router,node_context,node_responses toneBlue
class node_config,node_defaults,node_identity,node_roles,node_guards toneAmber
class node_issues,node_issue_domain,node_validation,node_audit toneMint
class node_reservations,node_reservation_rules,node_ev,node_ev_booking,node_ev_mirror,node_treasury,node_vehicles,node_other_routes toneRose
class node_github_api,node_github_client,node_google,node_turnstile,node_calendar,node_resident toneIndigo
```

## Components

### Worker runtime

- [Worker entry](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/index.ts): `worker/src/index.ts`
- [Route dispatch](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/router.ts): `worker/src/lib/router.ts`
- [Request context](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/ctx.ts): `worker/src/lib/ctx.ts`
- [HTTP envelopes](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/envelope.ts): `worker/src/lib/envelope.ts`

### Identity and policy

- [Site configuration](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/config/loader.ts): `worker/src/config/loader.ts`
- [Feature defaults](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/config/defaults.ts): `worker/src/config/defaults.ts`
- [Google identity](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/auth/jwt.ts): `worker/src/auth/jwt.ts`
- [Role resolution](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/auth/roles.ts): `worker/src/auth/roles.ts`
- [Access guards](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/middleware/rbac.ts): `worker/src/middleware/rbac.ts`

### Issue tracking

- [Issue intake and triage](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/issues.ts): `worker/src/routes/issues.ts`
- [Issue operations](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/issue.ts): `worker/src/lib/issue.ts`
- [Request validation](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/validate.ts): `worker/src/lib/validate.ts`
- [Audit records](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/audit.ts): `worker/src/lib/audit.ts`

### Society operations

- [Facility reservations](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/reservations.ts): `worker/src/routes/reservations.ts`
- [Reservation rules](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/reservation.ts): `worker/src/lib/reservation.ts`
- [EV charging](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/ev-charging.ts): `worker/src/routes/ev-charging.ts`
- [EV booking analytics](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/ev-booking.ts): `worker/src/lib/ev-booking.ts`
- [EV report mirror](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/lib/ev-mirror.ts): `worker/src/lib/ev-mirror.ts`
- [Treasury](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/treasury.ts): `worker/src/routes/treasury.ts`
- [Vehicle registry](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/routes/vehicles.ts): `worker/src/routes/vehicles.ts`
- [Society service routes](https://github.com/tadeskops/ta-society-helpdesk/tree/main/worker/src/routes): `worker/src/routes`

### External services

- **GitHub REST API**
- [GitHub client](https://github.com/tadeskops/ta-society-helpdesk/blob/main/worker/src/github/client.ts): `worker/src/github/client.ts`
- **Google Identity Services**
- **Cloudflare Turnstile**
- **Google Calendar**

### Other components

- **Resident / operator**

## Connections

- Resident / operator → Worker entry: sends requests (evidence: `README.md`)
- Worker entry → Route dispatch: dispatches routes (evidence: `worker/src/index.ts`)
- Worker entry → Request context: assembles context (evidence: `worker/src/index.ts`)
- Worker entry → Site configuration: loads configuration (evidence: `worker/src/index.ts`)
- Worker entry → Google identity: verifies identity (evidence: `worker/src/index.ts`)
- Worker entry → HTTP envelopes: formats responses (evidence: `worker/src/index.ts`)
- Site configuration → GitHub client: reads config (evidence: `worker/src/config/loader.ts`)
- Site configuration → Feature defaults: uses defaults (evidence: `worker/src/config/loader.ts`)
- Google identity → Google Identity Services: verifies tokens (evidence: `README.md`)
- Route dispatch → Issue intake and triage: routes issue requests (evidence: `worker/src/routes/index.ts`)
- Route dispatch → Facility reservations: routes bookings (evidence: `worker/src/routes/index.ts`)
- Route dispatch → EV charging: routes EV requests (evidence: `worker/src/routes/index.ts`)
- Route dispatch → Treasury: routes treasury requests (evidence: `worker/src/routes/index.ts`)
- Route dispatch → Vehicle registry: routes vehicle requests (evidence: `worker/src/routes/index.ts`)
- Route dispatch → Society service routes: routes other services (evidence: `worker/src/routes/index.ts`)
- Issue intake and triage → Access guards: checks access (evidence: `worker/src/routes/issues.ts`)
- Issue intake and triage → Request validation: validates input (evidence: `worker/src/routes/issues.ts`)
- Issue intake and triage → Issue operations: uses issue operations (evidence: `worker/src/routes/issues.ts`)
- Issue intake and triage → GitHub client: reads and writes issues (evidence: `worker/src/routes/issues.ts`)
- Issue intake and triage → Audit records: records actions (evidence: `worker/src/routes/issues.ts`)
- Issue intake and triage → Cloudflare Turnstile: checks submissions
- Facility reservations → Access guards: checks access (evidence: `worker/src/routes/reservations.ts`)
- Facility reservations → Reservation rules: applies booking rules (evidence: `worker/src/routes/reservations.ts`)
- Facility reservations → GitHub client: reads and writes records (evidence: `worker/src/routes/reservations.ts`)
- Facility reservations → Google Calendar: mirrors bookings (evidence: `worker/src/routes/reservations.ts`)
- EV charging → Access guards: checks access (evidence: `worker/src/routes/ev-charging.ts`)
- EV charging → GitHub client: reads and writes records (evidence: `worker/src/routes/ev-charging.ts`)
- EV charging → EV booking analytics: aggregates bookings (evidence: `worker/src/routes/ev-charging.ts`)
- EV charging → EV report mirror: mirrors reports (evidence: `worker/src/routes/ev-charging.ts`)
- EV charging → Audit records: records actions (evidence: `worker/src/routes/ev-charging.ts`)
- Treasury → GitHub client: reads and writes records (evidence: `worker/src/routes/treasury.ts`)
- Vehicle registry → GitHub client: uses repository data (evidence: `worker/src/routes/vehicles.ts`)
- GitHub client → GitHub REST API: calls REST API (evidence: `worker/src/github/client.ts`)
