ServerDatabase
Chat & User Feedback
Database tables capturing agent conversation histories and user satisfaction reviews.
Chat & User Feedback
This module manages real-time messaging histories with AI coaches (Nutritionists, Chefs) and logs user satisfaction ratings on system outputs.
Migrated by: 00005_create_chat_and_feedback.sql
1. Chat Threads & Histories
chat_threads
Header records for persistent chat sessions.
- Schema:
Column Type Constraints Default Description iduuidPRIMARY KEYgen_random_uuid()Thread identifier. user_iduuidNOT NULL- Foreign key referencing users.id (ON DELETE CASCADE). titletext- - Optional descriptive thread header. agent_typetextNOT NULL'nutritionist'Target AI Persona: 'nutritionist'or'chef'.created_attimestamptzNOT NULLnow()Thread creation timestamp. updated_attimestamptzNOT NULLnow()Last message timestamp.
chat_messages
Stores individual conversation blocks inside threads.
- Schema:
Column Type Constraints Default Description iduuidPRIMARY KEYgen_random_uuid()Message identifier. thread_iduuidNOT NULL- Foreign key referencing chat_threads.id (ON DELETE CASCADE). sender_roletextNOT NULL- Message author role: 'user','assistant', or'system'.contenttextNOT NULL- Message body text. Supports markdown. metadatajsonbNOT NULL'{}'Dynamic payload tracking LLM configurations, tool calls, and classification intents. created_attimestamptzNOT NULLnow()Message timestamp.
2. User Feedback
user_feedbacks
Captures ratings and qualitative reviews on chat outputs, meal plans, or generated recipes.
- Schema:
Column Type Constraints Default Description iduuidPRIMARY KEYgen_random_uuid()Feedback record identifier. user_iduuidNOT NULL- Foreign key referencing users.id (ON DELETE CASCADE). categorytextNOT NULL- target category: 'chat_response','meal_plan', or'recipe'.reference_iduuid- - UUID of the target item (e.g. chat_messages.id).ratingintegerNOT NULL CHECK (rating >= 1 AND rating <= 5)- Satisfaction rating from 1 (poor) to 5 (excellent). commenttext- - User written comments. metadatajsonbNOT NULL'{}'Additional debugging parameters. created_attimestamptzNOT NULLnow()Submission timestamp.