Fact-check table, Appwrite function behavior, UI flow, caching, and history.
The fact-check feature lets users verify a typed claim or an article-derived claim, reuses exact stored fact checks, calls Perplexity through an Appwrite Function when needed, and records signed-in history.
Primary table: fact_checks
Relevant columns:
claim, verdict, confidenceLevel, confidenceScore, source, sourceUrl, contextBlock, checkedAt, relatedContentId, languageconfidence, explanation, citations, userId, createdAtHistory table: user_fact_check_history
userIdfactCheckIdtriggeredAtsourceContentIdFunction ID: fact_check
The function accepts:
{
"claim": "Claim text",
"userId": "optional user id"
}
It validates that the claim is present and no longer than 500 characters. It checks for a recent exact cache hit within seven days. If no cache hit exists, it calls Perplexity with model sonar, requesting JSON with verdict, confidence, explanation, and citations.
Successful responses include:
claimverdictconfidenceexplanationcitationsuserIdcreatedAtThe function stores rows in fact_checks when Appwrite endpoint, project ID, and API key are available.
FactCheckRepository.checkClaim:
findFactCheck for an exact normalized match in fact_checks.fact_check when no exact cache row exists.FactCheckResult.sourceUrl or normalized title.relatedContentId back to the fact-check row when possible.user_fact_check_history.FactCheckScreen:
factCheckDraftClaimProvider.factCheckDraftSourceContentIdProvider.FactResultCard.The screen uses shared_preferences keys:
fc_datefc_countLimits:
Signed-in users get private history rows in user_fact_check_history. ArchiveScreen shows a Fact Checks tab that pages through this history by triggeredAt and displays each result through FactResultCard.