# denissons51/nextchat architecture

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

- Interactive diagram: https://gitdiagram.com/denissons51/nextchat
- Repository: https://github.com/denissons51/nextchat

## Overview

NextChat is a browser-first AI assistant with a Next.js API layer and optional desktop support. The main workflow is user chat input through chat state and provider-specific client dispatch, then server-side provider routing and an AI response back to the conversation. The product also includes prompt templates, MCP tools, realtime chat, image generation, artifacts, and cloud sync. Several feature branches are documented but their implementation was not sampled; those links are therefore documented or left unverified rather than inferred from filenames.

Main entry points: [`app/store/chat.ts`](https://github.com/denissons51/nextchat/blob/main/app/store/chat.ts) (Conversation state), [`app/client/api.ts`](https://github.com/denissons51/nextchat/blob/main/app/client/api.ts) (Provider dispatch), [`app/components/chat.tsx`](https://github.com/denissons51/nextchat/blob/main/app/components/chat.tsx) (Chat interface), [`app/components/home.tsx`](https://github.com/denissons51/nextchat/blob/main/app/components/home.tsx) (Application shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat experience"]
  node_home["Application shell<br/>[home.tsx]"]
  node_chatui["Chat interface<br/>[chat.tsx]"]
  node_ui["Shared UI components<br/>[ui-lib.tsx]"]
end

subgraph group_conversation["Conversation state"]
  node_chatstate["Conversation state<br/>[chat.ts]"]
  node_chatutils["Chat processing<br/>[chat.ts]"]
  node_maskstate["Prompt templates<br/>[mask.ts]"]
  node_maskcatalog["Built-in templates"]
end

subgraph group_providers["Model connectivity"]
  node_clientapi["Provider dispatch<br/>[api.ts]"]
  node_openai["OpenAI client<br/>[openai.ts]"]
  node_providerclients["Other provider clients"]
  node_apiroute["Provider router<br/>[route.ts]"]
  node_providerhandlers["Provider handlers"]
  node_auth["API authorization<br/>[auth.ts]"]
  node_modelcatalog["Model catalog<br/>[model.ts]"]
end

subgraph group_features["Assistant capabilities"]
  node_mcp["MCP tool actions<br/>[actions.ts]"]
  node_mcpclient["MCP client<br/>[client.ts]"]
  node_artifacts["Generated artifacts<br/>[artifacts.tsx]"]
  node_imagegen["Image generation<br/>[sd.tsx]"]
  node_realtime["Realtime chat<br/>[realtime-chat.tsx]"]
  node_plugins["Plugins<br/>[plugin.ts]"]
end

subgraph group_persistence["Persistence and config"]
  node_serverconfig["Server configuration<br/>[server.ts]"]
  node_clientconfig["Client configuration<br/>[client.ts]"]
  node_accessstate["Access settings<br/>[access.ts]"]
  node_configstate["Application settings<br/>[config.ts]"]
  node_storage[("Browser storage")]
  node_cloudsync["Cloud synchronization<br/>[sync.ts]"]
  node_cloudroutes["Cloud storage routes<br/>[route.ts]"]
end

node_user(("User"))

node_user -->|"opens"| node_home
node_home -.->|"presents"| node_chatui
node_chatui -.->|"updates"| node_chatstate
node_chatstate -->|"requests"| node_clientapi
node_clientapi -->|"dispatches"| node_openai
node_clientapi -->|"dispatches"| node_providerclients
node_openai -->|"calls"| node_apiroute
node_apiroute -->|"routes"| node_providerhandlers
node_providerhandlers -->|"authorizes"| node_auth
node_auth -->|"reads"| node_serverconfig
node_clientapi -->|"reads"| node_clientconfig
node_chatstate -->|"persists"| node_storage
node_chatstate -->|"invokes"| node_mcp
node_mcp -->|"uses"| node_mcpclient
node_chatstate -->|"reads"| node_configstate
node_chatstate -->|"reads"| node_accessstate
node_chatstate -->|"reads"| node_maskstate
node_maskstate -->|"loads"| node_maskcatalog
node_clientapi -->|"uses"| node_modelcatalog
node_chatstate -->|"uses"| node_chatutils
node_user -.->|"uses"| node_plugins
node_user -->|"starts"| node_realtime
node_user -->|"generates"| node_imagegen
node_user -->|"previews"| node_artifacts
node_cloudsync -.->|"syncs with"| node_cloudroutes
node_user -.->|"syncs data"| node_cloudsync
node_chatui -->|"uses"| node_ui

click node_home "https://github.com/denissons51/nextchat/blob/main/app/components/home.tsx"
click node_chatui "https://github.com/denissons51/nextchat/blob/main/app/components/chat.tsx"
click node_chatstate "https://github.com/denissons51/nextchat/blob/main/app/store/chat.ts"
click node_chatutils "https://github.com/denissons51/nextchat/blob/main/app/utils/chat.ts"
click node_clientapi "https://github.com/denissons51/nextchat/blob/main/app/client/api.ts"
click node_openai "https://github.com/denissons51/nextchat/blob/main/app/client/platforms/openai.ts"
click node_providerclients "https://github.com/denissons51/nextchat/tree/main/app/client/platforms"
click node_apiroute "https://github.com/denissons51/nextchat/blob/main/app/api/%5Bprovider%5D/%5B...path%5D/route.ts"
click node_providerhandlers "https://github.com/denissons51/nextchat/tree/main/app/api"
click node_auth "https://github.com/denissons51/nextchat/blob/main/app/api/auth.ts"
click node_serverconfig "https://github.com/denissons51/nextchat/blob/main/app/config/server.ts"
click node_clientconfig "https://github.com/denissons51/nextchat/blob/main/app/config/client.ts"
click node_accessstate "https://github.com/denissons51/nextchat/blob/main/app/store/access.ts"
click node_configstate "https://github.com/denissons51/nextchat/blob/main/app/store/config.ts"
click node_maskstate "https://github.com/denissons51/nextchat/blob/main/app/store/mask.ts"
click node_maskcatalog "https://github.com/denissons51/nextchat/tree/main/app/masks"
click node_storage "https://github.com/denissons51/nextchat/blob/main/app/utils/indexedDB-storage.ts"
click node_modelcatalog "https://github.com/denissons51/nextchat/blob/main/app/utils/model.ts"
click node_mcp "https://github.com/denissons51/nextchat/blob/main/app/mcp/actions.ts"
click node_mcpclient "https://github.com/denissons51/nextchat/blob/main/app/mcp/client.ts"
click node_artifacts "https://github.com/denissons51/nextchat/blob/main/app/components/artifacts.tsx"
click node_imagegen "https://github.com/denissons51/nextchat/blob/main/app/components/sd/sd.tsx"
click node_realtime "https://github.com/denissons51/nextchat/blob/main/app/components/realtime-chat/realtime-chat.tsx"
click node_plugins "https://github.com/denissons51/nextchat/blob/main/app/store/plugin.ts"
click node_cloudsync "https://github.com/denissons51/nextchat/blob/main/app/store/sync.ts"
click node_cloudroutes "https://github.com/denissons51/nextchat/blob/main/app/api/webdav/%5B...path%5D/route.ts"
click node_ui "https://github.com/denissons51/nextchat/blob/main/app/components/ui-lib.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_home,node_chatui,node_ui,node_user toneBlue
class node_chatstate,node_chatutils,node_maskstate,node_maskcatalog toneAmber
class node_clientapi,node_openai,node_providerclients,node_apiroute,node_providerhandlers,node_auth,node_modelcatalog toneMint
class node_mcp,node_mcpclient,node_artifacts,node_imagegen,node_realtime,node_plugins toneRose
class node_serverconfig,node_clientconfig,node_accessstate,node_configstate,node_storage,node_cloudsync,node_cloudroutes toneIndigo
```

## Components

### Chat experience

- [Application shell](https://github.com/denissons51/nextchat/blob/main/app/components/home.tsx): `app/components/home.tsx`
- [Chat interface](https://github.com/denissons51/nextchat/blob/main/app/components/chat.tsx): `app/components/chat.tsx`
- [Shared UI components](https://github.com/denissons51/nextchat/blob/main/app/components/ui-lib.tsx): `app/components/ui-lib.tsx`

### Conversation state

- [Conversation state](https://github.com/denissons51/nextchat/blob/main/app/store/chat.ts): `app/store/chat.ts`
- [Chat processing](https://github.com/denissons51/nextchat/blob/main/app/utils/chat.ts): `app/utils/chat.ts`
- [Prompt templates](https://github.com/denissons51/nextchat/blob/main/app/store/mask.ts): `app/store/mask.ts`
- [Built-in templates](https://github.com/denissons51/nextchat/tree/main/app/masks): `app/masks`

### Model connectivity

- [Provider dispatch](https://github.com/denissons51/nextchat/blob/main/app/client/api.ts): `app/client/api.ts`
- [OpenAI client](https://github.com/denissons51/nextchat/blob/main/app/client/platforms/openai.ts): `app/client/platforms/openai.ts`
- [Other provider clients](https://github.com/denissons51/nextchat/tree/main/app/client/platforms): `app/client/platforms`
- [Provider router](https://github.com/denissons51/nextchat/blob/main/app/api/%5Bprovider%5D/%5B...path%5D/route.ts): `app/api/[provider]/[...path]/route.ts`
- [Provider handlers](https://github.com/denissons51/nextchat/tree/main/app/api): `app/api`
- [API authorization](https://github.com/denissons51/nextchat/blob/main/app/api/auth.ts): `app/api/auth.ts`
- [Model catalog](https://github.com/denissons51/nextchat/blob/main/app/utils/model.ts): `app/utils/model.ts`

### Assistant capabilities

- [MCP tool actions](https://github.com/denissons51/nextchat/blob/main/app/mcp/actions.ts): `app/mcp/actions.ts`
- [MCP client](https://github.com/denissons51/nextchat/blob/main/app/mcp/client.ts): `app/mcp/client.ts`
- [Generated artifacts](https://github.com/denissons51/nextchat/blob/main/app/components/artifacts.tsx): `app/components/artifacts.tsx`
- [Image generation](https://github.com/denissons51/nextchat/blob/main/app/components/sd/sd.tsx): `app/components/sd/sd.tsx`
- [Realtime chat](https://github.com/denissons51/nextchat/blob/main/app/components/realtime-chat/realtime-chat.tsx): `app/components/realtime-chat/realtime-chat.tsx`
- [Plugins](https://github.com/denissons51/nextchat/blob/main/app/store/plugin.ts): `app/store/plugin.ts`

### Persistence and config

- [Server configuration](https://github.com/denissons51/nextchat/blob/main/app/config/server.ts): `app/config/server.ts`
- [Client configuration](https://github.com/denissons51/nextchat/blob/main/app/config/client.ts): `app/config/client.ts`
- [Access settings](https://github.com/denissons51/nextchat/blob/main/app/store/access.ts): `app/store/access.ts`
- [Application settings](https://github.com/denissons51/nextchat/blob/main/app/store/config.ts): `app/store/config.ts`
- [Browser storage](https://github.com/denissons51/nextchat/blob/main/app/utils/indexedDB-storage.ts): `app/utils/indexedDB-storage.ts`
- [Cloud synchronization](https://github.com/denissons51/nextchat/blob/main/app/store/sync.ts): `app/store/sync.ts`
- [Cloud storage routes](https://github.com/denissons51/nextchat/blob/main/app/api/webdav/%5B...path%5D/route.ts): `app/api/webdav/[...path]/route.ts`

### Other components

- **User**

## Connections

- User → Application shell: opens
- Application shell → Chat interface: presents
- Chat interface → Conversation state: updates
- Conversation state → Provider dispatch: requests (evidence: `app/store/chat.ts`)
- Provider dispatch → OpenAI client: dispatches (evidence: `app/client/api.ts`)
- Provider dispatch → Other provider clients: dispatches (evidence: `app/client/api.ts`)
- OpenAI client → Provider router: calls (evidence: `app/client/platforms/openai.ts`)
- Provider router → Provider handlers: routes (evidence: `app/api/[provider]/[...path]/route.ts`)
- Provider handlers → API authorization: authorizes (evidence: `app/api/auth.ts`)
- API authorization → Server configuration: reads (evidence: `app/api/auth.ts`)
- Provider dispatch → Client configuration: reads (evidence: `app/client/api.ts`)
- Conversation state → Browser storage: persists (evidence: `app/store/chat.ts`)
- Conversation state → MCP tool actions: invokes (evidence: `app/store/chat.ts`)
- MCP tool actions → MCP client: uses (evidence: `app/mcp/actions.ts`)
- Conversation state → Application settings: reads (evidence: `app/store/chat.ts`)
- Conversation state → Access settings: reads (evidence: `app/store/chat.ts`)
- Conversation state → Prompt templates: reads (evidence: `app/store/chat.ts`)
- Prompt templates → Built-in templates: loads (evidence: `app/store/mask.ts`)
- Provider dispatch → Model catalog: uses (evidence: `app/utils/model.ts`)
- Conversation state → Chat processing: uses (evidence: `app/store/chat.ts`)
- User → Plugins: uses
- User → Realtime chat: starts
- User → Image generation: generates
- User → Generated artifacts: previews
- Cloud synchronization → Cloud storage routes: syncs with
- User → Cloud synchronization: syncs data
- Chat interface → Shared UI components: uses (evidence: `app/components/ui-lib.tsx`)
