How okisdev/chatchat works
Project type and purpose
• This is a full‑stack web application built with Next.js (app router) that provides a unified chat and search interface to multiple AI providers.
• Its primary use case is to let end‑users perform chat conversations and web‑style searches via a single interface, backed by major AI/ML APIs (OpenAI, Anthropic, Google Gemini, Cohere, etc.).
File structure
• Top‑level:
• app/ — Next.js “app router” pages, layouts, server/provider components
• app/api/ — API route handlers for chat and search
• components/ — shared UI primitives and layouts (shadcn/ui + Tailwind CSS)
• config/ — provider and search configuration files
• lib/ — core logic modules (provider and search implementations)
• hooks/, utils/ — React hooks and utility functions
• public/, styles/, locales/ — static assets, global styles, i18n resource files
• Dockerfile, docker‑compose.yml, GitHub workflows — containerization and CI/CD
• The project uses an MVC‑style split:
• View: React components in app/ and components/
• Controller: Next.js API routes in app/api/
• Model/Logic: lib/ and config/ modules that wrap external AI/search services
README for additional insights
• The stack is Next.js + Tailwind CSS + shadcn UI.
• Deployable on Vercel, Railway, or Docker.
Main components
a. Frontend (Next.js SSR/CSR)
• App router pages: app/[locale]/(home)/…
• React state/hook layer: hooks/, app/provider.tsx
• UI component library: components/ui + components/layout
• i18n: locales/ + config/i18n
b. Backend API
• Chat service endpoints: app/api/chat/messages/[provider]/route.ts
• Search service endpoints: app/api/search/[engine]/route.ts
• App metadata endpoint: app/api/app/latest/route.ts
c. Core business logic
• Provider abstractions: lib/provider/*.ts + config/provider/*.ts
• Search modules: lib/search/*.ts + config/search/*.ts
• Shared utilities: utils/app, utils/provider, utils/search
d. External services
• AI provider REST APIs (OpenAI, Anthropic, Cohere, …)
• Search engine APIs (Google, Tavern, You.com, etc.)
• Optional: Vercel/Railway hosting, Docker registry
e. Static and supporting layers
• Global styling: styles/globals.css, tailwind.config.ts
Relationships and interactions
• User ↔ Frontend UI
• Frontend sends HTTP requests to Next.js API routes
• API routes invoke lib/provider or lib/search modules
• Those modules call external AI/search APIs
• Results flow back through API → frontend → rendered components
• Config files drive runtime behavior (provider keys, search parameters)
• Hooks manage client state (theme, storage, session)
Architectural patterns and design principles
• Separation of concerns (UI vs. API vs. business logic)
• Pluggable provider strategy (one route per provider, common interface)
• Modular component library for consistent styling and functionality
• Internationalization at routing layer via Next.js dynamic locale segments
• Containerized deployment for consistent environments
Final advice
• Be exhaustive: map out each major directory as a component or subcomponent.
• Flow of data (chat vs. search) separately if needed.
• Review the README stack & config folders to ensure all runtime dependencies (i18n, theming, hooks) are represented.