# stagsz/scrubberproject-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/stagsz/scrubberproject-v2
- Repository: https://github.com/stagsz/scrubberproject-v2
- Video tour (about a minute): https://gitdiagram.com/stagsz/scrubberproject-v2/video

## Overview

Scrubberproject is a salesperson’s tool for producing wet-scrubber budget quotes from customer flue-gas data. Its central workflow is to enter design inputs, derive a typed tower model, and present that model as engineering views and an offer; the README says these outputs share one derivation. The app also supports saved projects, immutable revisions, share links, and shared cost history. The model flow is documented, while several app-to-core and view-to-view connections are inferred only at the capability level; unsampled wiring is omitted.

Main entry points: [`core/src/model/derive.ts`](https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/derive.ts) (Tower derivation), [`app/lib/db.ts`](https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/db.ts) (Project data store), [`app/app/api/projects/[id]/revisions/route.ts`](https://github.com/stagsz/scrubberproject-v2/blob/main/app/app/api/projects/%5Bid%5D/revisions/route.ts) (Revision and share API), [`app/components/DesignBoard.tsx`](https://github.com/stagsz/scrubberproject-v2/blob/main/app/components/DesignBoard.tsx) (Design workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Engineering model"]
  node_inputs["Sheet inputs<br/>[inputs.ts]"]
  node_design["Design envelope<br/>[design.ts]"]
  node_derive["Tower derivation<br/>[derive.ts]"]
  node_sections["Tower sections<br/>[sections.ts]"]
  node_process["Process sizing"]
  node_duty["Duty evaluation"]
  node_geometry["Layout geometry"]
end

subgraph group_views["Design views"]
  node_elevation["Elevation drawing"]
  node_datasheet["Datasheet output"]
  node_designui["Design workspace<br/>[DesignBoard.tsx]"]
end

subgraph group_projects["Project lifecycle"]
  node_projectapi["Project API"]
  node_revisionapi["Revision and share API<br/>[route.ts]"]
  node_shareapi["Public share API<br/>[route.ts]"]
  node_projectstore[("Project data store<br/>[db.ts]")]
end

subgraph group_accounts["Accounts and history"]
  node_authapi["Authentication API"]
  node_authlogic["Authentication services<br/>[auth.ts]"]
  node_userstore[("Account and session store<br/>[db.ts]")]
end

subgraph group_commercial["Cost and offer"]
  node_offerui["Offer document view<br/>[OfferDocument.tsx]"]
  node_cost["Cost estimate"]
  node_offer["Offer document"]
  node_historyapi["Cost history API"]
  node_historylogic["History and FX logic<br/>[history.ts]"]
end

node_salesperson(("Salesperson"))
node_customer(("Customer"))

node_salesperson -->|"enters inputs"| node_designui
node_designui -->|"provides design data"| node_inputs
node_inputs -->|"validates inputs"| node_derive
node_derive -->|"derives tower"| node_sections
node_derive -->|"sizes process"| node_process
node_derive -->|"evaluates duty"| node_duty
node_derive -->|"derives layout"| node_geometry
node_derive -->|"feeds drawing"| node_elevation
node_derive -->|"feeds rows"| node_datasheet
node_derive -.->|"feeds takeoff"| node_cost
node_derive -.->|"feeds offer"| node_offer
node_designui -->|"saves design"| node_projectapi
node_projectapi -->|"normalizes design"| node_design
node_projectapi -->|"reads and writes"| node_projectstore
node_revisionapi -->|"freezes revisions"| node_projectstore
node_revisionapi -->|"normalizes snapshots"| node_design
node_revisionapi -->|"creates share links"| node_shareapi
node_shareapi -->|"reads frozen revision"| node_projectstore
node_customer -->|"opens share link"| node_shareapi
node_offer -->|"renders document"| node_offerui
node_salesperson -->|"reviews offer"| node_offerui
node_historyapi -->|"dispatches history actions"| node_historylogic
node_historylogic -->|"stores jobs and FX"| node_projectstore
node_salesperson -->|"manages cost history"| node_historyapi
node_salesperson -->|"registers or signs in"| node_authapi
node_authapi -->|"authenticates account"| node_authlogic
node_authlogic -->|"stores credentials and sessions"| node_userstore

click node_inputs "https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/inputs.ts"
click node_design "https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/design.ts"
click node_derive "https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/derive.ts"
click node_sections "https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/sections.ts"
click node_process "https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/process"
click node_duty "https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/duty"
click node_geometry "https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/layout"
click node_elevation "https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/drawing"
click node_datasheet "https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/datasheet"
click node_designui "https://github.com/stagsz/scrubberproject-v2/blob/main/app/components/DesignBoard.tsx"
click node_offerui "https://github.com/stagsz/scrubberproject-v2/blob/main/app/components/OfferDocument.tsx"
click node_cost "https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/cost"
click node_offer "https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/offer"
click node_projectapi "https://github.com/stagsz/scrubberproject-v2/tree/main/app/app/api/projects"
click node_revisionapi "https://github.com/stagsz/scrubberproject-v2/blob/main/app/app/api/projects/%5Bid%5D/revisions/route.ts"
click node_shareapi "https://github.com/stagsz/scrubberproject-v2/blob/main/app/app/api/share/%5Btoken%5D/route.ts"
click node_projectstore "https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/db.ts"
click node_historyapi "https://github.com/stagsz/scrubberproject-v2/tree/main/app/app/api/history"
click node_historylogic "https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/history.ts"
click node_authapi "https://github.com/stagsz/scrubberproject-v2/tree/main/app/app/api/auth"
click node_authlogic "https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/auth.ts"
click node_userstore "https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/db.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_inputs,node_design,node_derive,node_sections,node_process,node_duty,node_geometry toneBlue
class node_elevation,node_datasheet,node_designui toneAmber
class node_projectapi,node_revisionapi,node_shareapi,node_projectstore toneMint
class node_authapi,node_authlogic,node_userstore toneRose
class node_offerui,node_cost,node_offer,node_historyapi,node_historylogic,node_salesperson,node_customer toneIndigo
```

## Components

### Engineering model

- [Sheet inputs](https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/inputs.ts): `core/src/model/inputs.ts`
- [Design envelope](https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/design.ts): `core/src/model/design.ts`
- [Tower derivation](https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/derive.ts): `core/src/model/derive.ts`
- [Tower sections](https://github.com/stagsz/scrubberproject-v2/blob/main/core/src/model/sections.ts): `core/src/model/sections.ts`
- [Process sizing](https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/process): `core/src/process`
- [Duty evaluation](https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/duty): `core/src/duty`
- [Layout geometry](https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/layout): `core/src/layout`

### Design views

- [Elevation drawing](https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/drawing): `core/src/drawing`
- [Datasheet output](https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/datasheet): `core/src/datasheet`
- [Design workspace](https://github.com/stagsz/scrubberproject-v2/blob/main/app/components/DesignBoard.tsx): `app/components/DesignBoard.tsx`

### Project lifecycle

- [Project API](https://github.com/stagsz/scrubberproject-v2/tree/main/app/app/api/projects): `app/app/api/projects`
- [Revision and share API](https://github.com/stagsz/scrubberproject-v2/blob/main/app/app/api/projects/%5Bid%5D/revisions/route.ts): `app/app/api/projects/[id]/revisions/route.ts`
- [Public share API](https://github.com/stagsz/scrubberproject-v2/blob/main/app/app/api/share/%5Btoken%5D/route.ts): `app/app/api/share/[token]/route.ts`
- [Project data store](https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/db.ts): `app/lib/db.ts`

### Accounts and history

- [Authentication API](https://github.com/stagsz/scrubberproject-v2/tree/main/app/app/api/auth): `app/app/api/auth`
- [Authentication services](https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/auth.ts): `app/lib/auth.ts`
- [Account and session store](https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/db.ts): `app/lib/db.ts`

### Cost and offer

- [Offer document view](https://github.com/stagsz/scrubberproject-v2/blob/main/app/components/OfferDocument.tsx): `app/components/OfferDocument.tsx`
- [Cost estimate](https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/cost): `core/src/cost`
- [Offer document](https://github.com/stagsz/scrubberproject-v2/tree/main/core/src/offer): `core/src/offer`
- [Cost history API](https://github.com/stagsz/scrubberproject-v2/tree/main/app/app/api/history): `app/app/api/history`
- [History and FX logic](https://github.com/stagsz/scrubberproject-v2/blob/main/app/lib/history.ts): `app/lib/history.ts`

### Other components

- **Salesperson**
- **Customer**

## Connections

- Salesperson → Design workspace: enters inputs
- Design workspace → Sheet inputs: provides design data
- Sheet inputs → Tower derivation: validates inputs
- Tower derivation → Tower sections: derives tower
- Tower derivation → Process sizing: sizes process
- Tower derivation → Duty evaluation: evaluates duty
- Tower derivation → Layout geometry: derives layout
- Tower derivation → Elevation drawing: feeds drawing
- Tower derivation → Datasheet output: feeds rows
- Tower derivation → Cost estimate: feeds takeoff
- Tower derivation → Offer document: feeds offer
- Design workspace → Project API: saves design
- Project API → Design envelope: normalizes design
- Project API → Project data store: reads and writes
- Revision and share API → Project data store: freezes revisions
- Revision and share API → Design envelope: normalizes snapshots
- Revision and share API → Public share API: creates share links
- Public share API → Project data store: reads frozen revision
- Customer → Public share API: opens share link
- Offer document → Offer document view: renders document
- Salesperson → Offer document view: reviews offer
- Cost history API → History and FX logic: dispatches history actions
- History and FX logic → Project data store: stores jobs and FX
- Salesperson → Cost history API: manages cost history
- Salesperson → Authentication API: registers or signs in
- Authentication API → Authentication services: authenticates account
- Authentication services → Account and session store: stores credentials and sessions
