# nastoi/checkonit architecture

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

- Interactive diagram: https://gitdiagram.com/nastoi/checkonit
- Repository: https://github.com/nastoi/checkonit

## Overview

CheckOnIt is a staff-facing learner-operations chat UI, not the assistant workflow engine. Staff sign in with Microsoft Entra ID when enabled (or use a development identity), enter a learner email, and send messages through the chat interface. The server validates access and input, attaches staff identity and learner email, and proxies requests to Dify while carrying its conversation ID. The UI also provides quick actions for status, attendance, modules, payments, and support tickets. Dify’s downstream workflow is documented, but its implementation is outside this repository.

Main entry points: [`auth.ts`](https://github.com/nastoi/checkonit/blob/main/auth.ts) (Entra auth), [`app/chat/page.tsx`](https://github.com/nastoi/checkonit/blob/main/app/chat/page.tsx) (Chat access gate), [`app/api/chat/route.ts`](https://github.com/nastoi/checkonit/blob/main/app/api/chat/route.ts) (Chat proxy), [`lib-auth-mode.ts`](https://github.com/nastoi/checkonit/blob/main/lib-auth-mode.ts) (Auth mode)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and identity"]
  node_home["Sign-in page<br/>[page.tsx]"]
  node_authconfig["Entra auth<br/>[auth.ts]"]
  node_authroute["Auth callback route<br/>[route.ts]"]
  node_authmode["Auth mode<br/>[lib-auth-mode.ts]"]
  node_signout["Sign-out page<br/>[page.tsx]"]
end

subgraph group_interface["Staff chat interface"]
  node_chatpage["Chat access gate<br/>[page.tsx]"]
  node_chatshell["Chat and quick actions<br/>[ChatShell.tsx]"]
end

subgraph group_assistant["Assistant integration"]
  node_chatapi["Chat proxy<br/>[route.ts]"]
end

node_staff(("Staff user"))
node_entra(("Microsoft Entra ID"))
node_dify{{"Dify service"}}
node_downstream{{"Dify workflow stack"}}

node_staff -->|"opens"| node_home
node_home -->|"signs in via"| node_authconfig
node_authconfig -->|"authenticates with"| node_entra
node_authroute -->|"dispatches to"| node_authconfig
node_home -->|"checks mode"| node_authmode
node_staff -->|"opens chat"| node_chatpage
node_chatpage -->|"checks session"| node_authconfig
node_chatpage -->|"checks mode"| node_authmode
node_chatpage -->|"renders"| node_chatshell
node_staff -->|"requests sign-out"| node_signout
node_signout -->|"signs out via"| node_authconfig
node_signout -->|"checks mode"| node_authmode
node_chatshell -->|"posts messages"| node_chatapi
node_chatapi -->|"checks session"| node_authconfig
node_chatapi -->|"selects staff identity"| node_authmode
node_chatapi -->|"posts chat request"| node_dify
node_dify -->|"uses workflows"| node_downstream

click node_home "https://github.com/nastoi/checkonit/blob/main/app/page.tsx"
click node_authconfig "https://github.com/nastoi/checkonit/blob/main/auth.ts"
click node_authroute "https://github.com/nastoi/checkonit/blob/main/app/api/auth/%5B...nextauth%5D/route.ts"
click node_authmode "https://github.com/nastoi/checkonit/blob/main/lib-auth-mode.ts"
click node_signout "https://github.com/nastoi/checkonit/blob/main/app/signout/page.tsx"
click node_chatpage "https://github.com/nastoi/checkonit/blob/main/app/chat/page.tsx"
click node_chatshell "https://github.com/nastoi/checkonit/blob/main/components/ChatShell.tsx"
click node_chatapi "https://github.com/nastoi/checkonit/blob/main/app/api/chat/route.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_home,node_authconfig,node_authroute,node_authmode,node_signout,node_staff toneBlue
class node_chatpage,node_chatshell toneAmber
class node_chatapi toneMint
class node_entra,node_dify,node_downstream toneIndigo
```

## Components

### Access and identity

- [Sign-in page](https://github.com/nastoi/checkonit/blob/main/app/page.tsx): `app/page.tsx`
- [Entra auth](https://github.com/nastoi/checkonit/blob/main/auth.ts): `auth.ts`
- [Auth callback route](https://github.com/nastoi/checkonit/blob/main/app/api/auth/%5B...nextauth%5D/route.ts): `app/api/auth/[...nextauth]/route.ts`
- [Auth mode](https://github.com/nastoi/checkonit/blob/main/lib-auth-mode.ts): `lib-auth-mode.ts`
- [Sign-out page](https://github.com/nastoi/checkonit/blob/main/app/signout/page.tsx): `app/signout/page.tsx`

### Staff chat interface

- [Chat access gate](https://github.com/nastoi/checkonit/blob/main/app/chat/page.tsx): `app/chat/page.tsx`
- [Chat and quick actions](https://github.com/nastoi/checkonit/blob/main/components/ChatShell.tsx): `components/ChatShell.tsx`

### Assistant integration

- [Chat proxy](https://github.com/nastoi/checkonit/blob/main/app/api/chat/route.ts): `app/api/chat/route.ts`

### Other components

- **Staff user**
- **Microsoft Entra ID**
- **Dify service**
- **Dify workflow stack**

## Connections

- Staff user → Sign-in page: opens (evidence: `README.md`)
- Sign-in page → Entra auth: signs in via (evidence: `app/page.tsx`)
- Entra auth → Microsoft Entra ID: authenticates with (evidence: `auth.ts`)
- Auth callback route → Entra auth: dispatches to (evidence: `app/api/auth/[...nextauth]/route.ts`)
- Sign-in page → Auth mode: checks mode (evidence: `app/page.tsx`)
- Staff user → Chat access gate: opens chat (evidence: `README.md`)
- Chat access gate → Entra auth: checks session (evidence: `app/chat/page.tsx`)
- Chat access gate → Auth mode: checks mode (evidence: `app/chat/page.tsx`)
- Chat access gate → Chat and quick actions: renders (evidence: `app/chat/page.tsx`)
- Staff user → Sign-out page: requests sign-out (evidence: `README.md`)
- Sign-out page → Entra auth: signs out via (evidence: `app/signout/page.tsx`)
- Sign-out page → Auth mode: checks mode (evidence: `app/signout/page.tsx`)
- Chat and quick actions → Chat proxy: posts messages (evidence: `components/ChatShell.tsx`)
- Chat proxy → Entra auth: checks session (evidence: `app/api/chat/route.ts`)
- Chat proxy → Auth mode: selects staff identity (evidence: `app/api/chat/route.ts`)
- Chat proxy → Dify service: posts chat request (evidence: `app/api/chat/route.ts`)
- Dify service → Dify workflow stack: uses workflows (evidence: `README.md`)
