# tkiwz/ageis architecture

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

- Interactive diagram: https://gitdiagram.com/tkiwz/ageis
- Repository: https://github.com/tkiwz/ageis

## Overview

AEGIS is a Next.js HSSE command platform for industrial sites. Users work through command, operations, safety, governance, intelligence, and administration screens; API routes expose those workflows and use Prisma-backed persistence. Distinct product stages include device telemetry, operational and safety records, compliance oversight, and AI-assisted analysis. The excerpts show guarded Claude calls, pipeline alert cascades, conversational voice actions, and knowledge contribution processing. Several domain routes are represented by their existing API directories because their implementations were not sampled; links between those subsystems are omitted unless documented or directly evidenced.

Main entry points: [`src/lib/db.ts`](https://github.com/tkiwz/ageis/blob/main/src/lib/db.ts) (Prisma database), [`src/lib/ai/guarded-claude.ts`](https://github.com/tkiwz/ageis/blob/main/src/lib/ai/guarded-claude.ts) (Guarded Claude), [`src/app/(authenticated)/operations`](https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/operations) (Operations workspace), [`src/lib/knowledge/ingest.ts`](https://github.com/tkiwz/ageis/blob/main/src/lib/knowledge/ingest.ts) (Knowledge ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_command["Command center"]
  node_opsui["Operations workspace"]
  node_safetyui["Safety workspace"]
  node_govui["Governance workspace"]
  node_intelligenceui["Intelligence workspace"]
  node_adminui["Administration"]
end

subgraph group_operations["Site operations"]
  node_deviceingest["Device telemetry"]
  node_opsapi["Operations APIs"]
  node_pipelineanalysis["Pipeline analysis"]
  node_pipeline3d["Pipeline visualization"]
end

subgraph group_safety["Safety governance"]
  node_safetyapi["Safety APIs"]
  node_governanceapi["Compliance APIs"]
end

subgraph group_intelligence["AI intelligence"]
  node_knowledgeapi["Knowledge contributions"]
  node_knowledgeingest["Knowledge ingestion<br/>[ingest.ts]"]
  node_brainapi["Brain APIs"]
  node_voiceapi["Voice parsing<br/>[route.ts]"]
  node_aiwrapper["Guarded Claude<br/>[guarded-claude.ts]"]
end

subgraph group_platform["Platform services"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_database[("Prisma database<br/>[db.ts]")]
end

node_user(("Site user"))
node_claude["Claude service"]

node_user -->|"uses"| node_command
node_user -->|"uses"| node_opsui
node_user -->|"uses"| node_safetyui
node_user -->|"uses"| node_govui
node_user -->|"uses"| node_intelligenceui
node_user -->|"uses"| node_adminui
node_command -.->|"requests"| node_opsapi
node_opsui -.->|"requests"| node_opsapi
node_safetyui -.->|"requests"| node_safetyapi
node_govui -.->|"requests"| node_governanceapi
node_intelligenceui -.->|"requests"| node_brainapi
node_adminui -.->|"authenticates"| node_auth
node_deviceingest -.->|"stores telemetry"| node_database
node_opsapi -->|"reads and writes"| node_database
node_safetyapi -->|"reads and writes"| node_database
node_governanceapi -->|"reads and writes"| node_database
node_pipelineanalysis -->|"requests analysis"| node_aiwrapper
node_pipelineanalysis -->|"records alert cascade"| node_database
node_opsui -.->|"renders"| node_pipeline3d
node_knowledgeapi -->|"processes contributions"| node_knowledgeingest
node_knowledgeingest -->|"extracts knowledge"| node_aiwrapper
node_knowledgeingest -->|"stores contributions"| node_database
node_voiceapi -->|"parses intent"| node_aiwrapper
node_aiwrapper -->|"calls"| node_claude
node_auth -->|"looks up users"| node_database
node_auth -->|"appends audit"| node_database

click node_command "https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/command"
click node_opsui "https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/operations"
click node_safetyui "https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/safety"
click node_govui "https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/governance"
click node_intelligenceui "https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/intelligence"
click node_adminui "https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/admin"
click node_deviceingest "https://github.com/tkiwz/ageis/tree/main/src/app/api/devices"
click node_opsapi "https://github.com/tkiwz/ageis/tree/main/src/app/api/pipelines"
click node_pipelineanalysis "https://github.com/tkiwz/ageis/blob/main/src/lib/autonomy/pipeline-analyzer.ts"
click node_pipeline3d "https://github.com/tkiwz/ageis/blob/main/src/components/three-d/Pipeline3DScene.tsx"
click node_safetyapi "https://github.com/tkiwz/ageis/tree/main/src/app/api/incidents"
click node_governanceapi "https://github.com/tkiwz/ageis/tree/main/src/app/api/compliance"
click node_knowledgeapi "https://github.com/tkiwz/ageis/tree/main/src/app/api/knowledge"
click node_knowledgeingest "https://github.com/tkiwz/ageis/blob/main/src/lib/knowledge/ingest.ts"
click node_brainapi "https://github.com/tkiwz/ageis/tree/main/src/app/api/brain"
click node_voiceapi "https://github.com/tkiwz/ageis/blob/main/src/app/api/voice/parse/route.ts"
click node_aiwrapper "https://github.com/tkiwz/ageis/blob/main/src/lib/ai/guarded-claude.ts"
click node_auth "https://github.com/tkiwz/ageis/blob/main/src/auth.ts"
click node_database "https://github.com/tkiwz/ageis/blob/main/src/lib/db.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_command,node_opsui,node_safetyui,node_govui,node_intelligenceui,node_adminui,node_user toneBlue
class node_deviceingest,node_opsapi,node_pipelineanalysis,node_pipeline3d toneAmber
class node_safetyapi,node_governanceapi toneMint
class node_knowledgeapi,node_knowledgeingest,node_brainapi,node_voiceapi,node_aiwrapper toneRose
class node_auth,node_database,node_claude toneIndigo
```

## Components

### User experience

- [Command center](https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/command): `src/app/(authenticated)/command`
- [Operations workspace](https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/operations): `src/app/(authenticated)/operations`
- [Safety workspace](https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/safety): `src/app/(authenticated)/safety`
- [Governance workspace](https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/governance): `src/app/(authenticated)/governance`
- [Intelligence workspace](https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/intelligence): `src/app/(authenticated)/intelligence`
- [Administration](https://github.com/tkiwz/ageis/tree/main/src/app/(authenticated)/admin): `src/app/(authenticated)/admin`

### Site operations

- [Device telemetry](https://github.com/tkiwz/ageis/tree/main/src/app/api/devices): `src/app/api/devices`
- [Operations APIs](https://github.com/tkiwz/ageis/tree/main/src/app/api/pipelines): `src/app/api/pipelines`
- [Pipeline analysis](https://github.com/tkiwz/ageis/blob/main/src/lib/autonomy/pipeline-analyzer.ts): `src/lib/autonomy/pipeline-analyzer.ts`
- [Pipeline visualization](https://github.com/tkiwz/ageis/blob/main/src/components/three-d/Pipeline3DScene.tsx): `src/components/three-d/Pipeline3DScene.tsx`

### Safety governance

- [Safety APIs](https://github.com/tkiwz/ageis/tree/main/src/app/api/incidents): `src/app/api/incidents`
- [Compliance APIs](https://github.com/tkiwz/ageis/tree/main/src/app/api/compliance): `src/app/api/compliance`

### AI intelligence

- [Knowledge contributions](https://github.com/tkiwz/ageis/tree/main/src/app/api/knowledge): `src/app/api/knowledge`
- [Knowledge ingestion](https://github.com/tkiwz/ageis/blob/main/src/lib/knowledge/ingest.ts): `src/lib/knowledge/ingest.ts`
- [Brain APIs](https://github.com/tkiwz/ageis/tree/main/src/app/api/brain): `src/app/api/brain`
- [Voice parsing](https://github.com/tkiwz/ageis/blob/main/src/app/api/voice/parse/route.ts): `src/app/api/voice/parse/route.ts`
- [Guarded Claude](https://github.com/tkiwz/ageis/blob/main/src/lib/ai/guarded-claude.ts): `src/lib/ai/guarded-claude.ts`

### Platform services

- [Authentication](https://github.com/tkiwz/ageis/blob/main/src/auth.ts): `src/auth.ts`
- [Prisma database](https://github.com/tkiwz/ageis/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Other components

- **Site user**
- **Claude service**

## Connections

- Site user → Command center: uses (evidence: `README.md`)
- Site user → Operations workspace: uses (evidence: `README.md`)
- Site user → Safety workspace: uses (evidence: `README.md`)
- Site user → Governance workspace: uses (evidence: `README.md`)
- Site user → Intelligence workspace: uses (evidence: `README.md`)
- Site user → Administration: uses (evidence: `README.md`)
- Command center → Operations APIs: requests
- Operations workspace → Operations APIs: requests
- Safety workspace → Safety APIs: requests
- Governance workspace → Compliance APIs: requests
- Intelligence workspace → Brain APIs: requests
- Administration → Authentication: authenticates
- Device telemetry → Prisma database: stores telemetry
- Operations APIs → Prisma database: reads and writes (evidence: `README.md`)
- Safety APIs → Prisma database: reads and writes (evidence: `README.md`)
- Compliance APIs → Prisma database: reads and writes (evidence: `README.md`)
- Pipeline analysis → Guarded Claude: requests analysis (evidence: `src/lib/autonomy/pipeline-analyzer.ts`)
- Pipeline analysis → Prisma database: records alert cascade (evidence: `src/lib/autonomy/pipeline-analyzer.ts`)
- Operations workspace → Pipeline visualization: renders
- Knowledge contributions → Knowledge ingestion: processes contributions (evidence: `src/lib/knowledge/ingest.ts`)
- Knowledge ingestion → Guarded Claude: extracts knowledge (evidence: `src/lib/knowledge/ingest.ts`)
- Knowledge ingestion → Prisma database: stores contributions (evidence: `src/lib/knowledge/ingest.ts`)
- Voice parsing → Guarded Claude: parses intent (evidence: `src/app/api/voice/parse/route.ts`)
- Guarded Claude → Claude service: calls (evidence: `src/lib/ai/guarded-claude.ts`)
- Authentication → Prisma database: looks up users (evidence: `src/auth.ts`)
- Authentication → Prisma database: appends audit (evidence: `src/auth.ts`)
