# sypnosis2019/auto-fulfillment-location-routing architecture

> Architecture diagram of the GitHub repository sypnosis2019/auto-fulfillment-location-routing, 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/sypnosis2019/auto-fulfillment-location-routing
- Repository: https://github.com/sypnosis2019/auto-fulfillment-location-routing

## Overview

This is a Shopify embedded app for configuring automatic fulfillment routing. An administrator authenticates, chooses a fallback location and enables routing; Shopify order-created webhooks then trigger a service that finds eligible out-of-stock Continue-policy items and moves them through the Admin GraphQL API. The graph also shows login, session persistence, and documented webhook handling. Source excerpts establish the settings and order-routing calls; less detailed webhook behavior is documented or omitted where its implementation was not sampled.

Main entry points: [`app/shopify.server.ts`](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/shopify.server.ts) (Shopify integration), [`app/services/auto-routing.server.ts`](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/services/auto-routing.server.ts) (Routing settings records), [`app/db.server.ts`](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/db.server.ts) (Prisma database), [`app/routes/auth.login/route.tsx`](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/auth.login/route.tsx) (Login flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["App access"]
  node_landing["Entry page<br/>[route.tsx]"]
  node_login["Login flow<br/>[route.tsx]"]
  node_loginerrors["Login errors<br/>[error.server.tsx]"]
  node_appframe["Embedded app shell<br/>[app.tsx]"]
  node_shopifyconfig["Shopify integration<br/>[shopify.server.ts]"]
  node_scopeswebhook["Scope-update webhook"]
  node_uninstallwebhook["Uninstall webhook"]
end

subgraph group_settings["Routing settings"]
  node_settingspage["Routing settings UI<br/>[app.settings.tsx]"]
  node_dashboard["Routing dashboard<br/>[app._index.tsx]"]
end

subgraph group_routing["Order routing"]
  node_routingservice["Auto-routing service"]
  node_orderswebhook["Order-created webhook"]
end

subgraph group_persistence["Persistence"]
  node_sessionstore["Session storage adapter<br/>[shopify.server.ts]"]
  node_database[("Prisma database<br/>[db.server.ts]")]
  node_settingsdata[("Routing settings records")]
end

node_merchant(("Shop administrator"))
node_shopify(("Shopify platform"))

node_merchant -->|"opens"| node_landing
node_landing -->|"submits login"| node_login
node_login -->|"validates login"| node_shopifyconfig
node_login -->|"formats errors"| node_loginerrors
node_shopify -.->|"authenticates"| node_shopifyconfig
node_appframe -->|"authenticates admin"| node_shopifyconfig
node_merchant -.->|"configures routing"| node_settingspage
node_merchant -->|"views settings"| node_dashboard
node_settingspage -->|"authenticates admin"| node_shopifyconfig
node_dashboard -->|"authenticates admin"| node_shopifyconfig
node_settingspage -->|"reads and saves"| node_settingsdata
node_dashboard -->|"reads and saves"| node_settingsdata
node_orderswebhook -->|"authenticates webhook"| node_shopifyconfig
node_shopify -.->|"sends order event"| node_orderswebhook
node_orderswebhook -->|"processes order"| node_routingservice
node_routingservice -->|"loads settings"| node_settingsdata
node_routingservice -->|"queries and moves fulfillment"| node_shopify
node_shopifyconfig -->|"configures sessions"| node_sessionstore
node_sessionstore -->|"persists sessions"| node_database
node_settingsdata -->|"queries and writes"| node_database
node_scopeswebhook -.->|"authenticates webhook"| node_shopifyconfig
node_scopeswebhook -.->|"uses database"| node_database
node_uninstallwebhook -.->|"authenticates webhook"| node_shopifyconfig
node_uninstallwebhook -.->|"uses database"| node_database

click node_landing "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/_index/route.tsx"
click node_login "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/auth.login/route.tsx"
click node_loginerrors "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/auth.login/error.server.tsx"
click node_appframe "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/app.tsx"
click node_shopifyconfig "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/shopify.server.ts"
click node_settingspage "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/app.settings.tsx"
click node_dashboard "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/app._index.tsx"
click node_routingservice "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/services/auto-routing.server.ts"
click node_orderswebhook "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/webhooks.app.orders_create.tsx"
click node_scopeswebhook "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/webhooks.app.scopes_update.tsx"
click node_uninstallwebhook "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/webhooks.app.uninstalled.tsx"
click node_sessionstore "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/shopify.server.ts"
click node_database "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/db.server.ts"
click node_settingsdata "https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/services/auto-routing.server.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_landing,node_login,node_loginerrors,node_appframe,node_shopifyconfig,node_scopeswebhook,node_uninstallwebhook toneBlue
class node_settingspage,node_dashboard toneAmber
class node_routingservice,node_orderswebhook toneMint
class node_sessionstore,node_database,node_settingsdata toneRose
class node_merchant,node_shopify toneIndigo
```

## Components

### App access

- [Entry page](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/_index/route.tsx): `app/routes/_index/route.tsx`
- [Login flow](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/auth.login/route.tsx): `app/routes/auth.login/route.tsx`
- [Login errors](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/auth.login/error.server.tsx): `app/routes/auth.login/error.server.tsx`
- [Embedded app shell](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/app.tsx): `app/routes/app.tsx`
- [Shopify integration](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/shopify.server.ts): `app/shopify.server.ts`
- [Scope-update webhook](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/webhooks.app.scopes_update.tsx): `app/routes/webhooks.app.scopes_update.tsx`
- [Uninstall webhook](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/webhooks.app.uninstalled.tsx): `app/routes/webhooks.app.uninstalled.tsx`

### Routing settings

- [Routing settings UI](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/app.settings.tsx): `app/routes/app.settings.tsx`
- [Routing dashboard](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/app._index.tsx): `app/routes/app._index.tsx`

### Order routing

- [Auto-routing service](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/services/auto-routing.server.ts): `app/services/auto-routing.server.ts`
- [Order-created webhook](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/routes/webhooks.app.orders_create.tsx): `app/routes/webhooks.app.orders_create.tsx`

### Persistence

- [Session storage adapter](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/shopify.server.ts): `app/shopify.server.ts`
- [Prisma database](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/db.server.ts): `app/db.server.ts`
- [Routing settings records](https://github.com/sypnosis2019/auto-fulfillment-location-routing/blob/main/app/services/auto-routing.server.ts): `app/services/auto-routing.server.ts`

### Other components

- **Shop administrator**
- **Shopify platform**

## Connections

- Shop administrator → Entry page: opens (evidence: `app/routes/_index/route.tsx`)
- Entry page → Login flow: submits login (evidence: `app/routes/_index/route.tsx`)
- Login flow → Shopify integration: validates login (evidence: `app/routes/auth.login/route.tsx`)
- Login flow → Login errors: formats errors (evidence: `app/routes/auth.login/route.tsx`)
- Shopify platform → Shopify integration: authenticates (evidence: `README.md`)
- Embedded app shell → Shopify integration: authenticates admin (evidence: `app/routes/app.tsx`)
- Shop administrator → Routing settings UI: configures routing (evidence: `README.md`)
- Shop administrator → Routing dashboard: views settings (evidence: `app/routes/app._index.tsx`)
- Routing settings UI → Shopify integration: authenticates admin (evidence: `app/routes/app.settings.tsx`)
- Routing dashboard → Shopify integration: authenticates admin (evidence: `app/routes/app._index.tsx`)
- Routing settings UI → Routing settings records: reads and saves (evidence: `app/routes/app.settings.tsx`)
- Routing dashboard → Routing settings records: reads and saves (evidence: `app/routes/app._index.tsx`)
- Order-created webhook → Shopify integration: authenticates webhook (evidence: `app/routes/webhooks.app.orders_create.tsx`)
- Shopify platform → Order-created webhook: sends order event (evidence: `README.md`)
- Order-created webhook → Auto-routing service: processes order (evidence: `app/routes/webhooks.app.orders_create.tsx`)
- Auto-routing service → Routing settings records: loads settings (evidence: `app/services/auto-routing.server.ts`)
- Auto-routing service → Shopify platform: queries and moves fulfillment (evidence: `app/services/auto-routing.server.ts`)
- Shopify integration → Session storage adapter: configures sessions (evidence: `app/shopify.server.ts`)
- Session storage adapter → Prisma database: persists sessions (evidence: `app/shopify.server.ts`)
- Routing settings records → Prisma database: queries and writes (evidence: `app/services/auto-routing.server.ts`)
- Scope-update webhook → Shopify integration: authenticates webhook (evidence: `app/routes/webhooks.app.scopes_update.tsx`)
- Scope-update webhook → Prisma database: uses database (evidence: `app/routes/webhooks.app.scopes_update.tsx`)
- Uninstall webhook → Shopify integration: authenticates webhook (evidence: `app/routes/webhooks.app.uninstalled.tsx`)
- Uninstall webhook → Prisma database: uses database (evidence: `app/routes/webhooks.app.uninstalled.tsx`)
