Quick revision
The short answer
Every new post is saved as pending and moderated before it becomes visible: text goes to a ModerationModel (supported for some providers, such as OpenAI and Mistral) and images to a vision model or a dedicated image moderation service, and we keep the category scores. Configurable, audited thresholds per category decide publish, block or human review. Moderation runs asynchronously with a timeout policy agreed with the policy owners, every decision is stored with model versions and reviewer outcomes, and error rates are measured on a labelled sample regularly.
What to remember
In this answer, we designed moderation around a pending state: posts are stored, then text and images are scored by a ModerationModel and an image check, and per-category thresholds decide publish, review or block. Slow or failed checks follow a timeout policy agreed with policy owners, unsure cases go to human review, every decision is stored with versions and reviewer outcomes for appeals and tuning, and error rates are measured regularly on a labelled sample.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Every new post is saved as pending and moderated before it becomes visible: text goes to a ModerationModel (supported for some providers, such as OpenAI and Mistral) and images to a vision model or a dedicated image moderation service, and we keep the category scores. Configurable, audited thresholds per category decide publish, block or human review. Moderation runs asynchronously with a timeout policy agreed with the policy owners, every decision is stored with model versions and reviewer outcomes, and error rates are measured on a labelled sample regularly.
Why this question is asked
Moderation is a product decision wearing a technical costume. If the system blocks too much, honest users leave; if it blocks too little, harmful content reaches people and the company carries the risk. Interviewers ask this question to see whether we design for uncertainty, latency and accountability, not only for the happy path. In this answer, we will recap what a moderation model returns, design the flow from upload to publication, set thresholds, handle slow or unsure results, store decisions for appeals, and measure quality over time.
1A Quick Recap of Moderation Models
A moderation model reads content and returns, for each category of harm such as harassment, hate, self-harm, sexual content or violence, a score between 0 and 1 and a flag. Spring AI wraps this as a ModerationModel, supported for some providers, for example OpenAI and Mistral. We call it with a ModerationPrompt and read the result.
Notice that the model gives scores, not a final decision. The decision is ours. Text-only moderation endpoints do not cover images in every case, so for pictures we use a vision-capable model with a moderation prompt or a dedicated image moderation service, and record its scores in the same shape.
2The Flow From Upload to Publication
The key design choice is that a post is stored first and published later. When the user submits, we save it with status PENDING and return immediately, showing the user their own post with a small note such as being checked. A moderation worker picks it up from a queue, calls the text and image checks in parallel, combines the scores and applies the policy. The post then moves to PUBLISHED, BLOCKED or REVIEW, and the author is notified if it was blocked.
9 messages in order. Play them, or step through them one at a time.
3Thresholds per Category
Different harms deserve different thresholds. For categories with severe harm, such as child safety, we block at a low score and send borderline cases to review. For milder categories such as profanity, a community may allow quite a lot. So each category has two numbers: a block threshold and a review threshold. Scores below the review threshold publish, scores between them go to human review, and scores above the block threshold block.
| Score band | Decision | Who acts |
|---|---|---|
| below review threshold | publish | automatic |
| between review and block | hold for review | moderator within the target time |
| above block threshold | block, notify author | automatic; author may appeal |
| no score (timeout or error) | timeout policy | agreed with policy owners |
Notice self-harm: we review at a low score but rarely block automatically, because the right response to someone in distress is often support, not deletion. The thresholds live in configuration, not in code, and every change to them is reviewed by the policy owners and recorded with a policy version, so we can later say which rules applied to which decision.
4When Moderation Is Slow or Unsure
Moderation services sometimes take seconds, sometimes time out, and sometimes return scores right in the middle. Because the post is already stored as pending, slowness does not block the user's request; it only delays publication. We set a deadline, for example 10 seconds for the checks. What happens when the deadline passes is a policy decision, not an engineering one. A cautious community holds the post until moderation succeeds or a person reviews it. A community that values speed may publish with later review: the post goes live, is moderated as soon as the service recovers, and is taken down if it fails. The engineering job is to make both options possible, configurable per area of the app, and to agree the choice with policy owners in writing.
Unsure results are what human review is for. Review queues need a target time, such as two hours, and enough moderators for peak hours; otherwise the review band quietly becomes a delay for honest users.
5Store Every Decision
For each post we store the scores per category, the decision, the policy version and thresholds used, the model names and versions, the time taken, and, for reviewed or appealed posts, the moderator's decision and reason. This record does three jobs. It answers appeals: when a user asks why their post was removed, support can see exactly what happened. It supports audits and regulatory questions. And it is the data we need to tune thresholds, because reviewer outcomes tell us where the model and people disagree.
6Measure Quality Over Time
Models are updated and community behaviour changes, so a threshold that was right in spring can be wrong in autumn. Every month we take a random labelled sample, for example 1,000 posts graded by trained moderators, and measure false positives (honest posts blocked) and false negatives (harmful posts published) per category. We also watch the review rate and the appeal success rate, since a rising share of successful appeals means we block too much. When a provider changes its moderation model version, we run the sample again before trusting the old thresholds.
7Follow-up questions
What are the legal risks of fully automatic blocking?
Depending on the jurisdiction, laws on online platforms can require that users are told why content was removed, can appeal, and that decisions are not made only by automated means without a route to a human. Wrongly blocking content can also raise discrimination or freedom of expression concerns, and failing to remove illegal content quickly carries its own liability. So we keep a human review and appeal path, record the reasons, and involve legal and policy teams in setting the rules; this is an area where we confirm requirements with them rather than assume.
Why not moderate synchronously during the upload request?
Because moderation latency and outages would then become upload latency and outages. A pending state decouples them and gives us a natural place for retries, review and timeout policies.
Should authors see that their post is pending?
Yes, a clear status avoids duplicate posts and confusion. Showing the pending post only to its author keeps the experience smooth while protecting others.
8Conclusion
In this answer, we designed moderation around a pending state: posts are stored, then text and images are scored by a ModerationModel and an image check, and per-category thresholds decide publish, review or block. Slow or failed checks follow a timeout policy agreed with policy owners, unsure cases go to human review, every decision is stored with versions and reviewer outcomes for appeals and tuning, and error rates are measured regularly on a labelled sample.
Open with
I would never publish directly on upload. The post is saved as pending, visible only to its author, and a worker moderates it from a queue. For text I call a Spring AI ModerationModel, which some providers such as OpenAI and Mistral support, and for images a vision model with a moderation prompt or a dedicated image service, and I keep the category scores.
Then, if they want more
Each category has a review threshold and a block threshold in configuration, versioned and approved by the policy owners: below review we publish, between them a person reviews, above block we block and notify the author with a way to appeal.
If moderation is slow or down, the post stays pending until a deadline, and then follows a timeout policy we agreed with policy owners, either hold until checked or publish with later review, possibly different per area of the app.
Every decision is stored with scores, thresholds, policy version, model version and the reviewer's outcome, which answers appeals and helps tuning. And every month I would measure false positives and false negatives on a labelled sample, and rerun it whenever the provider updates its model.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring AI reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A community app lets users post text and images, and the product team wants AI...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/f6dccfddc4/