Files
CatoandClaude Fable 5.1 7be4d2dd1e feat(chat): the answer feedback loop — thumbs, transcript export, nightly review (#1398)
* feat(chat): the answer feedback loop — thumbs, transcript export, nightly review

Under every Cat answer, chatkit 0.14's thumb up and thumb down (one shape in
every fleet product): a thumb down asks why in one tap and takes a few words,
and the app posts it to POST /api/chat/feedback, stored in the new
chat_feedback table beside the conversation (RLS: insert by the owner, no
read through the API keys). A thumb on an answer still on screen resolves to
the conversation's newest stored answer, since the thread never learns the
row id of a live turn.

GET /api/chat/review-export serves the day's conversations to the fleet's
nightly reviewer (Loki) as chatkit's ChatTranscript[]: bearer
CHAT_REVIEW_TOKEN compared in constant time (401 wrong, 503 unset), never a
temporary chat, newest first, at most 50, 30 turns each, 4000 chars a turn,
the tool steps Cat took, a failed flag on a turn that died, and the thumbs —
with no name, email, user or actor id. The scope sentence is derived from
Cat's own system prompt and tool list, never typed twice.

- @bitbaum/chatkit ^0.14.0
- .env.example names CHAT_REVIEW_TOKEN; docs/reference/api/chat.md has the loop
- the export's bare {product, scope, transcripts} is a fleet wire format, so
  the envelope lint rule carves it out like LNURL
- unit tests for the token check, the export shape and the feedback schema

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

* chore(deps): next 16.4.2 — the audit's critical and high advisories

The dependency audit failed on this PR's head with two Next.js advisories
(>=16.0.0 <=16.4.0: unauthenticated RCE, App Router DoS), published after
main last went green. Not this PR's change; the fix is upstream, so it
rides here. `pnpm audit --audit-level=high --prod` is clean again.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 14:19:26 +02:00
..

created_date, last_modified_date, last_modified_summary
created_date last_modified_date last_modified_summary
2025-06-05 2025-06-05 Added documentation standards including creation and modification dates

�� API Documentation

REST API Reference for OrangeCat


📋 Overview

OrangeCat provides a comprehensive REST API for managing Bitcoin fundraising projects, user profiles, and authentication. All API endpoints follow RESTful conventions and return JSON responses.

Base URL: /api/
Authentication: JWT tokens via Supabase Auth
Rate Limiting: Applied per endpoint


🔐 Authentication

All protected endpoints require authentication via JWT tokens:

headers: {
  'Authorization': `Bearer ${token}`,
  'Content-Type': 'application/json'
}

📚 API Sections

📜 Public API (/api/v1/)

🤖 AI Chat

  • Chat API - AI assistant integration using Google Gemini

🎯 Quick Start

1. Authentication

// Login
POST /api/auth/login
{
  "email": "user@example.com",
  "password": "password"
}

2. Get Profile

// Get current user profile
GET /api/profile
Authorization: Bearer {token}

3. Create Campaign

// Create new project
POST /api/projects
Authorization: Bearer {token}
{
  "title": "My Campaign",
  "description": "Campaign description",
  "goal_amount": 1000000
}

📊 Response Format

Success Response

{
  "success": true,
  "data": { ... },
  "message": "Operation successful"
}

Error Response

{
  "success": false,
  "error": "Error message",
  "code": "ERROR_CODE"
}

🔒 Security

  • Input Validation - All inputs validated and sanitized
  • Rate Limiting - Protection against abuse
  • CORS - Configured for secure cross-origin requests
  • HTTPS Only - All API calls must use HTTPS in production

📈 Rate Limits

Endpoint Type Limit Window
Authentication 5 requests 1 minute
Profile Updates 10 requests 1 minute
File Uploads 3 requests 1 minute
General API 100 requests 1 minute

🐛 Error Codes

Code Description
AUTH_REQUIRED Authentication required
INVALID_TOKEN Invalid or expired token
VALIDATION_ERROR Input validation failed
RATE_LIMIT_EXCEEDED Too many requests
RESOURCE_NOT_FOUND Resource not found
PERMISSION_DENIED Insufficient permissions