# fileroomprojects/fortus architecture

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

- Interactive diagram: https://gitdiagram.com/fileroomprojects/fortus
- Repository: https://github.com/fileroomprojects/fortus

## Overview

Fortus is a Rails middleware application that synchronizes CRM records between HubSpot and NetSuite. The main user-to-result path begins with a platform webhook or HubSpot request, passes through a controller and domain synchronization logic, and uses each platform’s API client to create or update records. OAuth token handling supports NetSuite access. The README documents broader synchronization stages than the sampled source shows; those capabilities are represented without assuming unshown helper call chains.

Main entry points: [`app/models/hubspot/deal.rb`](https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/deal.rb) (Deal synchronization), [`app/controllers/netsuite_controller.rb`](https://github.com/fileroomprojects/fortus/blob/main/app/controllers/netsuite_controller.rb) (NetSuite webhook controller), [`app/models/netsuite/client.rb`](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/client.rb) (NetSuite API client), [`app/models/netsuite/estimate.rb`](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/estimate.rb) (Estimate synchronization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Webhook and HTTP entry"]
  node_hs_controller["HubSpot webhook controller"]
  node_ns_controller["NetSuite webhook controller"]
  node_ns_sync["NetSuite sync concern<br/>[netsuite_sync.rb]"]
  node_estimate_creation["Estimate creation concern"]
end

subgraph group_hubspot["HubSpot integration"]
  node_hubspot_deal["Deal synchronization<br/>[deal.rb]"]
  node_hubspot_children["Contact, company, quote records<br/>[contact.rb]"]
  node_hubspot_helpers["NetSuite sync helpers"]
  node_hubspot_client["HubSpot API client<br/>[client.rb]"]
  node_hs_domain_concerns["HubSpot record concerns<br/>[hubspot_deal.rb]"]
end

subgraph group_netsuite["NetSuite integration"]
  node_netsuite_estimate["Estimate synchronization<br/>[estimate.rb]"]
  node_netsuite_opportunity["Opportunity synchronization<br/>[opportunity.rb]"]
  node_netsuite_sales_order["Sales order synchronization<br/>[sales_order.rb]"]
  node_netsuite_helpers["HubSpot sync helpers<br/>[order_helper.rb]"]
  node_netsuite_client["NetSuite API client<br/>[client.rb]"]
  node_netsuite_records["Customer and contact records<br/>[customer.rb]"]
end

subgraph group_shared["Shared integration state"]
  node_token_model["OAuth token model<br/>[token.rb]"]
  node_netsuite_base["NetSuite OAuth base<br/>[base.rb]"]
  node_token_store[("Token database<br/>[schema.rb]")]
  node_https_request["HTTP request concern<br/>[https_request.rb]"]
end

node_hubspot_actor(("HubSpot"))
node_netsuite_actor(("NetSuite"))

node_hubspot_actor -->|"sends webhook"| node_hs_controller
node_netsuite_actor -->|"sends webhook"| node_ns_controller
node_hs_controller -->|"starts sync"| node_hubspot_deal
node_hs_controller -->|"requests estimate"| node_estimate_creation
node_ns_controller -->|"delegates sync"| node_ns_sync
node_ns_controller -->|"dispatches sales order"| node_netsuite_sales_order
node_ns_controller -->|"dispatches estimate"| node_netsuite_estimate
node_ns_controller -->|"dispatches opportunity"| node_netsuite_opportunity
node_hubspot_deal -->|"syncs customer contact"| node_netsuite_records
node_hubspot_deal -->|"syncs opportunity"| node_netsuite_opportunity
node_hubspot_deal -->|"creates estimate"| node_netsuite_estimate
node_hubspot_deal -.->|"uses helpers"| node_hubspot_helpers
node_netsuite_estimate -->|"syncs to HubSpot"| node_netsuite_helpers
node_netsuite_sales_order -->|"syncs to HubSpot"| node_netsuite_helpers
node_netsuite_opportunity -->|"syncs to deal"| node_hubspot_deal
node_hubspot_deal -.->|"uses API client"| node_hubspot_client
node_netsuite_sales_order -.->|"uses API client"| node_netsuite_client
node_netsuite_estimate -.->|"uses API client"| node_netsuite_client
node_hubspot_client -->|"calls CRM API"| node_hubspot_actor
node_netsuite_client -->|"calls REST API"| node_netsuite_actor
node_hubspot_deal -.->|"shares record logic"| node_hs_domain_concerns
node_netsuite_base -->|"manages tokens"| node_token_model
node_token_model -->|"persists credentials"| node_token_store
node_netsuite_client -->|"gets access token"| node_netsuite_base
node_hubspot_client -->|"uses requests"| node_https_request
node_netsuite_client -->|"uses requests"| node_https_request

click node_hs_controller "https://github.com/fileroomprojects/fortus/blob/main/app/controllers/hubspots_controller.rb"
click node_ns_controller "https://github.com/fileroomprojects/fortus/blob/main/app/controllers/netsuite_controller.rb"
click node_ns_sync "https://github.com/fileroomprojects/fortus/blob/main/app/controllers/concerns/netsuite_sync.rb"
click node_estimate_creation "https://github.com/fileroomprojects/fortus/blob/main/app/controllers/concerns/ns_estimate_creation.rb"
click node_hubspot_deal "https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/deal.rb"
click node_hubspot_children "https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/contact.rb"
click node_hubspot_helpers "https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/deal/netsuite_opportunity_helper.rb"
click node_hubspot_client "https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/client.rb"
click node_hs_domain_concerns "https://github.com/fileroomprojects/fortus/blob/main/app/models/concerns/hubspot_deal.rb"
click node_netsuite_estimate "https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/estimate.rb"
click node_netsuite_opportunity "https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/opportunity.rb"
click node_netsuite_sales_order "https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/sales_order.rb"
click node_netsuite_helpers "https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/sales_order/hubspot/order_helper.rb"
click node_netsuite_client "https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/client.rb"
click node_netsuite_records "https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/customer.rb"
click node_token_model "https://github.com/fileroomprojects/fortus/blob/main/app/models/token.rb"
click node_netsuite_base "https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/base.rb"
click node_token_store "https://github.com/fileroomprojects/fortus/blob/main/db/schema.rb"
click node_https_request "https://github.com/fileroomprojects/fortus/blob/main/app/models/concerns/https_request.rb"

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_hs_controller,node_ns_controller,node_ns_sync,node_estimate_creation toneBlue
class node_hubspot_deal,node_hubspot_children,node_hubspot_helpers,node_hubspot_client,node_hs_domain_concerns toneAmber
class node_netsuite_estimate,node_netsuite_opportunity,node_netsuite_sales_order,node_netsuite_helpers,node_netsuite_client,node_netsuite_records toneMint
class node_token_model,node_netsuite_base,node_token_store,node_https_request toneRose
class node_hubspot_actor,node_netsuite_actor toneIndigo
```

## Components

### Webhook and HTTP entry

- [HubSpot webhook controller](https://github.com/fileroomprojects/fortus/blob/main/app/controllers/hubspots_controller.rb): `app/controllers/hubspots_controller.rb`
- [NetSuite webhook controller](https://github.com/fileroomprojects/fortus/blob/main/app/controllers/netsuite_controller.rb): `app/controllers/netsuite_controller.rb`
- [NetSuite sync concern](https://github.com/fileroomprojects/fortus/blob/main/app/controllers/concerns/netsuite_sync.rb): `app/controllers/concerns/netsuite_sync.rb`
- [Estimate creation concern](https://github.com/fileroomprojects/fortus/blob/main/app/controllers/concerns/ns_estimate_creation.rb): `app/controllers/concerns/ns_estimate_creation.rb`

### HubSpot integration

- [Deal synchronization](https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/deal.rb): `app/models/hubspot/deal.rb`
- [Contact, company, quote records](https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/contact.rb): `app/models/hubspot/contact.rb`
- [NetSuite sync helpers](https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/deal/netsuite_opportunity_helper.rb): `app/models/hubspot/deal/netsuite_opportunity_helper.rb`
- [HubSpot API client](https://github.com/fileroomprojects/fortus/blob/main/app/models/hubspot/client.rb): `app/models/hubspot/client.rb`
- [HubSpot record concerns](https://github.com/fileroomprojects/fortus/blob/main/app/models/concerns/hubspot_deal.rb): `app/models/concerns/hubspot_deal.rb`

### NetSuite integration

- [Estimate synchronization](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/estimate.rb): `app/models/netsuite/estimate.rb`
- [Opportunity synchronization](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/opportunity.rb): `app/models/netsuite/opportunity.rb`
- [Sales order synchronization](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/sales_order.rb): `app/models/netsuite/sales_order.rb`
- [HubSpot sync helpers](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/sales_order/hubspot/order_helper.rb): `app/models/netsuite/sales_order/hubspot/order_helper.rb`
- [NetSuite API client](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/client.rb): `app/models/netsuite/client.rb`
- [Customer and contact records](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/customer.rb): `app/models/netsuite/customer.rb`

### Shared integration state

- [OAuth token model](https://github.com/fileroomprojects/fortus/blob/main/app/models/token.rb): `app/models/token.rb`
- [NetSuite OAuth base](https://github.com/fileroomprojects/fortus/blob/main/app/models/netsuite/base.rb): `app/models/netsuite/base.rb`
- [Token database](https://github.com/fileroomprojects/fortus/blob/main/db/schema.rb): `db/schema.rb`
- [HTTP request concern](https://github.com/fileroomprojects/fortus/blob/main/app/models/concerns/https_request.rb): `app/models/concerns/https_request.rb`

### Other components

- **HubSpot**
- **NetSuite**

## Connections

- HubSpot → HubSpot webhook controller: sends webhook
- NetSuite → NetSuite webhook controller: sends webhook
- HubSpot webhook controller → Deal synchronization: starts sync (evidence: `app/controllers/hubspots_controller.rb`)
- HubSpot webhook controller → Estimate creation concern: requests estimate (evidence: `app/controllers/hubspots_controller.rb`)
- NetSuite webhook controller → NetSuite sync concern: delegates sync (evidence: `app/controllers/netsuite_controller.rb`)
- NetSuite webhook controller → Sales order synchronization: dispatches sales order (evidence: `app/controllers/netsuite_controller.rb`)
- NetSuite webhook controller → Estimate synchronization: dispatches estimate (evidence: `app/controllers/netsuite_controller.rb`)
- NetSuite webhook controller → Opportunity synchronization: dispatches opportunity (evidence: `app/controllers/netsuite_controller.rb`)
- Deal synchronization → Customer and contact records: syncs customer contact
- Deal synchronization → Opportunity synchronization: syncs opportunity
- Deal synchronization → Estimate synchronization: creates estimate
- Deal synchronization → NetSuite sync helpers: uses helpers
- Estimate synchronization → HubSpot sync helpers: syncs to HubSpot
- Sales order synchronization → HubSpot sync helpers: syncs to HubSpot
- Opportunity synchronization → Deal synchronization: syncs to deal
- Deal synchronization → HubSpot API client: uses API client
- Sales order synchronization → NetSuite API client: uses API client
- Estimate synchronization → NetSuite API client: uses API client
- HubSpot API client → HubSpot: calls CRM API (evidence: `app/models/hubspot/client.rb`)
- NetSuite API client → NetSuite: calls REST API (evidence: `app/models/netsuite/client.rb`)
- Deal synchronization → HubSpot record concerns: shares record logic
- NetSuite OAuth base → OAuth token model: manages tokens
- OAuth token model → Token database: persists credentials
- NetSuite API client → NetSuite OAuth base: gets access token (evidence: `app/models/netsuite/client.rb`)
- HubSpot API client → HTTP request concern: uses requests (evidence: `app/models/hubspot/client.rb`)
- NetSuite API client → HTTP request concern: uses requests (evidence: `app/models/netsuite/client.rb`)
