This project provides a Node.js (Express) service that automatically fetches (or stores) health-related posts/tweets from an influencer, detects any health claims they make, de-duplicates repeated claims, and uses OpenAI to categorize and verify the validity of these claims. It stores the results in a PostgreSQL database and exposes a REST API for a front-end or other clients to consume.
-
Influencer Management
- Create or update influencers (name, handle, follower count) in a PostgreSQL database.
- Fetch a list of all influencers or retrieve detailed info (including claims) for a specific influencer.
-
Claim Extraction & Verification
- Pull (mock) tweets or text from the influencer.
- Use OpenAI GPT to automatically extract health-related claims.
- De-duplicate repeated claims (a naive approach by default---could integrate advanced methods).
- Categorize each claim (e.g., Nutrition, Medicine, Mental Health, Fitness, Other).
- Verify the claim ("Verified," "Questionable," or "Debunked") and assign a confidence score (0--100).
-
Trust Scoring
- Compute an overall trust score for each influencer, based on the average confidence of their claims.
-
Database Storage
- Stores influencers and claims in a PostgreSQL database with relationships.
- Each claim includes text, category, verification status, confidence score, and timestamp.
-
RESTful Endpoints
GET /influencers-- Lists all influencers.GET /influencers/:id-- Retrieves a single influencer's details and claims.POST /influencers-- Creates or updates an influencer.POST /analyze/:id-- Runs the OpenAI-based analysis pipeline for a given influencer.
-
Create an Influencer
- POST their name, handle (unique), and follower count to
/influencers.
- POST their name, handle (unique), and follower count to
-
Analyze
- When you call
POST /analyze/:id, the service:- Fetches (or simulates) tweets for that influencer.
- Uses OpenAI to extract health-related claims from the text.
- De-duplicates repeated claims.
- Categorizes each claim into broad categories (Nutrition, Medicine, etc.).
- Verifies each claim with a "Verified," "Questionable," or "Debunked" label and a confidence score (0--100).
- Stores everything in the
claimstable, updating the influencer'strust_score.
- When you call
-
View Results
- GET
/influencersto see all influencers, or/influencers/:idto see that influencer's claims in detail.
- GET
- Node.js / Express for the backend API
- PostgreSQL for data storage
- OpenAI for LLM-based claim extraction, categorization, and verification
- Docker Compose (optional) to run PostgreSQL and the Node service together
go
Code kopieren
├── backend/
│ ├── Dockerfile
│ ├── package.json
│ ├── server.js // Main Express app
│ ├── db.js // Database connection & table init
│ └── ...
└── docker-compose.yml
-
Clone the repository.
-
Set up your environment variables in a
.envfile or export them in your shell:bash
Code kopieren
DB_HOST=localhost DB_USER=postgres DB_PASS=postgres DB_NAME=health_db OPENAI_API_KEY=sk-xxx PORT=5001 -
Install dependencies:
bash
Code kopieren
cd backend npm install -
Run with Docker Compose (recommended):
bash
Code kopieren
docker-compose up --build-
This spins up Postgres and the Node server on port 5001 (or whichever you configure).
-
Or, to run locally without Docker, ensure Postgres is running separately, then:
bash
Code kopieren
npm start
-
-
Create an influencer:
bash
Code kopieren
curl -X POST -H "Content-Type: application/json"\ -d '{"name":"Dr. Health","handle":"drhealth","follower_count":10000}'\ http://localhost:5001/influencers -
Check influencer list:
bash
Code kopieren
curl http://localhost:5001/influencers -
Analyze claims for influencer ID
1:bash
Code kopieren
curl -X POST http://localhost:5001/analyze/1 -
View updated influencer details (including claims):
bash
Code kopieren
curl http://localhost:5001/influencers/1
- Tweet Ingestion: Currently, tweets are mocked. Integrate real Twitter data or store tweets in a DB table if desired.
- De-duplication: A naive string check is used by default; you can integrate more advanced embedding-based solutions.
- Verification: Modify the OpenAI prompts or use a different model for more accurate claim verification.
- Frontend: Build a React/Vue/Angular dashboard calling these endpoints to visualize influencer data, claims, and trust scores.
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.
MIT -- Feel free to use and adapt this project to your own needs.