Sentiment Analysis System

Brand Monitoring and Review Analysis

Design a brand-monitoring service that reads a stream of social posts and reviews, finds which brand and which product feature each one talks about, scores the sentiment, and alerts a team within minutes when opinion turns.

Overview

Brand monitoring answers questions like 'how do people feel about our new phone this week, and is the battery complaint getting worse?' The service reads a large stream of public posts and reviews, keeps the ones that mention a customer's brands, decides whether each opinion is positive, negative or neutral, and turns millions of small, noisy judgments into trend lines and alerts.

The design rests on two ideas. First, one score per post throws away the useful part. A review can praise the camera and complain about the battery; that is aspect-based sentiment analysis (ABSA), which the SemEval-2014 shared task defined as finding the aspects of an entity and the sentiment expressed about each. Second, any single prediction may be wrong (sarcasm, slang, a different company with the same name), so the system is built to be right in aggregate: it counts carefully, compares against a baseline, and alerts only on shifts that are large, well supported and sustained.

Questions to ask first

  • Whole-post sentiment or per feature? — Both: an overall label plus per-aspect labels
  • Which sources? — Licensed social and review feeds, delivered as a stream
  • How much data? — About 100 million matching posts a day, bursty (5 × average at peak)
  • How fresh? — A post shows on the dashboard within 60 seconds
  • How many languages? — Many; the top languages get dedicated models
  • Who reads it? — Marketing, product and support teams, not data scientists

What you will be able to do

  • Explain aspect-based sentiment and design the data model around mentions of (post, brand, aspect).
  • Choose between rules, a fine-tuned model and a large language model for scoring, by cost and accuracy.
  • Tell 'Apple the company' from 'apple the fruit' with an alias table plus context.
  • Build rollups that stay correct when posts arrive late or twice.
  • Write an alert rule that catches a real shift and ignores noise.

Key concepts

  • Aspect-based sentiment
  • Entity linking
  • Language identification
  • Stream processing
  • Event time and late data
  • Count-based rollups
  • Baseline alerting
  • Human-in-the-loop labeling
  • Model versioning

Functional requirements

  • Ingest posts and reviews from licensed feeds continuously; drop exact duplicates
  • Detect the language and link each post to the customer's brands and products
  • Label overall sentiment and sentiment per aspect: positive, negative or neutral
  • Roll up counts per brand, aspect and minute; show trends and drill into example posts
  • Let customers define alert rules; notify by Slack, email or pager
  • Let analysts correct labels; use corrections to evaluate and retrain models
  • Reprocess history with a new model version without mixing versions in one chart

Non-functional requirements

  • Post to dashboard within 60 seconds at p95 (a target we chose)
  • Keep up with 5 × the average rate for an hour without losing posts
  • Each post counted exactly once in rollups, even if it is delivered twice or late
  • Dashboard queries under 500 ms from precomputed rollups (a target we chose)
  • Alerts within 30 minutes of a sustained shift, with few false alarms
  • Customer data isolated per organization

Interview questions

  • What is aspect-based sentiment analysis, and why build for it?
  • Walk me through the pipeline from post to dashboard.
  • How do you avoid false alarms?
  • How do you tell which company a post is about?
  • How do you keep counts correct when data arrives late or twice?
  • Would you use a large language model for this?
  • How do you know the model is still accurate?
  • How does it scale to many languages and 10 times the volume?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio