How atharshafi/sentiment-analysis-api works
This is a stateless, full-stack sentiment analysis application. A user enters text in the React interface, which sends it to FastAPI; the API validates the request, selects an available engine, and returns sentiment, confidence, engine, and inference time for display. Engine selection is configured at startup: DistilBERT is intended for local learning, while VADER is the lightweight hosted default, with fallback to VADER if DistilBERT fails to load. The interface also keeps a short in-memory history. The README documents health and root endpoints and a standalone DistilBERT learning script; some backend wiring is omitted from the sampled excerpts, so uncertain calls are not shown.
Main entry points: app.py FastAPI app · SentimentAnalyzer.jsx Analyzer UI · main.jsx React entry · App.jsx App shell
Components 13
Web interface
- React entry
frontend/src/main.jsx - App shell
frontend/src/App.jsx - Analyzer UI
frontend/src/components/SentimentAnalyzer.jsx
HTTP API
- FastAPI app
backend/app.py - Engine startup
backend/app.py - Analyze endpoint
backend/app.py - Health endpoint
backend/app.py
Sentiment engines
- DistilBERT inference
backend/app.py - VADER analysis
backend/app.py
Learning script
- Local inference demo
backend/sentiment_analysis_local_v2.py
Other components
- User
- Browser
- Model hosting
Connections 17
- User → Browser: enters text
- Browser → React entry: loads interface
- React entry → App shell: renders
- App shell → Analyzer UI: renders
- Analyzer UI → FastAPI app: sends analysis
- FastAPI app → Engine startup: starts with
- Engine startup → DistilBERT inference: loads if selected
- Engine startup → VADER analysis: loads by default
- Engine startup → VADER analysis: falls back to
- DistilBERT inference → Model hosting: downloads model
- FastAPI app → Analyze endpoint: routes request
- Analyze endpoint → DistilBERT inference: runs if selected
- Analyze endpoint → VADER analysis: runs otherwise
- Analyze endpoint → Analyzer UI: returns result
- FastAPI app → Health endpoint: routes health check
- User → Local inference demo: runs learning demo
- Local inference demo → Model hosting: loads model