$ show Niek/chatgpt-web
ChatGPT-web is a Svelte 5 single-page application (with a Tauri desktop wrapper) that provides a configurable chat interface for multiple large language model (LLM) providers, including OpenAI, Anthropic, xAI, Google Gemini, Mistral, APIpie, OpenRouter, OrcaRouter, and custom endpoints. The system handles streaming and non-streaming chat completions, image generation, token counting, pricing estimation, chat profiles with system prompt injection, and export/import of conversations. All chat history and settings are stored client-side in localStorage and IndexedDB, making it a private, self-contained frontend. The architecture is a client-only SPA with no backend; it relies entirely on browser fetch calls to provider APIs. The codebase demonstrates a clear separation of concerns between UI components (Svelte), state management (local storage stores), provider abstractions (provider definitions, request classes), and utility modules (token counting, image caching, settings schema). However, it shows signs of organic growth with tight coupling between modules, frequent `any` type casts, and comments referencing desired refactors. The bundled prompts CSV from the awesome-chatgpt-prompts project serves as a built-in prompt library. The project is suitable for developers wanting a customizable, private, multi-provider chat frontend, but reusing individual components requires careful extraction due to internal dependencies.
The LLM identified 4 files worth highlighting for reuse:
Decentralized provider definitions (OpenAI, Anthropic, etc.) as a typed array of objects. Each entry specifies base URL, headers, model endpoint, image support, and response mapping. This pattern allows adding new providers without modifying core logic, and the configuration object can be extracted and reused in any project needing a registry of API provider endpoints.
A class (`ChatRequest`) that encapsulates the full lifecycle of a chat API request: message pre-processing, token counting, streaming consumption, error handling, and reduction modes (FIFO/summary continuous chat). It is instantiated per conversation and communicates via callbacks. The pattern of a reusable request orchestrator with fallback, retry, and configurable reduction is transferable to other chat or streaming API applications.
Exports a declarative array of `ChatSetting` objects that define every configuration option (name, type, default, visibility condition, API transform, after-change hook). This pattern allows building dynamic UI forms and enforcing client-side validation with minimal boilerplate. The schema is human-readable and could be extracted to drive settings for any application that requires nested, conditional configuration.
A dedicated store using Dexie (IndexedDB) for caching images and thumbnails. Provides methods to put, get, and delete blobs with object URLs. This pattern solves the browser memory issue of storing many images as Base64 in localStorage and is a clean, reusable caching layer that can be adapted for any Blob-heavy web application.