Skip to main content

Flow Diagrams

Three maps. The outcome map asks what success looks like. The dependency map asks what it sits on. The value stream map traces the flow from operator intent to customer access.

Outcome Map

What does a superadmin need to make happen, and how does success change?

CURRENT STATE                          TARGET STATE
─────────────────────────────────────  ──────────────────────────────────────
Superadmin needs org created           Superadmin fills form at /admin/orgs/new
  → opens DB client                      → org created in < 30s
  → writes INSERT manually               → visible in org list immediately

Login goes straight to dashboard       Login detects multiple orgs
  → single org assumed                   → org picker appears
  → no way to switch orgs               → user selects org, enters dashboard

Resource types only via seed function  Resource types editable in /admin/reference-data
  → requires code change + deploy        → INSERT row via UI
  → requires developer                   → active in permission matrix same day

admin.dreamineering.com → 403          admin.dreamineering.com → /admin
  → Better Auth invalid origin           → trustedOrigins updated
  → deployed but broken                  → fully operational
OutcomePassFail
Org creationNew org in DB within 30s of form submit404 on /admin/orgs/new, or DB insert required
Org pickerUser with 2+ orgs sees selector at loginDashboard loads without asking which org
Resource type insertNew type in roles permission matrixStill requires seed function re-run
Superadmin isolationOrg admin cannot reach /admin/*Any user can browse to /admin
Cross-org queriesSuperadmin sees all orgs; admin sees zero othersOrg admin can view other org members

The outcome map names what success looks like. The dependency map asks what it sits on.

Dependency Map

What does the admin portal sit on, and what sits on it?

Admin Portal
│
├── DEPENDS ON (must exist first)
│   ├── Better Auth authentication [LIVE]
│   │   └── Custom claims (role=superadmin) [GAP — claim not yet defined]
│   │   └── trustedOrigins [GAP — admin.dreamineering.com missing]
│   ├── Multi-tenancy schema [LIVE]
│   │   ├── organisations table [LIVE]
│   │   ├── organisationId FK on all tenant tables [LIVE]
│   │   └── org creation server action [GAP — does not exist]
│   ├── Next.js middleware [LIVE]
│   │   └── Superadmin bypass layer [GAP — not written]
│   └── governance_resource_types table [LIVE — seed only, no UI]
│
└── ENABLES (blocked until this exists)
    ├── Customer 2 onboarding [BLOCKED]
    ├── Multi-org login flow [BLOCKED]
    ├── New resource types without a developer [BLOCKED]
    └── Org lifecycle management (suspend, archive) [BLOCKED]

Critical Path

AUTHZ-004: Superadmin auth claim + middleware guard
    ↓
ORG-001: Org create + list at /admin
    ↓ (parallel)
ORG-002: Org picker on login      REF-001: Reference data UI at /admin/reference-data
    ↓
ORG-003: Org suspend/archive

Blast Radius

LayerImpactRisk
MiddlewareAll routes pass through itSuperadmin bypass must not weaken org-scoped protection
organisations tableSchema unchanged — new INSERTs onlyLow — additive only
governance_resource_typesNew UI adds rows; existing rows unchangedLow — UI is additive
Login flowOrg picker adds conditional stepMedium — must not break single-org login
All server actionsStill scoped by organisationIdNone — superadmin bypass is middleware-only

The dependency map names what must exist. The value stream traces the flow.

Value Stream Map

How does value flow from operator intent to customer access?

OPERATOR INTENT                    SYSTEM PROCESSING                  CUSTOMER VALUE
──────────────────                 ──────────────────                   ──────────────

1. "Create org for Customer 2"     Better Auth validates superadmin     Customer 2 signs in
   ↓                               claim in session                    ↓
2. Navigate to /admin/orgs/new     ↓                                   Org picker renders
   ↓                               Middleware allows /admin/* access    ↓
3. Fill name + slug                ↓                                   Selects their org
   ↓                               createOrgAction() INSERTs row       ↓
4. Submit                          ↓                                   Lands on dashboard
   ↓                               Org appears in list + picker        ↓
5. Invite customer admin           ↓                                   Customer admin manages
                                   Auth callback detects multi-org     their own users
                                   ↓
                                   Org picker rendered
                                   ↓
                                   Customer selects org → dashboard

CYCLE TIME TARGET: < 5 minutes from operator intent to customer first login
CURRENT CYCLE TIME: ∞ (requires developer + DB access + deploy)

Value Bottlenecks

BottleneckCurrentTarget
Auth origin403 — admin domain not trustedConfig fix — minutes
Org creationRequires developer + DBForm submit — 30 seconds
Org switchingImpossible — hardcoded to single orgOrg picker at login
Reference dataCode change + deployAdmin UI — same session