# gritgridtechnologies/gritgrid-workbench architecture

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

- Interactive diagram: https://gitdiagram.com/gritgridtechnologies/gritgrid-workbench
- Repository: https://github.com/gritgridtechnologies/gritgrid-workbench

## Overview

GritGrid Workbench is an employee-facing control center with server-side session authentication and an AI-workforce interface. Employees sign in, inspect workforce state, and use the dashboard or task page to view and act on backend tasks; the API gateway restricts mutations by role and proxies requests to the configured workforce service. The documented AI capabilities also include agents, orchestration, approvals, memory, events, runs, artifacts, and providers. The excerpts do not show dashboard request call sites, so those UI-to-client links are marked unverified; other links use shown calls or README statements.

Main entry points: [`lib/ai/client.ts`](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts) (AI API client), [`components/workbench/workforce-dashboard.tsx`](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/components/workbench/workforce-dashboard.tsx) (Workforce dashboard), [`app/api/ai/[...path]/route.ts`](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/api/ai/%5B...path%5D/route.ts) (AI proxy route), [`lib/auth-server.ts`](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/auth-server.ts) (Session service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Authentication"]
  node_login["Sign-in page<br/>[page.tsx]"]
  node_auth_ui["Auth provider<br/>[auth.tsx]"]
  node_auth_routes["Session API routes"]
  node_auth_server["Session service<br/>[auth-server.ts]"]
end

subgraph group_workforce["AI Workforce"]
  node_dashboard_page["Workbench home<br/>[page.tsx]"]
  node_dashboard["Workforce dashboard"]
  node_ai_workforce["AI workforce views<br/>[ai-workforce.tsx]"]
  node_task_page["Task detail page<br/>[page.tsx]"]
  node_approval_memory["Approvals and memory<br/>[client.ts]"]
  node_workforce_ops["Agents and orchestration<br/>[client.ts]"]
  node_workforce_observe["Status and activity<br/>[client.ts]"]
  node_artifacts_providers["Artifacts and providers<br/>[client.ts]"]
end

subgraph group_gateway["Backend Gateway"]
  node_ai_client["AI API client<br/>[client.ts]"]
  node_ai_proxy["AI proxy route<br/>[route.ts]"]
end

subgraph group_contracts["AI Data Contracts"]
  node_ai_types["Workforce data contracts<br/>[types.ts]"]
end

node_employee(("Workbench employee"))
node_neon[("Neon PostgreSQL")]
node_ai_backend["FastAPI workforce"]

node_employee -->|"signs in"| node_login
node_login -->|"uses"| node_auth_ui
node_auth_ui -->|"fetches session and login"| node_auth_routes
node_auth_routes -->|"authenticates and checks sessions"| node_auth_server
node_auth_server -->|"reads and writes sessions"| node_neon
node_employee -->|"opens workbench"| node_dashboard_page
node_dashboard_page -->|"renders"| node_dashboard
node_dashboard -.->|"renders workforce views"| node_ai_workforce
node_dashboard -.->|"requests workforce data"| node_ai_client
node_employee -->|"opens task"| node_task_page
node_task_page -->|"loads task"| node_ai_client
node_ai_client -->|"uses contracts"| node_ai_types
node_ai_client -.->|"requests same-origin API"| node_ai_proxy
node_ai_proxy -->|"checks mutation role"| node_auth_server
node_ai_proxy -->|"proxies requests"| node_ai_backend
node_ai_client -->|"calls agent and orchestration endpoints"| node_workforce_ops
node_ai_client -->|"calls approval and memory endpoints"| node_approval_memory
node_ai_client -->|"calls status and activity endpoints"| node_workforce_observe
node_ai_client -->|"calls catalog endpoints"| node_artifacts_providers

click node_login "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/login/page.tsx"
click node_auth_ui "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/auth.tsx"
click node_auth_routes "https://github.com/gritgridtechnologies/gritgrid-workbench/tree/main/app/api/auth"
click node_auth_server "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/auth-server.ts"
click node_dashboard_page "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/page.tsx"
click node_dashboard "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/components/workbench/workforce-dashboard.tsx"
click node_ai_workforce "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/components/workbench/ai-workforce.tsx"
click node_task_page "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/tasks/%5BtaskId%5D/page.tsx"
click node_ai_client "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts"
click node_ai_proxy "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/api/ai/%5B...path%5D/route.ts"
click node_ai_types "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/types.ts"
click node_approval_memory "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts"
click node_workforce_ops "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts"
click node_workforce_observe "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts"
click node_artifacts_providers "https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.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_login,node_auth_ui,node_auth_routes,node_auth_server toneBlue
class node_dashboard_page,node_dashboard,node_ai_workforce,node_task_page,node_approval_memory,node_workforce_ops,node_workforce_observe,node_artifacts_providers,node_neon toneAmber
class node_ai_client,node_ai_proxy,node_ai_backend toneMint
class node_ai_types toneRose
class node_employee toneIndigo
```

## Components

### Authentication

- [Sign-in page](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Auth provider](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/auth.tsx): `lib/auth.tsx`
- [Session API routes](https://github.com/gritgridtechnologies/gritgrid-workbench/tree/main/app/api/auth): `app/api/auth`
- [Session service](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/auth-server.ts): `lib/auth-server.ts`

### AI Workforce

- [Workbench home](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/page.tsx): `app/page.tsx`
- [Workforce dashboard](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/components/workbench/workforce-dashboard.tsx): `components/workbench/workforce-dashboard.tsx`
- [AI workforce views](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/components/workbench/ai-workforce.tsx): `components/workbench/ai-workforce.tsx`
- [Task detail page](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/tasks/%5BtaskId%5D/page.tsx): `app/tasks/[taskId]/page.tsx`
- [Approvals and memory](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts): `lib/ai/client.ts`
- [Agents and orchestration](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts): `lib/ai/client.ts`
- [Status and activity](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts): `lib/ai/client.ts`
- [Artifacts and providers](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts): `lib/ai/client.ts`

### Backend Gateway

- [AI API client](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/client.ts): `lib/ai/client.ts`
- [AI proxy route](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/app/api/ai/%5B...path%5D/route.ts): `app/api/ai/[...path]/route.ts`

### AI Data Contracts

- [Workforce data contracts](https://github.com/gritgridtechnologies/gritgrid-workbench/blob/main/lib/ai/types.ts): `lib/ai/types.ts`

### Other components

- **Workbench employee**
- **Neon PostgreSQL**
- **FastAPI workforce**

## Connections

- Workbench employee → Sign-in page: signs in
- Sign-in page → Auth provider: uses (evidence: `app/login/page.tsx`)
- Auth provider → Session API routes: fetches session and login (evidence: `lib/auth.tsx`)
- Session API routes → Session service: authenticates and checks sessions (evidence: `app/api/auth/login/route.ts`)
- Session service → Neon PostgreSQL: reads and writes sessions (evidence: `lib/auth-server.ts`)
- Workbench employee → Workbench home: opens workbench
- Workbench home → Workforce dashboard: renders (evidence: `app/page.tsx`)
- Workforce dashboard → AI workforce views: renders workforce views
- Workforce dashboard → AI API client: requests workforce data (evidence: `components/workbench/workforce-dashboard.tsx`)
- Workbench employee → Task detail page: opens task (evidence: `app/tasks/[taskId]/page.tsx`)
- Task detail page → AI API client: loads task (evidence: `app/tasks/[taskId]/page.tsx`)
- AI API client → Workforce data contracts: uses contracts (evidence: `lib/ai/client.ts`)
- AI API client → AI proxy route: requests same-origin API (evidence: `app/api/ai/[...path]/route.ts`)
- AI proxy route → Session service: checks mutation role (evidence: `app/api/ai/[...path]/route.ts`)
- AI proxy route → FastAPI workforce: proxies requests (evidence: `app/api/ai/[...path]/route.ts`)
- AI API client → Agents and orchestration: calls agent and orchestration endpoints (evidence: `lib/ai/client.ts`)
- AI API client → Approvals and memory: calls approval and memory endpoints (evidence: `lib/ai/client.ts`)
- AI API client → Status and activity: calls status and activity endpoints (evidence: `lib/ai/client.ts`)
- AI API client → Artifacts and providers: calls catalog endpoints (evidence: `lib/ai/client.ts`)
