# navelya/prismai architecture

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

- Interactive diagram: https://gitdiagram.com/navelya/prismai
- Repository: https://github.com/navelya/prismai

## Overview

Prism AI is a chat-first creative automation platform: users describe a task, the chat system builds or edits a node graph, and execution dispatches graph nodes to produce media results shown in chat and the visual editor. The repository also includes workflow persistence, templates, collaboration, billing, and administration. Relationships below rely on README statements and the supplied source index/excerpts; unsampled implementations are represented only where the tree documents a substantial capability, and uncertain links are omitted.

Main entry points: [`components/chat/ChatInterface.tsx`](https://github.com/navelya/prismai/blob/main/components/chat/ChatInterface.tsx) (Chat interface), [`lib/workflow/dispatch-v2.ts`](https://github.com/navelya/prismai/blob/main/lib/workflow/dispatch-v2.ts) (Node dispatcher), [`app/api/chat/stream/route.ts`](https://github.com/navelya/prismai/blob/main/app/api/chat/stream/route.ts) (Chat stream API), [`lib/chat/tools/handlers.ts`](https://github.com/navelya/prismai/blob/main/lib/chat/tools/handlers.ts) (Workflow tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_chat_ui["Chat interface<br/>[ChatInterface.tsx]"]
  node_canvas["Visual editor<br/>[EditorCanvas.tsx]"]
end

subgraph group_chat["Chat workflow authoring"]
  node_chat_route["Chat stream API<br/>[route.ts]"]
  node_brain["Chat reasoning<br/>[index.ts]"]
  node_tool_handlers["Workflow tools<br/>[handlers.ts]"]
end

subgraph group_execution["Workflow execution"]
  node_start_api["Execution start API<br/>[route.ts]"]
  node_orchestrator["DAG orchestrator<br/>[orchestrator.ts]"]
  node_dispatcher["Node dispatcher<br/>[dispatch-v2.ts]"]
  node_node_registry["Server node registry<br/>[server-registry.ts]"]
  node_ai_node["AI generation node<br/>[executor.server.ts]"]
  node_result_format["Result formatting<br/>[result-format.ts]"]
end

subgraph group_state["State and persistence"]
  node_store["Client state store<br/>[app-store.ts]"]
  node_workflow_db[("Workflow persistence<br/>[workflows.ts]")]
end

subgraph group_platform["Platform capabilities"]
  node_templates["Workflow templates<br/>[route.ts]"]
  node_collaboration["Canvas collaboration"]
  node_billing["Credits and billing<br/>[cost.ts]"]
  node_admin["Administration<br/>[page.tsx]"]
end

node_designer(("Designer"))
node_provider{{"AI model provider"}}
node_supabase[("Supabase")]

node_designer -->|"describes task"| node_chat_ui
node_chat_ui -.->|"streams request"| node_chat_route
node_chat_route -->|"invokes reasoning"| node_brain
node_chat_route -->|"uses tools"| node_tool_handlers
node_tool_handlers -->|"edits graph"| node_canvas
node_designer -->|"inspects workflow"| node_canvas
node_designer -.->|"starts execution"| node_start_api
node_start_api -->|"dispatches roots"| node_dispatcher
node_orchestrator -->|"dispatches children"| node_dispatcher
node_dispatcher -->|"resolves node"| node_node_registry
node_node_registry -->|"registers executor"| node_ai_node
node_ai_node -.->|"requests generation"| node_provider
node_dispatcher -->|"formats output"| node_result_format
node_result_format -->|"renders results"| node_chat_ui
node_chat_ui -->|"updates state"| node_store
node_store -->|"autosaves workflow"| node_workflow_db
node_workflow_db -.->|"persists data"| node_supabase
node_designer -.->|"browses templates"| node_templates
node_designer -.->|"shares canvas"| node_collaboration
node_designer -.->|"manages credits"| node_billing
node_designer -.->|"administers platform"| node_admin

click node_chat_ui "https://github.com/navelya/prismai/blob/main/components/chat/ChatInterface.tsx"
click node_canvas "https://github.com/navelya/prismai/blob/main/components/editor/EditorCanvas.tsx"
click node_chat_route "https://github.com/navelya/prismai/blob/main/app/api/chat/stream/route.ts"
click node_brain "https://github.com/navelya/prismai/blob/main/lib/chat/index.ts"
click node_tool_handlers "https://github.com/navelya/prismai/blob/main/lib/chat/tools/handlers.ts"
click node_start_api "https://github.com/navelya/prismai/blob/main/app/api/executions/start/route.ts"
click node_orchestrator "https://github.com/navelya/prismai/blob/main/lib/workflow/orchestrator.ts"
click node_dispatcher "https://github.com/navelya/prismai/blob/main/lib/workflow/dispatch-v2.ts"
click node_node_registry "https://github.com/navelya/prismai/blob/main/lib/nodes/core/server-registry.ts"
click node_ai_node "https://github.com/navelya/prismai/blob/main/lib/nodes/plugins/ai_generator/executor.server.ts"
click node_result_format "https://github.com/navelya/prismai/blob/main/lib/workflow/result-format.ts"
click node_store "https://github.com/navelya/prismai/blob/main/lib/store/app-store.ts"
click node_workflow_db "https://github.com/navelya/prismai/blob/main/lib/db/workflows.ts"
click node_templates "https://github.com/navelya/prismai/blob/main/app/api/templates/route.ts"
click node_collaboration "https://github.com/navelya/prismai/blob/main/lib/hooks/use-workflow-collaboration.ts"
click node_billing "https://github.com/navelya/prismai/blob/main/lib/billing/cost.ts"
click node_admin "https://github.com/navelya/prismai/blob/main/app/admin/page.tsx"

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_chat_ui,node_canvas toneBlue
class node_chat_route,node_brain,node_tool_handlers,node_supabase toneAmber
class node_start_api,node_orchestrator,node_dispatcher,node_node_registry,node_ai_node,node_result_format toneMint
class node_store,node_workflow_db toneRose
class node_templates,node_collaboration,node_billing,node_admin,node_designer,node_provider toneIndigo
```

## Components

### User experience

- [Chat interface](https://github.com/navelya/prismai/blob/main/components/chat/ChatInterface.tsx): `components/chat/ChatInterface.tsx`
- [Visual editor](https://github.com/navelya/prismai/blob/main/components/editor/EditorCanvas.tsx): `components/editor/EditorCanvas.tsx`

### Chat workflow authoring

- [Chat stream API](https://github.com/navelya/prismai/blob/main/app/api/chat/stream/route.ts): `app/api/chat/stream/route.ts`
- [Chat reasoning](https://github.com/navelya/prismai/blob/main/lib/chat/index.ts): `lib/chat/index.ts`
- [Workflow tools](https://github.com/navelya/prismai/blob/main/lib/chat/tools/handlers.ts): `lib/chat/tools/handlers.ts`

### Workflow execution

- [Execution start API](https://github.com/navelya/prismai/blob/main/app/api/executions/start/route.ts): `app/api/executions/start/route.ts`
- [DAG orchestrator](https://github.com/navelya/prismai/blob/main/lib/workflow/orchestrator.ts): `lib/workflow/orchestrator.ts`
- [Node dispatcher](https://github.com/navelya/prismai/blob/main/lib/workflow/dispatch-v2.ts): `lib/workflow/dispatch-v2.ts`
- [Server node registry](https://github.com/navelya/prismai/blob/main/lib/nodes/core/server-registry.ts): `lib/nodes/core/server-registry.ts`
- [AI generation node](https://github.com/navelya/prismai/blob/main/lib/nodes/plugins/ai_generator/executor.server.ts): `lib/nodes/plugins/ai_generator/executor.server.ts`
- [Result formatting](https://github.com/navelya/prismai/blob/main/lib/workflow/result-format.ts): `lib/workflow/result-format.ts`

### State and persistence

- [Client state store](https://github.com/navelya/prismai/blob/main/lib/store/app-store.ts): `lib/store/app-store.ts`
- [Workflow persistence](https://github.com/navelya/prismai/blob/main/lib/db/workflows.ts): `lib/db/workflows.ts`

### Platform capabilities

- [Workflow templates](https://github.com/navelya/prismai/blob/main/app/api/templates/route.ts): `app/api/templates/route.ts`
- [Canvas collaboration](https://github.com/navelya/prismai/blob/main/lib/hooks/use-workflow-collaboration.ts): `lib/hooks/use-workflow-collaboration.ts`
- [Credits and billing](https://github.com/navelya/prismai/blob/main/lib/billing/cost.ts): `lib/billing/cost.ts`
- [Administration](https://github.com/navelya/prismai/blob/main/app/admin/page.tsx): `app/admin/page.tsx`

### Other components

- **Designer**
- **AI model provider**
- **Supabase**

## Connections

- Designer → Chat interface: describes task (evidence: `README.md`)
- Chat interface → Chat stream API: streams request
- Chat stream API → Chat reasoning: invokes reasoning (evidence: `app/api/chat/stream/route.ts`)
- Chat stream API → Workflow tools: uses tools (evidence: `app/api/chat/stream/route.ts`)
- Workflow tools → Visual editor: edits graph (evidence: `lib/chat/tools/handlers.ts`)
- Designer → Visual editor: inspects workflow (evidence: `README.md`)
- Designer → Execution start API: starts execution
- Execution start API → Node dispatcher: dispatches roots (evidence: `app/api/executions/start/route.ts`)
- DAG orchestrator → Node dispatcher: dispatches children (evidence: `lib/workflow/orchestrator.ts`)
- Node dispatcher → Server node registry: resolves node (evidence: `lib/workflow/dispatch-v2.ts`)
- Server node registry → AI generation node: registers executor (evidence: `lib/nodes/core/server-registry.ts`)
- AI generation node → AI model provider: requests generation
- Node dispatcher → Result formatting: formats output (evidence: `lib/workflow/dispatch-v2.ts`)
- Result formatting → Chat interface: renders results (evidence: `README.md`)
- Chat interface → Client state store: updates state (evidence: `app/chat/ChatClientPage.tsx`)
- Client state store → Workflow persistence: autosaves workflow (evidence: `hooks/useAutoSave.ts`)
- Workflow persistence → Supabase: persists data
- Designer → Workflow templates: browses templates
- Designer → Canvas collaboration: shares canvas
- Designer → Credits and billing: manages credits
- Designer → Administration: administers platform
