# stagsz/scrubberproject architecture

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

- Interactive diagram: https://gitdiagram.com/stagsz/scrubberproject
- Repository: https://github.com/stagsz/scrubberproject

## Overview

This repository combines a shared scrubber-engineering package with a web application for design projects and plant-asset records. The documented design workflow configures tower and spray geometry, computes process sizing, presents views and cost estimates, and exports design data; the web tree adds project, sharing, and asset-management capabilities. Process integration’s sampled source shows it invoking several calculation modules, and the asset-route excerpt shows shared authentication plumbing. README describes additional designer capabilities, but its single-file artifact is not present in the supplied tree; evaluation tooling is omitted.

Main entry points: [`web/app/design/[id]/page.tsx`](https://github.com/stagsz/scrubberproject/blob/master/web/app/design/%5Bid%5D/page.tsx) (Design interface), [`core/src/process/integration.ts`](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/integration.ts) (Duty integration), [`web/lib/asset/route.ts`](https://github.com/stagsz/scrubberproject/blob/master/web/lib/asset/route.ts) (Asset route plumbing), [`core/src/process/flooding.ts`](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/flooding.ts) (Flooding capacity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_process["Process calculations"]
  node_integration["Duty integration<br/>[integration.ts]"]
  node_flooding["Flooding capacity<br/>[flooding.ts]"]
  node_capacity["Tower capacity<br/>[capacity.ts]"]
  node_transfer["Packed-bed transfer<br/>[transfer.ts]"]
  node_quench["Quench balance<br/>[quench.ts]"]
  node_pump["Pump duty<br/>[pump.ts]"]
  node_demister["Demister sizing<br/>[demister.ts]"]
  node_gasbasis["Gas basis<br/>[gasbasis.ts]"]
  node_condenser["Condenser model<br/>[condenser.ts]"]
  node_reagent["Reagent model<br/>[reagent.ts]"]
  node_validity["Validity limits<br/>[validity.ts]"]
end

subgraph group_design["Design models"]
  node_designer["Design interface<br/>[page.tsx]"]
  node_geometry["Layout geometry<br/>[geometry.ts]"]
  node_cost["Cost estimation<br/>[cost.ts]"]
  node_nozzles["Nozzle catalogue<br/>[nozzles.ts]"]
  node_csv["CSV catalogue import<br/>[csv.ts]"]
end

subgraph group_projects["Web projects"]
  node_projects["Project endpoints<br/>[route.ts]"]
  node_revisions["Project revisions<br/>[revisions.ts]"]
  node_sharing["Project sharing<br/>[route.ts]"]
end

subgraph group_assets["Plant assets"]
  node_assetui["Asset interface<br/>[AssetClient.tsx]"]
  node_assetroutes["Asset route plumbing<br/>[route.ts]"]
  node_assetapi["Plant and fleet APIs<br/>[route.ts]"]
  node_assetlogic["Asset calculations<br/>[quantities.ts]"]
  node_database[("Application database<br/>[db.ts]")]
end

node_engineer(("Engineer"))
node_auth["Authentication helper<br/>[auth.ts]"]

node_engineer -.->|"configures design"| node_designer
node_integration -->|"calls"| node_flooding
node_integration -->|"calls"| node_transfer
node_integration -->|"calls"| node_quench
node_integration -->|"calls"| node_pump
node_capacity -->|"uses correlation"| node_flooding
node_capacity -->|"checks limits"| node_validity
node_flooding -->|"checks limits"| node_validity
node_demister -->|"checks limits"| node_validity
node_designer -.->|"runs sizing"| node_integration
node_designer -.->|"presents layout"| node_geometry
node_designer -.->|"estimates cost"| node_cost
node_designer -.->|"imports history"| node_csv
node_projects -.->|"stores projects"| node_database
node_projects -.->|"uses revisions"| node_revisions
node_sharing -.->|"resolves shares"| node_database
node_assetui -.->|"requests records"| node_assetapi
node_assetapi -.->|"uses route plumbing"| node_assetroutes
node_assetroutes -->|"reads asset records"| node_database
node_assetroutes -->|"maps quantities"| node_assetlogic
node_assetroutes -->|"gets current user"| node_auth

click node_designer "https://github.com/stagsz/scrubberproject/blob/master/web/app/design/%5Bid%5D/page.tsx"
click node_integration "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/integration.ts"
click node_flooding "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/flooding.ts"
click node_capacity "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/capacity.ts"
click node_transfer "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/transfer.ts"
click node_quench "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/quench.ts"
click node_pump "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/pump.ts"
click node_demister "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/demister.ts"
click node_gasbasis "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/gasbasis.ts"
click node_condenser "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/condenser.ts"
click node_reagent "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/reagent.ts"
click node_validity "https://github.com/stagsz/scrubberproject/blob/master/core/src/process/validity.ts"
click node_geometry "https://github.com/stagsz/scrubberproject/blob/master/core/src/model/geometry.ts"
click node_cost "https://github.com/stagsz/scrubberproject/blob/master/core/src/model/cost.ts"
click node_nozzles "https://github.com/stagsz/scrubberproject/blob/master/core/src/catalogue/nozzles.ts"
click node_csv "https://github.com/stagsz/scrubberproject/blob/master/core/src/catalogue/csv.ts"
click node_projects "https://github.com/stagsz/scrubberproject/blob/master/web/app/api/projects/route.ts"
click node_revisions "https://github.com/stagsz/scrubberproject/blob/master/web/lib/revisions.ts"
click node_sharing "https://github.com/stagsz/scrubberproject/blob/master/web/app/api/share/%5Btoken%5D/route.ts"
click node_assetui "https://github.com/stagsz/scrubberproject/blob/master/web/app/asset/%5Bid%5D/AssetClient.tsx"
click node_assetroutes "https://github.com/stagsz/scrubberproject/blob/master/web/lib/asset/route.ts"
click node_assetapi "https://github.com/stagsz/scrubberproject/blob/master/web/app/api/fleet/route.ts"
click node_assetlogic "https://github.com/stagsz/scrubberproject/blob/master/web/lib/asset/quantities.ts"
click node_database "https://github.com/stagsz/scrubberproject/blob/master/web/lib/db.ts"
click node_auth "https://github.com/stagsz/scrubberproject/blob/master/web/lib/auth.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_integration,node_flooding,node_capacity,node_transfer,node_quench,node_pump,node_demister,node_gasbasis,node_condenser,node_reagent,node_validity toneBlue
class node_designer,node_geometry,node_cost,node_nozzles,node_csv toneAmber
class node_projects,node_revisions,node_sharing toneMint
class node_assetui,node_assetroutes,node_assetapi,node_assetlogic,node_database toneRose
class node_engineer toneIndigo
class node_auth toneTeal
```

## Components

### Process calculations

- [Duty integration](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/integration.ts): `core/src/process/integration.ts`
- [Flooding capacity](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/flooding.ts): `core/src/process/flooding.ts`
- [Tower capacity](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/capacity.ts): `core/src/process/capacity.ts`
- [Packed-bed transfer](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/transfer.ts): `core/src/process/transfer.ts`
- [Quench balance](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/quench.ts): `core/src/process/quench.ts`
- [Pump duty](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/pump.ts): `core/src/process/pump.ts`
- [Demister sizing](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/demister.ts): `core/src/process/demister.ts`
- [Gas basis](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/gasbasis.ts): `core/src/process/gasbasis.ts`
- [Condenser model](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/condenser.ts): `core/src/process/condenser.ts`
- [Reagent model](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/reagent.ts): `core/src/process/reagent.ts`
- [Validity limits](https://github.com/stagsz/scrubberproject/blob/master/core/src/process/validity.ts): `core/src/process/validity.ts`

### Design models

- [Design interface](https://github.com/stagsz/scrubberproject/blob/master/web/app/design/%5Bid%5D/page.tsx): `web/app/design/[id]/page.tsx`
- [Layout geometry](https://github.com/stagsz/scrubberproject/blob/master/core/src/model/geometry.ts): `core/src/model/geometry.ts`
- [Cost estimation](https://github.com/stagsz/scrubberproject/blob/master/core/src/model/cost.ts): `core/src/model/cost.ts`
- [Nozzle catalogue](https://github.com/stagsz/scrubberproject/blob/master/core/src/catalogue/nozzles.ts): `core/src/catalogue/nozzles.ts`
- [CSV catalogue import](https://github.com/stagsz/scrubberproject/blob/master/core/src/catalogue/csv.ts): `core/src/catalogue/csv.ts`

### Web projects

- [Project endpoints](https://github.com/stagsz/scrubberproject/blob/master/web/app/api/projects/route.ts): `web/app/api/projects/route.ts`
- [Project revisions](https://github.com/stagsz/scrubberproject/blob/master/web/lib/revisions.ts): `web/lib/revisions.ts`
- [Project sharing](https://github.com/stagsz/scrubberproject/blob/master/web/app/api/share/%5Btoken%5D/route.ts): `web/app/api/share/[token]/route.ts`

### Plant assets

- [Asset interface](https://github.com/stagsz/scrubberproject/blob/master/web/app/asset/%5Bid%5D/AssetClient.tsx): `web/app/asset/[id]/AssetClient.tsx`
- [Asset route plumbing](https://github.com/stagsz/scrubberproject/blob/master/web/lib/asset/route.ts): `web/lib/asset/route.ts`
- [Plant and fleet APIs](https://github.com/stagsz/scrubberproject/blob/master/web/app/api/fleet/route.ts): `web/app/api/fleet/route.ts`
- [Asset calculations](https://github.com/stagsz/scrubberproject/blob/master/web/lib/asset/quantities.ts): `web/lib/asset/quantities.ts`
- [Application database](https://github.com/stagsz/scrubberproject/blob/master/web/lib/db.ts): `web/lib/db.ts`

### Other components

- **Engineer**
- [Authentication helper](https://github.com/stagsz/scrubberproject/blob/master/web/lib/auth.ts): `web/lib/auth.ts`

## Connections

- Engineer → Design interface: configures design
- Duty integration → Flooding capacity: calls (evidence: `core/src/process/integration.ts`)
- Duty integration → Packed-bed transfer: calls (evidence: `core/src/process/integration.ts`)
- Duty integration → Quench balance: calls (evidence: `core/src/process/integration.ts`)
- Duty integration → Pump duty: calls (evidence: `core/src/process/integration.ts`)
- Tower capacity → Flooding capacity: uses correlation (evidence: `core/src/process/capacity.ts`)
- Tower capacity → Validity limits: checks limits (evidence: `core/src/process/capacity.ts`)
- Flooding capacity → Validity limits: checks limits (evidence: `core/src/process/flooding.ts`)
- Demister sizing → Validity limits: checks limits (evidence: `core/src/process/demister.ts`)
- Design interface → Duty integration: runs sizing
- Design interface → Layout geometry: presents layout
- Design interface → Cost estimation: estimates cost
- Design interface → CSV catalogue import: imports history
- Project endpoints → Application database: stores projects
- Project endpoints → Project revisions: uses revisions
- Project sharing → Application database: resolves shares
- Asset interface → Plant and fleet APIs: requests records
- Plant and fleet APIs → Asset route plumbing: uses route plumbing
- Asset route plumbing → Application database: reads asset records (evidence: `web/lib/asset/route.ts`)
- Asset route plumbing → Asset calculations: maps quantities (evidence: `web/lib/asset/route.ts`)
- Asset route plumbing → Authentication helper: gets current user (evidence: `web/lib/asset/route.ts`)
