Spaces:
Running
Running
Sentiment Analysis Frontend
A modern React frontend for the Sentiment Analysis API, featuring real-time sentiment analysis, history tracking, and cache performance monitoring.
Features
- Real-time Sentiment Analysis: Analyze text sentiment instantly
- Visual Feedback: Beautiful emoji-based sentiment indicators
- Confidence Scores: Progress bars showing prediction confidence
- Analysis History: Browse and filter previous analyses
- Cache Statistics: Monitor Redis cache performance
- Responsive Design: Works on all devices (320px+)
- Accessibility: WCAG AA compliant
Tech Stack
- React 19 - UI library
- TypeScript - Type safety
- Vite - Build tool
- Tailwind CSS 4 - Styling
- Axios - HTTP client
- Lucide React - Icons
Getting Started
Prerequisites
- Node.js 18+
- The Sentiment API backend running (see main README)
Installation
# Install dependencies
npm install
# Start development server
npm run dev
The app will be available at http://localhost:5173
Environment Variables
Create a .env file (copy from .env.example):
# API Base URL
VITE_API_BASE_URL=http://localhost:8000
Building for Production
npm run build
The built files will be in the dist/ directory.
Project Structure
src/
βββ components/ # React components
β βββ Header.tsx # App header
β βββ Footer.tsx # App footer
β βββ SentimentAnalyzer.tsx # Main input/analysis
β βββ ResultCard.tsx # Result display
β βββ HistoryList.tsx # Analysis history
β βββ CacheStats.tsx # Cache dashboard
βββ hooks/ # Custom React hooks
β βββ useSentimentAnalysis.ts
β βββ useHistory.ts
β βββ useCacheStats.ts
βββ services/ # API services
β βββ api.ts # Axios instance & endpoints
βββ types/ # TypeScript types
β βββ index.ts
βββ utils/ # Utility functions
β βββ formatters.ts # Date/number formatting
β βββ validators.ts # Input validation
βββ App.tsx # Root component
βββ main.tsx # Entry point
βββ index.css # Global styles
Deployment
GitHub Pages
The frontend is configured for GitHub Pages deployment. Push to main branch and the GitHub Actions workflow will automatically build and deploy.
Live URL: https://simplyarfan.github.io/Sentiment-API/
Other Platforms
- Vercel: Connect your GitHub repo
- Netlify: Connect your GitHub repo
- Manual: Run
npm run buildand uploaddist/folder
API Endpoints Used
| Endpoint | Method | Description |
|---|---|---|
/analyze |
POST | Analyze text sentiment |
/history |
GET | Get analysis history |
/cache/stats |
GET | Get cache statistics |
License
MIT