# dartmouth-outing-club/doc-trailhead architecture

> Architecture diagram of the GitHub repository dartmouth-outing-club/doc-trailhead, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dartmouth-outing-club/doc-trailhead
- Repository: https://github.com/dartmouth-outing-club/doc-trailhead

## Overview

DOC Trailhead is a server-rendered trip-management web application. Users browse and sign up for trips, manage profiles and gear or vehicle requests, and receive HTML responses tailored to their permissions. Leaders and OPO staff handle trip, gear, profile, and fleet approvals. The documented architecture uses Express routes, Nunjucks views, HTMX interactivity, and SQLite. The graph reflects README and indexed references; unsampled route implementations are represented at their exact paths, and their internal call details are not inferred.

Main entry points: [`src/router.js`](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/router.js) (Route dispatch), [`src/server.js`](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/server.js) (HTTP server), [`src/services/mailer.js`](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/services/mailer.js) (Mail delivery), [`src/routes/trip.js`](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip.js) (Trip management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Web runtime"]
  node_server["HTTP server<br/>[server.js]"]
  node_router["Route dispatch<br/>[router.js]"]
  node_templates["HTML views"]
end

subgraph group_trips["Trip operations"]
  node_trip["Trip management<br/>[trip.js]"]
  node_tripcard["Trip cards<br/>[trip-card.js]"]
  node_members["Trip members<br/>[trip-members.js]"]
  node_requests["Trip requests<br/>[trip-requests.js]"]
  node_checkin["Check-in/out<br/>[check-in.js]"]
  node_gear["Gear requests<br/>[gear.js]"]
  node_vehicle["Vehicle requests<br/>[vehicle-request.js]"]
end

subgraph group_admin["Approvals and profiles"]
  node_profile["User profiles<br/>[profile.js]"]
  node_chair["Club oversight<br/>[trip-overview.js]"]
  node_gearapproval["Gear approvals<br/>[gear-approvals.js]"]
  node_profileapproval["Profile approvals"]
  node_fleet["Fleet requests"]
end

subgraph group_platform["Data and messaging"]
  node_database[("SQLite database<br/>[sqlite.js]")]
  node_emails["Email workflows<br/>[emails.js]"]
  node_mailer["Mail delivery<br/>[mailer.js]"]
  node_scheduler["Scheduled notices<br/>[app.js]"]
end

node_visitor(("Browser user"))
node_graph{{"Microsoft Graph"}}
node_auth{{"OIDC identity"}}

node_visitor -->|"requests pages"| node_server
node_server -->|"configures OIDC"| node_auth
node_server -->|"dispatches routes"| node_router
node_router -->|"routes trip actions"| node_trip
node_router -->|"routes profile actions"| node_profile
node_router -->|"routes membership"| node_members
node_router -->|"routes trip requests"| node_requests
node_router -->|"routes check-in"| node_checkin
node_router -->|"routes gear"| node_gear
node_router -->|"routes approvals"| node_gearapproval
node_router -->|"routes approvals"| node_profileapproval
node_router -->|"routes fleet"| node_fleet
node_router -->|"routes oversight"| node_chair
node_server -->|"attaches database"| node_database
node_server -->|"configures rendering"| node_templates
node_trip -->|"reads and writes"| node_database
node_trip -->|"renders trip cards"| node_tripcard
node_tripcard -->|"loads vehicle data"| node_vehicle
node_gearapproval -->|"renders leader card"| node_tripcard
node_gearapproval -->|"renders request table"| node_vehicle
node_profile -->|"reads and writes"| node_database
node_vehicle -->|"reads request data"| node_database
node_members -->|"sends notices"| node_mailer
node_trip -->|"sends notices"| node_mailer
node_gearapproval -->|"sends notices"| node_mailer
node_mailer -->|"sends email"| node_graph
node_scheduler -->|"selects scheduled notices"| node_emails
node_scheduler -->|"schedules delivery"| node_mailer

click node_server "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/server.js"
click node_router "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/router.js"
click node_templates "https://github.com/dartmouth-outing-club/doc-trailhead/tree/main/src/templates"
click node_trip "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip.js"
click node_tripcard "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/trip-card.js"
click node_members "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/trip-members.js"
click node_requests "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/trip-requests.js"
click node_checkin "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/check-in.js"
click node_gear "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/gear/gear.js"
click node_profile "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/profile.js"
click node_chair "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/chair/trip-overview.js"
click node_gearapproval "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/opo/gear-approvals.js"
click node_profileapproval "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/opo/profile-approvals.js"
click node_fleet "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/opo/vehicle-requests.js"
click node_vehicle "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/vehicle-request.js"
click node_database "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/services/sqlite.js"
click node_emails "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/emails.js"
click node_mailer "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/services/mailer.js"
click node_scheduler "https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/app.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_server,node_router,node_templates,node_visitor toneBlue
class node_trip,node_tripcard,node_members,node_requests,node_checkin,node_gear,node_vehicle toneAmber
class node_profile,node_chair,node_gearapproval,node_profileapproval,node_fleet toneMint
class node_database,node_emails,node_mailer,node_scheduler toneRose
class node_graph,node_auth toneIndigo
```

## Components

### Web runtime

- [HTTP server](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/server.js): `src/server.js`
- [Route dispatch](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/router.js): `src/router.js`
- [HTML views](https://github.com/dartmouth-outing-club/doc-trailhead/tree/main/src/templates): `src/templates`

### Trip operations

- [Trip management](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip.js): `src/routes/trip.js`
- [Trip cards](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/trip-card.js): `src/routes/trip/trip-card.js`
- [Trip members](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/trip-members.js): `src/routes/trip/trip-members.js`
- [Trip requests](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/trip-requests.js): `src/routes/trip/trip-requests.js`
- [Check-in/out](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/check-in.js): `src/routes/trip/check-in.js`
- [Gear requests](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/trip/gear/gear.js): `src/routes/trip/gear/gear.js`
- [Vehicle requests](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/vehicle-request.js): `src/routes/vehicle-request.js`

### Approvals and profiles

- [User profiles](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/profile.js): `src/routes/profile.js`
- [Club oversight](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/chair/trip-overview.js): `src/routes/chair/trip-overview.js`
- [Gear approvals](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/opo/gear-approvals.js): `src/routes/opo/gear-approvals.js`
- [Profile approvals](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/opo/profile-approvals.js): `src/routes/opo/profile-approvals.js`
- [Fleet requests](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/routes/opo/vehicle-requests.js): `src/routes/opo/vehicle-requests.js`

### Data and messaging

- [SQLite database](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/services/sqlite.js): `src/services/sqlite.js`
- [Email workflows](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/emails.js): `src/emails.js`
- [Mail delivery](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/services/mailer.js): `src/services/mailer.js`
- [Scheduled notices](https://github.com/dartmouth-outing-club/doc-trailhead/blob/main/src/app.js): `src/app.js`

### Other components

- **Browser user**
- **Microsoft Graph**
- **OIDC identity**

## Connections

- Browser user → HTTP server: requests pages (evidence: `README.md`)
- HTTP server → OIDC identity: configures OIDC (evidence: `src/server.js`)
- HTTP server → Route dispatch: dispatches routes (evidence: `src/server.js`)
- Route dispatch → Trip management: routes trip actions (evidence: `src/router.js`)
- Route dispatch → User profiles: routes profile actions (evidence: `src/router.js`)
- Route dispatch → Trip members: routes membership (evidence: `src/router.js`)
- Route dispatch → Trip requests: routes trip requests (evidence: `src/router.js`)
- Route dispatch → Check-in/out: routes check-in (evidence: `src/router.js`)
- Route dispatch → Gear requests: routes gear (evidence: `src/router.js`)
- Route dispatch → Gear approvals: routes approvals (evidence: `src/router.js`)
- Route dispatch → Profile approvals: routes approvals (evidence: `src/router.js`)
- Route dispatch → Fleet requests: routes fleet (evidence: `src/router.js`)
- Route dispatch → Club oversight: routes oversight (evidence: `src/router.js`)
- HTTP server → SQLite database: attaches database (evidence: `src/server.js`)
- HTTP server → HTML views: configures rendering (evidence: `src/server.js`)
- Trip management → SQLite database: reads and writes (evidence: `src/routes/trip.js`)
- Trip management → Trip cards: renders trip cards (evidence: `src/routes/trip.js`)
- Trip cards → Vehicle requests: loads vehicle data (evidence: `src/routes/trip/trip-card.js`)
- Gear approvals → Trip cards: renders leader card (evidence: `src/routes/opo/gear-approvals.js`)
- Gear approvals → Vehicle requests: renders request table (evidence: `src/routes/opo/gear-approvals.js`)
- User profiles → SQLite database: reads and writes (evidence: `src/routes/profile.js`)
- Vehicle requests → SQLite database: reads request data (evidence: `src/routes/vehicle-request.js`)
- Trip members → Mail delivery: sends notices (evidence: `src/routes/trip/trip-members.js`)
- Trip management → Mail delivery: sends notices (evidence: `src/routes/trip.js`)
- Gear approvals → Mail delivery: sends notices (evidence: `src/routes/opo/gear-approvals.js`)
- Mail delivery → Microsoft Graph: sends email (evidence: `src/services/mailer.js`)
- Scheduled notices → Email workflows: selects scheduled notices (evidence: `src/app.js`)
- Scheduled notices → Mail delivery: schedules delivery (evidence: `src/app.js`)
