How denissons51/nextchat works
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: chat.ts Conversation state · api.ts Provider dispatch · chat.tsx Chat interface · home.tsx Application shell
Components 28
Chat experience
- Application shell
app/components/home.tsx - Chat interface
app/components/chat.tsx - Shared UI components
app/components/ui-lib.tsx
Conversation state
- Conversation state
app/store/chat.ts - Chat processing
app/utils/chat.ts - Prompt templates
app/store/mask.ts - Built-in templates
app/masks
Model connectivity
- Provider dispatch
app/client/api.ts - OpenAI client
app/client/platforms/openai.ts - Other provider clients
app/client/platforms - Provider router
app/api/[provider]/[...path]/route.ts - Provider handlers
app/api - API authorization
app/api/auth.ts - Model catalog
app/utils/model.ts
Assistant capabilities
- MCP tool actions
app/mcp/actions.ts - MCP client
app/mcp/client.ts - Generated artifacts
app/components/artifacts.tsx - Image generation
app/components/sd/sd.tsx - Realtime chat
app/components/realtime-chat/realtime-chat.tsx - Plugins
app/store/plugin.ts
Persistence and config
- Server configuration
app/config/server.ts - Client configuration
app/config/client.ts - Access settings
app/store/access.ts - Application settings
app/store/config.ts - Browser storage
app/utils/indexedDB-storage.ts - Cloud synchronization
app/store/sync.ts - Cloud storage routes
app/api/webdav/[...path]/route.ts
Other components
- User
Connections 27
- User → Application shell: opens
- Application shell → Chat interface: presents
- Chat interface → Conversation state: updates
- Conversation state → Provider dispatch: requests
app/store/chat.ts - Provider dispatch → OpenAI client: dispatches
app/client/api.ts - Provider dispatch → Other provider clients: dispatches
app/client/api.ts - OpenAI client → Provider router: calls
app/client/platforms/openai.ts - Provider router → Provider handlers: routes
app/api/[provider]/[...path]/route.ts - Provider handlers → API authorization: authorizes
app/api/auth.ts - API authorization → Server configuration: reads
app/api/auth.ts - Provider dispatch → Client configuration: reads
app/client/api.ts - Conversation state → Browser storage: persists
app/store/chat.ts - Conversation state → MCP tool actions: invokes
app/store/chat.ts - MCP tool actions → MCP client: uses
app/mcp/actions.ts - Conversation state → Application settings: reads
app/store/chat.ts - Conversation state → Access settings: reads
app/store/chat.ts - Conversation state → Prompt templates: reads
app/store/chat.ts - Prompt templates → Built-in templates: loads
app/store/mask.ts - Provider dispatch → Model catalog: uses
app/utils/model.ts - Conversation state → Chat processing: uses
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
app/components/ui-lib.tsx