How recoupable/recoup-chat works
Main Components
• Frontend User Interface:
• Pages in the “app/” folder with dynamic routing (e.g., chat pages, artist pages, funnels, reports).
• Reusable UI components under “components/”.
• Custom React hooks (“hooks/”) that manage UI interactivity.
• Providers (“providers/”) that supply global context (user, chat, payment, autopilot, etc.).
• Backend API Endpoints:
• Numerous API routes within “app/api/” handling various functions such as account management, artist actions, chat, credits, email, reporting, uploads, etc.
• These endpoints follow Next.js API routing conventions.
• Data Storage & External Integration:
• Supabase integration for data storage and migrations (located in “supabase/migrations/”).
• External services configuration, such as Privy for authentication and Stripe (in “lib/stripe”).
• Utility & Service Layers:
• “lib/”: Contains a variety of helper functions (for chat, agents, PDF generation, reporting, IPFS, Supabase queries, etc.).
• “types/”: TypeScript type definitions that support both frontend and backend.
• Evaluation Suite:
• The “evals/” directory holds many evaluation scripts, test cases, and experiments designed to validate and fine-tune the AI components.
• This section interacts with the core AI models and external evaluation APIs.
Relationships and Data Flow
• The frontend (user browser) communicates with the Next.js server:
• UI components render data fetched from API endpoints.
• Context providers (e.g., ChatProvider, UserProvider) manage state and pass it through the component tree.
• API Routes:
• Receive requests from the client and orchestrate backend logic, including data manipulation, authentication (via Privy), and communication with Supabase.
• They often delegate tasks to utility functions in “lib/” to process data or generate responses.
• Data Storage:
• Supabase acts as the persistent store for artists, accounts, campaigns, reviews, etc. API endpoints interact with Supabase using dedicated helper functions.
• Evaluation Flow:
• The evals scripts run tests (such as OpenAI Evals) to ensure AI responses are of high quality. They simulate real user interactions with the chatbot and possibly track metrics.
• These evaluation components can be isolated as a sub‑system that periodically polls or triggers test cases.
Architectural Patterns & Design Principles
• Separation of Concerns:
• Clear division between UI (pages/components) and backend (API endpoints and service libraries).
• Modular Design:
• Each feature (e.g., chat, account, artist actions) is encapsulated with its own dedicated API route, client-side component, and sometimes even its own provider/hook.
• Type Safety & Extensibility:
• Use of TypeScript (with types defined under “types/”) enforces correctness across components and services.
• External Integration:
• Integration with third‑party services (Supabase, Privy, Stripe) is isolated within the “lib/” directory so that changing one integration doesn’t affect other parts.
• Evaluation as a First‑Class Component:
• The extensive “evals/” directory highlights that the project uses continuous assessment to validate AI quality, making this an essential part of architecture.