# mortalmen/first_app_shopify architecture

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

- Interactive diagram: https://gitdiagram.com/mortalmen/first_app_shopify
- Repository: https://github.com/mortalmen/first_app_shopify

## Overview

This is a Shopify embedded app template with a customer analytics/VIP workflow and a separate product, variant, and metaobject GraphQL demo. Merchants log in, enter the embedded app, browse customer spending and VIP status, and can submit a spending threshold to tag qualifying customers. Shopify authentication uses Prisma-backed session storage. The README also documents webhook, metafield, and metaobject capabilities. Relationships involving unsampled route wiring are omitted; the customer form’s implicit submission target is shown as unverified.

Main entry points: [`app/shopify.server.js`](https://github.com/mortalmen/first_app_shopify/blob/main/app/shopify.server.js) (Shopify setup), [`app/routes/app.customers.jsx`](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/app.customers.jsx) (Customer route), [`app/routes/_index/route.jsx`](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/_index/route.jsx) (Login landing), [`app/db.server.js`](https://github.com/mortalmen/first_app_shopify/blob/main/app/db.server.js) (Session database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App entry"]
  node_landing["Login landing<br/>[route.jsx]"]
  node_app_shell["Embedded app shell<br/>[app.jsx]"]
end

subgraph group_auth["Authentication"]
  node_login["Login handler<br/>[route.jsx]"]
  node_shopify_config["Shopify setup<br/>[shopify.server.js]"]
  node_session_db[("Session database<br/>[db.server.js]")]
end

subgraph group_customer["Customer tools"]
  node_customers_route["Customer route<br/>[app.customers.jsx]"]
  node_customer_service["Customer queries and VIP tags"]
  node_vip_bar["VIP threshold controls"]
  node_customer_card["Customer summary card<br/>[CustomerCard.jsx]"]
end

subgraph group_shopify["Shopify integration"]
  node_product_demo["Product and metafield demo<br/>[app._index.jsx]"]
  node_scope_webhook["Scope update webhook"]
  node_uninstall_webhook["Uninstall webhook"]
end

node_merchant(("Merchant"))
node_shopify_admin{{"Shopify Admin API"}}

node_merchant -->|"opens app"| node_landing
node_landing -->|"submits login"| node_login
node_landing -->|"redirects shop"| node_app_shell
node_login -->|"validates login"| node_shopify_config
node_shopify_config -->|"stores sessions"| node_session_db
node_app_shell -->|"authenticates admin"| node_shopify_config
node_customers_route -->|"authenticates admin"| node_shopify_config
node_customers_route -->|"loads and updates"| node_customer_service
node_customers_route -->|"renders controls"| node_vip_bar
node_customers_route -->|"renders customers"| node_customer_card
node_vip_bar -.->|"submits threshold"| node_customers_route
node_customer_service -->|"queries and tags"| node_shopify_admin
node_product_demo -->|"authenticates admin"| node_shopify_config
node_product_demo -->|"creates product and metaobject"| node_shopify_admin
node_scope_webhook -->|"uses authentication"| node_shopify_config
node_scope_webhook -->|"updates sessions"| node_session_db
node_uninstall_webhook -->|"uses authentication"| node_shopify_config
node_uninstall_webhook -->|"updates sessions"| node_session_db

click node_landing "https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/_index/route.jsx"
click node_login "https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/auth.login/route.jsx"
click node_shopify_config "https://github.com/mortalmen/first_app_shopify/blob/main/app/shopify.server.js"
click node_session_db "https://github.com/mortalmen/first_app_shopify/blob/main/app/db.server.js"
click node_app_shell "https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/app.jsx"
click node_product_demo "https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/app._index.jsx"
click node_customers_route "https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/app.customers.jsx"
click node_customer_service "https://github.com/mortalmen/first_app_shopify/blob/main/app/features/customers/customers.server.js"
click node_vip_bar "https://github.com/mortalmen/first_app_shopify/blob/main/app/features/customers/VipAutomationBar.jsx"
click node_customer_card "https://github.com/mortalmen/first_app_shopify/blob/main/app/features/customers/CustomerCard.jsx"
click node_scope_webhook "https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/webhooks.app.scopes_update.jsx"
click node_uninstall_webhook "https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/webhooks.app.uninstalled.jsx"

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_landing,node_app_shell toneBlue
class node_login,node_shopify_config,node_session_db toneAmber
class node_customers_route,node_customer_service,node_vip_bar,node_customer_card,node_shopify_admin toneMint
class node_product_demo,node_scope_webhook,node_uninstall_webhook toneRose
class node_merchant toneIndigo
```

## Components

### App entry

- [Login landing](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/_index/route.jsx): `app/routes/_index/route.jsx`
- [Embedded app shell](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/app.jsx): `app/routes/app.jsx`

### Authentication

- [Login handler](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/auth.login/route.jsx): `app/routes/auth.login/route.jsx`
- [Shopify setup](https://github.com/mortalmen/first_app_shopify/blob/main/app/shopify.server.js): `app/shopify.server.js`
- [Session database](https://github.com/mortalmen/first_app_shopify/blob/main/app/db.server.js): `app/db.server.js`

### Customer tools

- [Customer route](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/app.customers.jsx): `app/routes/app.customers.jsx`
- [Customer queries and VIP tags](https://github.com/mortalmen/first_app_shopify/blob/main/app/features/customers/customers.server.js): `app/features/customers/customers.server.js`
- [VIP threshold controls](https://github.com/mortalmen/first_app_shopify/blob/main/app/features/customers/VipAutomationBar.jsx): `app/features/customers/VipAutomationBar.jsx`
- [Customer summary card](https://github.com/mortalmen/first_app_shopify/blob/main/app/features/customers/CustomerCard.jsx): `app/features/customers/CustomerCard.jsx`

### Shopify integration

- [Product and metafield demo](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/app._index.jsx): `app/routes/app._index.jsx`
- [Scope update webhook](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/webhooks.app.scopes_update.jsx): `app/routes/webhooks.app.scopes_update.jsx`
- [Uninstall webhook](https://github.com/mortalmen/first_app_shopify/blob/main/app/routes/webhooks.app.uninstalled.jsx): `app/routes/webhooks.app.uninstalled.jsx`

### Other components

- **Merchant**
- **Shopify Admin API**

## Connections

- Merchant → Login landing: opens app (evidence: `README.md`)
- Login landing → Login handler: submits login (evidence: `app/routes/_index/route.jsx`)
- Login landing → Embedded app shell: redirects shop (evidence: `app/routes/_index/route.jsx`)
- Login handler → Shopify setup: validates login (evidence: `app/routes/auth.login/route.jsx`)
- Shopify setup → Session database: stores sessions (evidence: `app/shopify.server.js`)
- Embedded app shell → Shopify setup: authenticates admin (evidence: `app/routes/app.jsx`)
- Customer route → Shopify setup: authenticates admin (evidence: `app/routes/app.customers.jsx`)
- Customer route → Customer queries and VIP tags: loads and updates (evidence: `app/routes/app.customers.jsx`)
- Customer route → VIP threshold controls: renders controls (evidence: `app/routes/app.customers.jsx`)
- Customer route → Customer summary card: renders customers (evidence: `app/routes/app.customers.jsx`)
- VIP threshold controls → Customer route: submits threshold (evidence: `app/routes/app.customers.jsx`)
- Customer queries and VIP tags → Shopify Admin API: queries and tags (evidence: `app/features/customers/customers.server.js`)
- Product and metafield demo → Shopify setup: authenticates admin (evidence: `app/routes/app._index.jsx`)
- Product and metafield demo → Shopify Admin API: creates product and metaobject (evidence: `app/routes/app._index.jsx`)
- Scope update webhook → Shopify setup: uses authentication (evidence: `app/routes/webhooks.app.scopes_update.jsx`)
- Scope update webhook → Session database: updates sessions (evidence: `app/routes/webhooks.app.scopes_update.jsx`)
- Uninstall webhook → Shopify setup: uses authentication (evidence: `app/routes/webhooks.app.uninstalled.jsx`)
- Uninstall webhook → Session database: updates sessions (evidence: `app/routes/webhooks.app.uninstalled.jsx`)
