← Back to Portfolio
Case Study — AI Web App

Sentiment Analysis
with Gemini and Groq

A React and Vite app that analyzes text, chat-style conversations and chat screenshots with Google Gemini, and falls back to Groq automatically if a request fails. It returns overall sentiment, a six-emotion breakdown, keywords and per-participant summaries, and keeps your history locally in the browser.

React 18 / Vite Google Gemini Groq IndexedDB Recharts CSS Modules ▶ Personal Project ยท 2026
6 Emotions Scored
3 Input Types
100 Scores Sum to 100
0 Backend Servers
01 — The Problem

One Label Is Not Enough

A single "positive" or "negative" hides most of what is in a message, and chats involve more than one person.

🎭

Mixed feelings

A sentence can be mostly positive with some anger in it. Scores and an emotion breakdown show the mix, not just a label.

💬

Conversations

In a chat, each person has their own tone. The app scores each participant separately and summarizes the dynamic.

📷

Screenshots as input

People often have a chat as an image, not text. The app accepts a screenshot and reads the visible messages.

02 — Architecture

How It Fits Together

Everything runs in the browser. The only external calls are to the Gemini API, or to Groq as the fallback.

UI
Analyze History Stats (lazy) Code (lazy)
↓ useSentiment hook
Logic
Prompt builder Strict JSON schema Error normalizer
↓ generateContent request (text + image)
Model
Google Gemini (Flash) Groq
↓ structured JSON response
Validate
Parse and normalize scores
↓ save result
Storage
IndexedDB history Recharts statistics
03 — Features

What It Does

The three tabs of the app and what each one gives you.

🔍

Analyze

Single text or conversation mode. Overall sentiment badge, positive, neutral and negative score bars, six emotions, keyword chips and a one-sentence insight.

📚

History

Previous analyses saved in the browser with sentiment badges and timestamps, with a button to clear them.

📊

Stats

Total analyses, average positivity, most common sentiment, a distribution bar chart and a radial positivity chart.

04 — Technology

Technology Choices

Small and focused, with no server to run.

LayerTechnologyWhy
UI React 18 + Vite Fast development and a small production bundle; the Stats and Code tabs are lazy-loaded.
AI Google Gemini Groq Gemini handles text and images in one model, so screenshots need no separate OCR step. Groq is a second provider: if one fails or hits a rate limit, the app retries with the other.
Persistence IndexedDB History stays on the user's device; no accounts or database to maintain.
Charts Recharts Declarative charts for the distribution and positivity views.
Styling CSS Modules Scoped styles per component with a small global stylesheet.
05 — Decisions

Calls That Mattered

How the app gets reliable results from a language model.

01

A strict, JSON-only prompt

The prompt embeds the exact output schema and states the rules: raw JSON only, scores as integers, and positive, neutral and negative must sum to 100. That makes the response something the UI can render directly.

02

Validate and normalize on the client

The response is checked and normalized before it is shown or saved, so one odd model answer cannot break the charts or corrupt stored history.

03

Separate prompts for text and conversations

Conversation mode asks for per-participant scores that each sum to 100 and a message-count estimate, which the single-text prompt does not need.

04

Local history, no backend

Saving to IndexedDB keeps the app free to host and keeps analysed text on the user's device.

05

Lazy-loaded tabs

Stats and Code load only when opened, which keeps the first load light.

06 — Hard Parts

What Needed Care

The problems that come with putting a language model behind a UI.

🧱 Structured output from a model

Models drift from a format. A schema in the prompt, explicit rules and client-side normalization turn free-form generation into predictable data.

✓ Schema-in-prompt plus validation

🖼️ Reading chat screenshots

Screenshots can be blurry or cropped. The conversation prompt tells the model to use only the text it can identify confidently, and to still return one participant if only one speaker is visible.

✓ Rules for unclear images

⏱️ Rate limits

API quota errors are normal on a free tier. The app reads the retry delay from the error and shows "Try again in about N seconds" instead of a raw failure.

✓ Friendly retry guidance

💾 Keeping history consistent

Results are stored in IndexedDB in a fixed shape, so History and Stats always read the same structure.

✓ One normalized result shape
07 — Outcomes

What This Demonstrates

What the project shows about how I build AI features.

6 Emotions Joy, anger, fear, sadness, surprise and disgust, each scored 0 to 100.
3 Inputs Single text, conversation text, and a chat screenshot, alone or combined.
0 Servers A fully client-side app: static hosting plus the Gemini API, with Groq as a fallback.
Local Private history Past analyses stay in the browser and can be cleared at any time.
Lazy Light first load Heavier tabs load on demand.
Live Deployed Available on Vercel as a working demo.
08 — Limits

Known Limits and What Is Next

Honest notes on a client-side AI app.

🔑

API key handling

The demo calls Gemini or Groq directly from the browser. For production use, the key should live behind a small serverless proxy with rate limiting, not in the client.

🎯

Model scores are estimates

Scores come from a language model's judgement, not a trained classifier. They are good for exploration, and should not be treated as ground truth.

📐

What I would build next

A serverless proxy, batch analysis of many texts, CSV export of history, and evaluation against a labelled dataset.

Available for work

Want to build something
like this together?

I'm open to full-time roles and project work in AI engineering, full-stack development, and backend systems.