# charlesclapshaw/charlesclapshaw_dev2test architecture

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

- Interactive diagram: https://gitdiagram.com/charlesclapshaw/charlesclapshaw_dev2test
- Repository: https://github.com/charlesclapshaw/charlesclapshaw_dev2test

## Overview

#### Purpose and Runtime
A Node.js/Firebase-backed artwork commerce site, serving a largely static Webflow-generated frontend and exposing server-rendered artwork routes. Root entry points are `app.js` and `server.js`; deployment is defined by `firebase.json` and containerized via `Dockerfile`.

#### Static Web Client
Firebase Hosting likely serves `public/`, containing the primary landing page, artwork pages, styles, and browser scripts. The public UI has several artwork-page iterations, with the active architecture centered on:
- `public/index.html`
- `public/artwork-node.html`
- `public/app.js`
- `public/firebase.js`
- `public/stripe.js`

Browser code is responsible for Firebase client integration, artwork-page behavior, and initiating Stripe-related checkout interactions.

#### Dynamic Artwork Routing
The backend separates route wiring from artwork lookup and HTML/page assembly:
- `src/routes/artwork.js`
- `src/endpoints/artworkBySlug.js`
- `src/services/artworkSlug.js`
- `src/services/artworkPage.js`

The expected request flow is an artwork slug request → route/endpoint → slug resolution → page/content generation or response. This is the boundary between static Webflow assets and dynamic catalog presentation.

#### Firestore Artwork Access
Firestore-specific artwork data access is isolated in:
- `lib/firestoreArtwork.js`
- `firestore.rules`
- `firestore.indexes.json`

This layer is the persistence boundary used to retrieve artwork records. Firestore rules control client/server data authorization; indexes support catalog query patterns. A Firestore export exists under `firebase/`, indicating local/exported project data rather than application source.

#### Checkout and Stripe Boundary
Stripe handling is split between client-facing scripts and server middleware:
- `public/stripe.js`
- `public/checkout-confirmation.js`
- `src/middleware/stripe.js`
- `public/server/endpoints/checkout-confirmation.html`

Frontend code initiates or confirms checkout UX; backend middleware should own secret-key-dependent Stripe operations. Keep payment session creation, verification, and trusted transaction state out of public scripts.

#### Firebase Infrastructure
Firebase is the principal platform: Hosting for `public/`, Firestore for artwork data, and likely server/function-style routing for Node handlers. Core infrastructure artifacts are:
- `firebase.json`
- `.firebaserc`
- `storage.rules`
- `firestore.rules`

Cloud Storage rules indicate an asset-upload/storage boundary, likely for artwork media. The repository contains Firebase-oriented agent documentation, but these files are development guidance rather than runtime code.

#### Operational Boundaries
`package.json` and `package-lock.json` define the Node dependency/runtime contract. `Dockerfile` provides a deployable server image, making `server.js`/`app.js` potentially usable outside Firebase Hosting as well. The architecture should preserve a strict split: public static assets and browser Firebase SDK usage in `public/`; trusted routing, Firestore server access, and Stripe secrets in root/server-side `src/` and `lib/`.

Main entry points: [`public/app.js`](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/app.js) (Artwork behavior), [`public/stripe.js`](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/stripe.js) (Checkout client), [`src/endpoints/artworkBySlug.js`](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/endpoints/artworkBySlug.js) (Artwork-by-slug endpoint), [`firebase.json`](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/firebase.json) (Firebase Hosting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser client"]
  node_public["Webflow static UI<br/>static site"]
  node_landing["Landing page<br/>HTML page<br/>[index.html]"]
  node_artwork_ui["Artwork page UI<br/>HTML page<br/>[artwork-node.html]"]
  node_browser_app["Artwork behavior<br/>browser script<br/>[app.js]"]
  node_firebase_client["Firebase client SDK<br/>browser integration<br/>[firebase.js]"]
  node_stripe_client["Checkout client<br/>browser script<br/>[stripe.js]"]
  node_checkout_confirmation["Checkout confirmation UI<br/>HTML page"]
end

subgraph group_server["Trusted Node backend"]
  node_server_entry["Server bootstrap<br/>Node entry point<br/>[server.js]"]
  node_app_entry["Application setup<br/>Node entry point<br/>[app.js]"]
  node_artwork_route["Artwork route<br/>route wiring<br/>[artwork.js]"]
  node_artwork_endpoint["Artwork-by-slug endpoint<br/>request handler<br/>[artworkBySlug.js]"]
  node_slug_service["Slug resolution<br/>catalog service<br/>[artworkSlug.js]"]
  node_page_service["Artwork page assembly<br/>page service<br/>[artworkPage.js]"]
  node_stripe_middleware["Trusted Stripe middleware<br/>payment boundary<br/>[stripe.js]"]
  node_firestore_access["Firestore artwork access<br/>data access layer"]
  node_container["Container deployment<br/>Docker image"]
end

subgraph group_firebase["Firebase platform"]
  node_hosting{{"Firebase Hosting<br/>[firebase.json]"}}
  node_firestore[("Firestore artwork catalog<br/>database")]
  node_firestore_rules["Firestore authorization rules<br/>security rules<br/>[firestore.rules]"]
  node_firestore_indexes["Firestore catalog indexes<br/>database indexes"]
  node_storage_rules["Cloud Storage access rules<br/>security rules<br/>[storage.rules]"]
end

node_hosting -->|"serves"| node_public
node_public -->|"contains"| node_landing
node_public -->|"contains"| node_artwork_ui
node_artwork_ui -->|"loads"| node_browser_app
node_browser_app -->|"uses"| node_firebase_client
node_browser_app -->|"initiates checkout"| node_stripe_client
node_stripe_client -->|"payment request"| node_stripe_middleware
node_stripe_client -->|"confirms checkout"| node_checkout_confirmation
node_hosting -->|"forwards dynamic requests"| node_server_entry
node_server_entry -->|"starts"| node_app_entry
node_app_entry -->|"registers"| node_artwork_route
node_artwork_route -->|"dispatches slug request"| node_artwork_endpoint
node_artwork_endpoint -->|"resolves slug"| node_slug_service
node_artwork_endpoint -->|"assembles response"| node_page_service
node_slug_service -->|"looks up artwork"| node_firestore_access
node_page_service -->|"loads artwork content"| node_firestore_access
node_firestore_access -->|"reads records"| node_firestore
node_firestore_rules -.->|"authorizes access"| node_firestore
node_firestore_indexes -.->|"supports catalog queries"| node_firestore
node_storage_rules -.->|"protects media access"| node_hosting
node_container -->|"packages"| node_server_entry

click node_hosting "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/firebase.json"
click node_landing "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/index.html"
click node_artwork_ui "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/artwork-node.html"
click node_browser_app "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/app.js"
click node_firebase_client "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/firebase.js"
click node_stripe_client "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/stripe.js"
click node_checkout_confirmation "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/server/endpoints/checkout-confirmation.html"
click node_server_entry "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/server.js"
click node_app_entry "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/app.js"
click node_artwork_route "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/routes/artwork.js"
click node_artwork_endpoint "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/endpoints/artworkBySlug.js"
click node_slug_service "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/services/artworkSlug.js"
click node_page_service "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/services/artworkPage.js"
click node_stripe_middleware "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/middleware/stripe.js"
click node_firestore_access "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/lib/firestoreArtwork.js"
click node_firestore_rules "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/firestore.rules"
click node_firestore_indexes "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/firestore.indexes.json"
click node_storage_rules "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/storage.rules"
click node_container "https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/Dockerfile"

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_public,node_landing,node_artwork_ui,node_browser_app,node_firebase_client,node_stripe_client,node_checkout_confirmation toneBlue
class node_server_entry,node_app_entry,node_artwork_route,node_artwork_endpoint,node_slug_service,node_page_service,node_stripe_middleware,node_firestore_access,node_container toneAmber
class node_hosting,node_firestore,node_firestore_rules,node_firestore_indexes,node_storage_rules toneMint
```

## Components

### Browser client

- **Webflow static UI**: static site
- [Landing page](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/index.html): HTML page · `public/index.html`
- [Artwork page UI](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/artwork-node.html): HTML page · `public/artwork-node.html`
- [Artwork behavior](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/app.js): browser script · `public/app.js`
- [Firebase client SDK](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/firebase.js): browser integration · `public/firebase.js`
- [Checkout client](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/stripe.js): browser script · `public/stripe.js`
- [Checkout confirmation UI](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/public/server/endpoints/checkout-confirmation.html): HTML page · `public/server/endpoints/checkout-confirmation.html`

### Trusted Node backend

- [Server bootstrap](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/server.js): Node entry point · `server.js`
- [Application setup](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/app.js): Node entry point · `app.js`
- [Artwork route](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/routes/artwork.js): route wiring · `src/routes/artwork.js`
- [Artwork-by-slug endpoint](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/endpoints/artworkBySlug.js): request handler · `src/endpoints/artworkBySlug.js`
- [Slug resolution](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/services/artworkSlug.js): catalog service · `src/services/artworkSlug.js`
- [Artwork page assembly](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/services/artworkPage.js): page service · `src/services/artworkPage.js`
- [Trusted Stripe middleware](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/src/middleware/stripe.js): payment boundary · Owns secret-key Stripe operations. · `src/middleware/stripe.js`
- [Firestore artwork access](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/lib/firestoreArtwork.js): data access layer · `lib/firestoreArtwork.js`
- [Container deployment](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/Dockerfile): Docker image · `Dockerfile`

### Firebase platform

- [Firebase Hosting](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/firebase.json): hosting · Serves public assets and routes requests to backend handling. · `firebase.json`
- **Firestore artwork catalog**: database
- [Firestore authorization rules](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/firestore.rules): security rules · `firestore.rules`
- [Firestore catalog indexes](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/firestore.indexes.json): database indexes · `firestore.indexes.json`
- [Cloud Storage access rules](https://github.com/charlesclapshaw/charlesclapshaw_dev2test/blob/main/storage.rules): security rules · Controls artwork media access. · `storage.rules`

## Connections

- Firebase Hosting → Webflow static UI: serves
- Webflow static UI → Landing page: contains
- Webflow static UI → Artwork page UI: contains
- Artwork page UI → Artwork behavior: loads
- Artwork behavior → Firebase client SDK: uses
- Artwork behavior → Checkout client: initiates checkout
- Checkout client → Trusted Stripe middleware: payment request
- Checkout client → Checkout confirmation UI: confirms checkout
- Firebase Hosting → Server bootstrap: forwards dynamic requests
- Server bootstrap → Application setup: starts
- Application setup → Artwork route: registers
- Artwork route → Artwork-by-slug endpoint: dispatches slug request
- Artwork-by-slug endpoint → Slug resolution: resolves slug
- Artwork-by-slug endpoint → Artwork page assembly: assembles response
- Slug resolution → Firestore artwork access: looks up artwork
- Artwork page assembly → Firestore artwork access: loads artwork content
- Firestore artwork access → Firestore artwork catalog: reads records
- Firestore authorization rules → Firestore artwork catalog: authorizes access
- Firestore catalog indexes → Firestore artwork catalog: supports catalog queries
- Cloud Storage access rules → Firebase Hosting: protects media access
- Container deployment → Server bootstrap: packages
