# Deployment and runtime

## Logical deployment

```mermaid
flowchart LR
  subgraph Edge["Edge"]
    CDN[Optional CDN / static]
  end

  subgraph App["Application tier"]
    WEB[Next.js server or static export]
    PHP[PHP-FPM / Laravel]
  end

  subgraph Support["Supporting services"]
    CRON[Scheduler: fx:sync-system-rates]
  end

  Browser --> CDN
  CDN --> WEB
  WEB -->|NEXT_PUBLIC_API_URL| PHP
  PHP --> CRON
```

## HTTP request lifecycle (staff UI)

```mermaid
sequenceDiagram
  participant B as Browser
  participant N as Next.js
  participant L as Laravel API
  participant D as Database

  B->>N: GET /dashboard (HTML)
  N-->>B: Page + JS bundle
  B->>L: GET /api/user (Bearer)
  L->>D: Load user + org
  D-->>L: Row
  L-->>B: JSON workspace user
  B->>L: GET /api/grants (Bearer + modules)
  L-->>B: JSON list
```

## Configuration touchpoints

```mermaid
mindmap
  root((Runtime config))
    Laravel
      config/app.php
      config/modules.php
      config/filesystems.php organisation_private
      config/sanctum.php
      config/rbac.php
    Next
      NEXT_PUBLIC_API_URL
    Env
      APP_URL
      DB_*
      FILESYSTEM_DISK
```

## Storage layout (conceptual)

```mermaid
flowchart TB
  subgraph Disks["Configured disks"]
    OP[organisation_private]
    LOC[local / private app]
    PUB[public / logos via signed URL where applicable]
  end

  subgraph Use["Typical use"]
    GA[Grant attachments]
    VR[Vendor registration PDF]
    LG[Org logos / branding files]
  end

  OP --> GA
  OP --> VR
  OP --> LG
```
