Applied GenAI · LangChain
ReviewLens
Turns a week of customer reviews into sentiment, categories, urgent issues and three action items. Built with agentic coding using Claude Code.
- 206reviews in the demo week
- 3languages handled
- 223automated tests passed
- 0real model calls in tests
01The problem
Reviews pile up faster than anyone can read them.
A restaurant chain or online store collects hundreds of reviews a week from Google, Zomato, Swiggy and Amazon, in English, Tamil and Tanglish. A manager reads them by hand, urgent complaints are missed for days, and nobody can put numbers on what customers are saying.
ReviewLens turns that week into sentiment, categories, urgent issues and exactly three action items, in about five minutes of reading.
02What I built
From a pile of reviews to something a manager can act on.
- 01Structured classificationLangChain with Pydantic returns every review as a typed, validated record rather than free text.
- 02Exact metricsCounts and percentages are computed in pandas, not estimated by the model.
- 03Urgent issues and actionsUrgent complaints are surfaced, and the report closes with three action items.
- 04SafeguardsPrompt-injection and upload safeguards protect the app from hostile input.
Built with LangChain, OpenAI, Pydantic and Streamlit, packaged with Docker. An automated test suite runs with a mocked LLM.
03How it works
From raw reviews to a weekly report.
- Customer reviewsUploaded as a batch
- Upload safeguards
- Structured classificationLangChain + Pydantic
- Exact metricsComputed in pandas
- Insights reportUrgent issues and three actions
04Decisions that mattered
What I chose, and why.
The reasoning behind the build, not just the parts list.
- 01The model classifies; code countsCounts and percentages come from pandas, never from the model. Any number in the written report that does not match the computed metrics is rejected.
- 02Structured output, validatedA LangChain chain with a Pydantic schema returns sentiment, category, urgency, language, a one-line summary and a suggested reply, each with enforced values. Invalid output is retried a bounded number of times, then marked needs_review and never counted as analysed.
- 03A second chain writes the reportThe report is produced from the evidence and the computed metrics: top complaints, top praise, urgent items and exactly three actions.
- 04Reply in the customer’s language, keep a person in chargeEnglish gets an English reply, Tamil script a Tamil reply, Tanglish a Tanglish reply. Summaries are always English. Replies are drafts for human review and are never sent automatically.
- 05Treat review text as untrustedUploads are validated before any model call. Review text sits inside delimiters, angle brackets are neutralised, output is schema-checked, and instructions inside a review are never followed. Exported spreadsheets are protected against formula injection.
- 06A public demo that cannot leak a keyOne Docker image runs in two modes behind a reverse proxy. The public demo is pre-analysed and the container never receives the API key. Live analysis sits behind a password.
- 07Test it without calling a modelA mocked LLM lets the whole suite run offline, including 22 tests of invalid-output retries.
05Engineering evidence
Structured, measured and tested.
Design choices
- The model classifies; code does the arithmetic, so the numbers can be trusted.
- Output is validated against a schema before it reaches the report.
Testing
- An automated test suite runs with a mocked LLM, so behaviour is checked without calling a model.
06Under the hood
Stack, lessons and limits.
Stack by layer
- Interface
- Streamlit with Plotly charts
- Orchestration
- LangChain (LCEL chains)
- Structured output
- Pydantic v2 with structured output
- Model
- OpenAI, behind a provider factory
- Data
- pandas
- Packaging
- Docker with a Traefik reverse proxy; read-only, non-root containers
- Quality
- pytest with a mocked LLM; Ruff
What I learned
- LangChain is the application’s runtime framework. Claude Code was the development tool, used as an agentic coding workflow.
- Putting arithmetic in code and judgement in the model keeps the numbers trustworthy.
Honest limits
- Single-user and session-only: no accounts, history or database.
- One model provider is implemented.
- Without a pinned temperature, a borderline review can be classified differently between runs.
- Tamil and Tanglish quality depends on the configured model.
Classification, exact metrics and safeguards, tested without calling a model.