Lightweight web app, a Chrome extension, and a backend that analyze short text and social posts for sentiment using Hugging Face models.
- Web UI (Next.js): paste or enter text and get sentiment (Positive / Neutral / Negative) with confidence scores.
- Browser Extension (Manifest V3): automatically analyzes posts on X (formerly Twitter) and adds a color-coded border + percentage summary for each post.
- Backend (Express): proxies requests to the Hugging Face Inference API so the UI & extension don't need direct HF keys.
- Real-time sentiment detection (web app + extension)
- Simple cache (extension background) to avoid duplicate network calls
- Easy to run locally and to deploy (Railway/Vercel recommended)
- Clone the repo
git clone https://github.com/localhost969/ps-2025.git
cd ps-2025- Backend
cd backend
npm install
# Create a .env file with the following:
# HF_TOKEN=<Your Hugging Face token>
npm start- Frontend
cd ../frontend
npm install
# If you want to point the frontend to a local backend, edit
# `frontend/pages/index.tsx` and set the fetch URL to: `http://localhost:5000/analyze`
npm run dev- Chrome Extension (developer mode)
cd ../extension
# Open Chrome -> chrome://extensions -> Enable 'Developer mode' -> Load unpacked -> select this `extension` folderData Flow:
- Input: Raw text is captured from the textarea (Web) or DOM elements (Extension).
- Processing: Text is packaged into a JSON payload
{ "text": "..." }. - Analysis: Backend forwards this to Hugging Face, which returns an array of labels and scores.
- Output: The application sorts these scores and renders the highest confidence label to the user.
- Backend: already configured to bind to env vars and ready to deploy to Railway. Set
HF_TOKENin env. - Frontend: built with Next.js - change the backend URL to your production backend when deploying, or use an env variable workflow.
- Frontend:
frontend/(Next.js) — main page ispages/index.tsx - Backend:
backend/(Express) — REST endpointPOST /analyze - Extension:
extension/— content script & service worker (+ css)
- If the app returns an HF token error: ensure
HF_TOKENis set in your backend.envfile. - If extension or web app can't reach the backend: either update the
BACKEND_URLinextension/background.jsor set the fetch URL inpages/index.tsxto your local backend URL.
- Improvements, small fixes, and PRs are welcome.



