# astermd/storefront-node architecture

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

- Interactive diagram: https://gitdiagram.com/astermd/storefront-node
- Repository: https://github.com/astermd/storefront-node

## Overview

AsterMD Storefront is a server-rendered telehealth commerce application. The principal journey runs from product discovery and cart through definition-driven clinical intake, optional identity verification, payment checkout, optional upsells, and a receipt. Internal layers include funnel routing, journey/session state, and persistence. The README documents the broad workflow and integrations; the shown source excerpts confirm selected controller, checkout, session-store, and browser-form interactions. Many listed modules were not sampled, so edges between those stages rely on the README rather than inspected implementation.

Main entry points: [`src/checkout/checkout.service.ts`](https://github.com/astermd/storefront-node/blob/main/src/checkout/checkout.service.ts) (Checkout service), [`src/forms/intake-session.ts`](https://github.com/astermd/storefront-node/blob/main/src/forms/intake-session.ts) (Intake forms), [`src/domain/funnel-router.ts`](https://github.com/astermd/storefront-node/blob/main/src/domain/funnel-router.ts) (Funnel routing), [`src/upsell/upsell-service.ts`](https://github.com/astermd/storefront-node/blob/main/src/upsell/upsell-service.ts) (Post-purchase upsells)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_journey["Storefront journey"]
  node_catalog["Product catalog<br/>[catalog-builder.ts]"]
  node_cart["Cart<br/>[cart.ts]"]
  node_funnel["Funnel routing<br/>[funnel-router.ts]"]
  node_journey_state["Journey state<br/>[journey-state.ts]"]
  node_session_store[("Session persistence")]
end

subgraph group_clinical["Clinical workflow"]
  node_intake["Intake forms<br/>[intake-session.ts]"]
  node_form_engine["Browser form engine<br/>[intake-engine.js]"]
  node_eligibility["Eligibility rules"]
  node_verification["Identity verification"]
end

subgraph group_commerce["Checkout and orders"]
  node_checkout_route["Checkout route"]
  node_checkout_service["Checkout service"]
  node_payment["Payment adapters<br/>[payment-adapter.ts]"]
  node_order_recording["Order recording"]
  node_upsells["Post-purchase upsells<br/>[upsell-service.ts]"]
  node_receipt["Receipt<br/>[receipt.ts]"]
end

subgraph group_platform["Platform and operations"]
  node_emr_gateways["AsterMD gateways"]
  node_seo["SEO routes"]
  node_reconciliation["Reconciliation"]
  node_operations["Operations commands"]
  node_config["Deployment config<br/>[app.ts]"]
end

node_visitor(("Visitor"))
node_aggregator{{"Payment aggregator"}}
node_astermd{{"AsterMD platform"}}
node_database[("Application database")]

node_visitor -->|"browses"| node_catalog
node_catalog -->|"adds products"| node_cart
node_cart -->|"starts intake"| node_intake
node_intake -->|"renders questionnaire"| node_form_engine
node_form_engine -->|"posts answers"| node_intake
node_intake -->|"checks eligibility"| node_eligibility
node_eligibility -->|"routes outcome"| node_funnel
node_funnel -->|"may require"| node_verification
node_funnel -->|"routes to checkout"| node_checkout_route
node_checkout_route -->|"invokes"| node_checkout_service
node_checkout_service -->|"reads cart"| node_cart
node_checkout_service -->|"reads journey"| node_journey_state
node_journey_state -->|"persists state"| node_session_store
node_checkout_service -->|"places charge"| node_payment
node_payment -->|"sends payment"| node_aggregator
node_checkout_service -->|"records order"| node_order_recording
node_order_recording -->|"writes order"| node_database
node_checkout_service -->|"reports funnel events"| node_emr_gateways
node_emr_gateways -->|"calls platform"| node_astermd
node_checkout_service -->|"continues purchase"| node_upsells
node_upsells -->|"charges again"| node_aggregator
node_upsells -->|"finishes at"| node_receipt
node_visitor -->|"requests pages"| node_seo
node_operations -->|"runs sweeps"| node_reconciliation
node_config -->|"configures checks"| node_verification

click node_catalog "https://github.com/astermd/storefront-node/blob/main/src/catalog/catalog-builder.ts"
click node_cart "https://github.com/astermd/storefront-node/blob/main/src/domain/cart.ts"
click node_funnel "https://github.com/astermd/storefront-node/blob/main/src/domain/funnel-router.ts"
click node_journey_state "https://github.com/astermd/storefront-node/blob/main/src/journey/journey-state.ts"
click node_session_store "https://github.com/astermd/storefront-node/blob/main/src/repository/session-repository.ts"
click node_intake "https://github.com/astermd/storefront-node/blob/main/src/forms/intake-session.ts"
click node_form_engine "https://github.com/astermd/storefront-node/blob/main/public/js/intake-engine.js"
click node_eligibility "https://github.com/astermd/storefront-node/blob/main/src/forms/disqualification.ts"
click node_verification "https://github.com/astermd/storefront-node/blob/main/src/verification/identity-verification-sequence.ts"
click node_checkout_route "https://github.com/astermd/storefront-node/blob/main/src/routes/checkout/checkout.controller.ts"
click node_checkout_service "https://github.com/astermd/storefront-node/blob/main/src/checkout/checkout.service.ts"
click node_payment "https://github.com/astermd/storefront-node/blob/main/src/payment/payment-adapter.ts"
click node_order_recording "https://github.com/astermd/storefront-node/blob/main/src/checkout/database-order-recorder.ts"
click node_upsells "https://github.com/astermd/storefront-node/blob/main/src/upsell/upsell-service.ts"
click node_receipt "https://github.com/astermd/storefront-node/blob/main/src/completion/receipt.ts"
click node_emr_gateways "https://github.com/astermd/storefront-node/tree/main/src/emr"
click node_seo "https://github.com/astermd/storefront-node/tree/main/src/seo"
click node_reconciliation "https://github.com/astermd/storefront-node/blob/main/src/reconciliation/forward-reconciliation.ts"
click node_operations "https://github.com/astermd/storefront-node/tree/main/src/console"
click node_config "https://github.com/astermd/storefront-node/blob/main/config/app.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_catalog,node_cart,node_funnel,node_journey_state,node_session_store toneBlue
class node_intake,node_form_engine,node_eligibility,node_verification,node_database toneAmber
class node_checkout_route,node_checkout_service,node_payment,node_order_recording,node_upsells,node_receipt toneMint
class node_emr_gateways,node_seo,node_reconciliation,node_operations,node_config toneRose
class node_visitor,node_aggregator,node_astermd toneIndigo
```

## Components

### Storefront journey

- [Product catalog](https://github.com/astermd/storefront-node/blob/main/src/catalog/catalog-builder.ts): `src/catalog/catalog-builder.ts`
- [Cart](https://github.com/astermd/storefront-node/blob/main/src/domain/cart.ts): `src/domain/cart.ts`
- [Funnel routing](https://github.com/astermd/storefront-node/blob/main/src/domain/funnel-router.ts): `src/domain/funnel-router.ts`
- [Journey state](https://github.com/astermd/storefront-node/blob/main/src/journey/journey-state.ts): `src/journey/journey-state.ts`
- [Session persistence](https://github.com/astermd/storefront-node/blob/main/src/repository/session-repository.ts): `src/repository/session-repository.ts`

### Clinical workflow

- [Intake forms](https://github.com/astermd/storefront-node/blob/main/src/forms/intake-session.ts): `src/forms/intake-session.ts`
- [Browser form engine](https://github.com/astermd/storefront-node/blob/main/public/js/intake-engine.js): `public/js/intake-engine.js`
- [Eligibility rules](https://github.com/astermd/storefront-node/blob/main/src/forms/disqualification.ts): `src/forms/disqualification.ts`
- [Identity verification](https://github.com/astermd/storefront-node/blob/main/src/verification/identity-verification-sequence.ts): `src/verification/identity-verification-sequence.ts`

### Checkout and orders

- [Checkout route](https://github.com/astermd/storefront-node/blob/main/src/routes/checkout/checkout.controller.ts): `src/routes/checkout/checkout.controller.ts`
- [Checkout service](https://github.com/astermd/storefront-node/blob/main/src/checkout/checkout.service.ts): `src/checkout/checkout.service.ts`
- [Payment adapters](https://github.com/astermd/storefront-node/blob/main/src/payment/payment-adapter.ts): `src/payment/payment-adapter.ts`
- [Order recording](https://github.com/astermd/storefront-node/blob/main/src/checkout/database-order-recorder.ts): `src/checkout/database-order-recorder.ts`
- [Post-purchase upsells](https://github.com/astermd/storefront-node/blob/main/src/upsell/upsell-service.ts): `src/upsell/upsell-service.ts`
- [Receipt](https://github.com/astermd/storefront-node/blob/main/src/completion/receipt.ts): `src/completion/receipt.ts`

### Platform and operations

- [AsterMD gateways](https://github.com/astermd/storefront-node/tree/main/src/emr): `src/emr`
- [SEO routes](https://github.com/astermd/storefront-node/tree/main/src/seo): `src/seo`
- [Reconciliation](https://github.com/astermd/storefront-node/blob/main/src/reconciliation/forward-reconciliation.ts): `src/reconciliation/forward-reconciliation.ts`
- [Operations commands](https://github.com/astermd/storefront-node/tree/main/src/console): `src/console`
- [Deployment config](https://github.com/astermd/storefront-node/blob/main/config/app.ts): `config/app.ts`

### Other components

- **Visitor**
- **Payment aggregator**
- **AsterMD platform**
- **Application database**

## Connections

- Visitor → Product catalog: browses
- Product catalog → Cart: adds products
- Cart → Intake forms: starts intake
- Intake forms → Browser form engine: renders questionnaire
- Browser form engine → Intake forms: posts answers (evidence: `public/js/intake-engine.js`)
- Intake forms → Eligibility rules: checks eligibility
- Eligibility rules → Funnel routing: routes outcome (evidence: `src/domain/funnel-router.ts`)
- Funnel routing → Identity verification: may require (evidence: `src/domain/funnel-router.ts`)
- Funnel routing → Checkout route: routes to checkout (evidence: `src/domain/funnel-router.ts`)
- Checkout route → Checkout service: invokes (evidence: `src/routes/checkout/checkout.controller.ts`)
- Checkout service → Cart: reads cart (evidence: `src/checkout/checkout.service.ts`)
- Checkout service → Journey state: reads journey (evidence: `src/checkout/checkout.service.ts`)
- Journey state → Session persistence: persists state (evidence: `src/repository/session-repository.ts`)
- Checkout service → Payment adapters: places charge (evidence: `src/checkout/checkout.service.ts`)
- Payment adapters → Payment aggregator: sends payment
- Checkout service → Order recording: records order
- Order recording → Application database: writes order
- Checkout service → AsterMD gateways: reports funnel events (evidence: `src/checkout/checkout.service.ts`)
- AsterMD gateways → AsterMD platform: calls platform
- Checkout service → Post-purchase upsells: continues purchase
- Post-purchase upsells → Payment aggregator: charges again
- Post-purchase upsells → Receipt: finishes at
- Visitor → SEO routes: requests pages
- Operations commands → Reconciliation: runs sweeps
- Deployment config → Identity verification: configures checks (evidence: `config/app.ts`)
