A real-time dashboard that displays customer happiness levels by region and uses an NVIDIA Nemotron multi-step agent to diagnose issues and auto-generate resolution recommendations.
- 🗺️ Interactive Map Visualization: Heatmap showing customer happiness scores by US region
- 📊 Real-time Sentiment Analysis: Aggregated sentiment data from multiple sources
- 🤖 NVIDIA Nemotron Agent: Multi-step workflow for diagnosing issues and generating recommendations
- 📱 Responsive Dashboard: Dark, minimal UI with real-time updates
- 🔄 Auto-refresh: Data updates every 30 seconds
- 📈 Trend Analysis: Track positive and negative sentiment spikes
- Frontend: Next.js 14 + React + TypeScript
- Styling: TailwindCSS
- Map: Leaflet.js + React-Leaflet
- Backend: Next.js API Routes
- Database: Supabase (PostgreSQL)
- LLM Agent: NVIDIA Nemotron (simulated with rule-based logic)
- Sentiment Analysis: HuggingFace API (with fallback)
- Node.js 18+ and npm
- Supabase account and project
- (Optional) HuggingFace API key for sentiment analysis
- (Optional) NVIDIA API key for Nemotron integration
-
Clone and install dependencies:
npm install
-
Set up environment variables:
cp .env.local.example .env.local
Edit
.env.localand add your credentials:NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key # Optional HUGGINGFACE_API_KEY=your_huggingface_api_key NVIDIA_API_KEY=your_nvidia_api_key NVIDIA_BASE_URL=https://integrate.api.nvidia.com/v1
-
Set up Supabase database:
- Create a new Supabase project
- Run the migration script from
supabase/migrations/001_initial_schema.sqlin your Supabase SQL editor - Or use Supabase CLI:
supabase db push
-
Seed the database (optional):
npm run seed
-
Run the development server:
npm run dev
-
Open your browser: Navigate to http://localhost:3000
SentimentRadar/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ │ ├── diagnose/ # Nemotron agent endpoint
│ │ ├── snapshots/ # Sentiment data endpoint
│ │ └── publish-slack/ # Slack integration (simulated)
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Main dashboard page
├── components/ # React components
│ ├── Dashboard.tsx # Main dashboard component
│ ├── HappinessMap.tsx # Map visualization
│ ├── Sidebar.tsx # Sentiment trends sidebar
│ └── DiagnosisPanel.tsx # Diagnosis results modal
├── lib/ # Utility libraries
│ ├── supabase.ts # Supabase client setup
│ ├── sentiment.ts # Sentiment analysis service
│ └── nemotron-agent.ts # Nemotron agent workflow
├── scripts/ # Utility scripts
│ └── seed.ts # Database seeding script
└── supabase/ # Database migrations
└── migrations/
└── 001_initial_schema.sql
id(uuid, primary key)region(text)happiness_score(float, 0-100)sentiment_summary(text)outage_level(integer, 0-100)created_at(timestamp)
id(uuid, primary key)region(text)cause(text)internal_message(text)customer_message(text)created_at(timestamp)
- Click on any region marker on the map
- Click "Run Diagnosis" in the popup
- The Nemotron agent will:
- Retrieve latest sentiment data
- Analyze trends
- Identify root causes
- Generate internal and customer-facing messages
- Review the results in the diagnosis panel
- Optionally publish to Slack (simulated)
- The sidebar shows:
- Overall happiness score
- Top 5 negative sentiment spikes
- Top 5 positive moments
- Data refreshes automatically every 30 seconds
- Click the refresh button to manually update
The agent implements a 5-step workflow:
- Retrieve Data: Fetches latest sentiment and outage data from Supabase
- Analyze Trend: Determines if happiness is rising, falling, or stable
- Identify Cause: If happiness drops below threshold, identifies probable causes
- Generate Internal Message: Creates detailed resolution message for internal teams
- Generate Customer Message: Creates customer-friendly status update
Edit lib/nemotron-agent.ts and uncomment the callNemotronAPI function implementation. Replace the simulated responses with actual API calls:
const response = await fetch(`${process.env.NVIDIA_BASE_URL}/chat/completions`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.NVIDIA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'nemotron-4-340b-instruct',
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'user', content: prompt }
],
}),
})To integrate real Twitter/X, Reddit, or outage data:
- Create new API routes in
app/api/ - Implement data fetching logic
- Use
lib/sentiment.tsto analyze sentiment - Insert results into
sentiment_snapshotstable
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Run linter
npm run lint
# Seed database
npm run seed| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Yes | Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
Yes | Supabase anonymous key |
SUPABASE_SERVICE_ROLE_KEY |
Yes | Supabase service role key (for admin operations) |
HUGGINGFACE_API_KEY |
No | HuggingFace API key for sentiment analysis |
NVIDIA_API_KEY |
No | NVIDIA API key for Nemotron |
NVIDIA_BASE_URL |
No | NVIDIA API base URL |
MIT
Contributions are welcome! Please feel free to submit a Pull Request.