Smart News Service Architecture: Frontend and Client Implementation Breakdown
This article explores the architecture and implementation strategies for building an intelligent news service, targeting backend engineers, client developers, and product managers. It details a five-layer system design, a conversational news retrieval pipeline using Retrieval-Augmented Generation (RAG), personalized recommendation algorithms, and critical aspects of data security, content credibility, and operational monitoring metrics.
1. Applicable Scenarios and Boundaries
This article is intended for backend engineers, client developers, and product managers responsible for news-oriented mobile applications. The architecture and parameters provided serve as ready-to-use reference values, which teams should adjust based on their traffic, content volume, and model costs.
Suitable scenarios include: organizing multiple reports into a timeline based on user natural language queries about a specific event; sorting news feeds by interest and region; and pushing on-site notifications during offline events.
Unsuitable scenarios include: real-time market quotes, judgments relying on personal privacy data, and professional consultations that must provide definitive conclusions without citable sources. When encountering such issues, the system should explicitly state its inability to answer and guide users to human or authoritative channels.
2. Overall Architecture
It is recommended to split the system into five layers, communicating only through explicit interfaces to prevent mobile clients from directly accessing models.
Mobile Client (pages, session ID, local cache)↓ HTTPS, carrying short-lived access tokenAPI Gateway (authentication, rate limiting, circuit breaking, request logging)↓Business Services (session management, news feed, recommendation, events)↓ ↓RAG Retrieval Service Recommendation Service(keyword index, vector DB) (feature service, ranking model)↓Model Gateway (model selection, prompt template version, timeout, token metering)↓Content Repository & Audit (body text, metadata, audit status, copyright fields)
Main interfaces are as follows:
- POST /v1/chat/ask: Inputs include session_id, question, and client_version. Regional information is only passed in upon user authorization. Returns answer, citations (including article_id, title, publish time, original link), confidence_level, and request_id.
- GET /v1/feed: Inputs include cursor, channel, and limit (default 20, max 50).
- POST /v1/events: Reports impressions, clicks, and dwell time in batches, up to 100 items per batch.
Regarding authentication, the mobile client uses an access token valid for 15 minutes, paired with a refresh token for renewal. The Model Gateway only accepts service-to-service calls using intranet certificates or server-side signatures; clients cannot connect directly.
For rate limiting, Q&A is limited to 10 requests per minute per user, and 60 requests per minute per IP. When exceeded, it returns a 429 status and provides a retry time in the response header.
For timeouts and retries, the retrieval timeout is set to 300 milliseconds, the model’s first token timeout to 2 seconds, and the full response timeout to 8 seconds. Model calls retry only once for network errors and 5xx errors using exponential backoff. Timeout requests are not retried to avoid latency accumulation.
For fallbacks, if the model is unavailable, the interface returns the retrieved list of original articles with an explanatory note. If retrieval fails, the interface returns trending news and a prompt. Both fallbacks must mark degraded=true in the response for statistical purposes.
Regarding cache keys, the Q&A cache key is a hash of “standardized question + regional code + content version number + prompt template version.” The TTL for time-sensitive questions is 10 minutes, and for background questions, it is 24 hours. The news feed cache key is “user bucket + channel + cursor,” with a TTL of 60 seconds. Personalized results do not enter the public cache.
3. Designing the Conversational News Retrieval Pipeline
The core of Retrieval-Augmented Generation (RAG) is to first find citable materials and then let the model organize the answer based on those materials. Relying solely on the model’s internal knowledge is insufficient because training data has a cutoff date, whereas news changes rapidly. The complete pipeline consists of six steps.
Step 1: Query Understanding. The system first determines the question type (e.g., summary, cause, comparison, timeline) and then extracts time ranges, locations, and entities. Classification can initially be done using rule dictionaries and small models, offering low cost and stable latency.
Step 2: Recall. Keyword search (BM25) and vector search run in parallel, each fetching the top 50 results. These are merged and deduplicated by article ID. A maximum of 3 articles per event are retained to prevent syndicated copies from dominating the candidate set.
Step 3: Reranking. A cross-encoder or lightweight ranking model scores the candidates, retaining the top 8. Ranking factors include relevance, publication time decay, source tier, and audit status. The half-life of time decay is set by topic—24 hours for breaking news, 30 days for background material.
Step 4: Generation. The prompt template requires the model to only use the provided materials and cite the source ID after each conclusion. For uncertain content, the model should use phrasing like “reports indicate” or “according to disclosures” rather than drawing direct conclusions.
Step 5: Validation. The program checks whether the citation ID for each sentence exists. It also verifies that numbers, dates, and names appearing in the answer can be found in the cited materials. Sentences that fail this check are deleted or rewritten as uncertain statements.
Step 6: Refusal to Answer. The system directly replies “insufficient material to answer” and lists candidate article links if any of the following conditions are met: the highest relevance score after reranking is below the 0.45 threshold; fewer than 2 valid articles are available for summary-type questions; or fewer than 2 sentences remain after validation.
4. Personalized Recommendation Features and Ranking
Recommendation system features fall into three categories. User features include the click distribution across channels over the last 30 days, recent search terms, and subscribed topics. Content features include topic tags, region, publication time, source tier, and body text semantic vectors. Contextual features include time of day, network status, and, if authorized, event proximity information.
The recall phase uses three routes: subscribed topic recall, regional trending recall, and global trending recall, fetching 100 items per route.
The ranking phase first scores with rules to get an initial order, followed by model-based fine-ranking. The optimization target should be deep reading—the proportion of clicks with a dwell time over 60 seconds—rather than simple click-through rate (CTR). Pursuing only CTR allows clickbait content to dominate the top of the feed.
Diversity control has two hard rules: no more than 3 articles of the same topic in the top 10 results; and at least one public important news item per screen. This reduces filter bubbles while ensuring users encounter public issues.
For cold starts, new users are shown regional trending news and editorial picks. Personalized ranking activates only after completing 3 valid reading sessions.
Major public events, emergency information, and important policy updates have a manual top-pinning channel. Operations staff review and manually adjust positions, logging the operator, time, and reason for each action.
5. Data Security and Content Credibility
Data collection follows the principle of minimization. Only business-essential fields are collected; location information is saved at most to the city level, without precise coordinates. Authorization entries are placed in the settings page, allowing users to revoke access at any time. Upon revocation, the system stops using the field within 24 hours and deletes derived features.
For log desensitization, phone numbers, emails, and device IDs are hashed or masked before being written to logs. Original Q&A text is retained for 30 days, after which only hash values and statistical fields are kept.
Regarding data retention periods, behavioral details are kept for 180 days, aggregated statistics for 2 years, and model call logs for 30 days. Data exceeding these periods is deleted by scheduled tasks, with the deletion records themselves retained for 1 year.
Regarding copyright, every citation must display the source media name and a link to the original article. Full-paragraph reproduction is prohibited; the generated summary length must not exceed 30% of the original text.
Content audit responsibilities are divided as follows: editors handle source content review; generated content is sampled by duty staff, with a daily sample size of 200 items or 1% of the day’s Q&A volume, whichever is greater. Policy, breaking news, and medical Q&A must all undergo manual review before entering trending recommendations.
For input-side security, the system must identify prompt injections, such as instructions demanding the model ignore rules. Retrieved news body text and user input must be passed to the model in different message roles. Instructions appearing in the news text are treated as plain text and not executed as operational commands.
6. Operations and Monitoring Metrics
The following metrics require instrumentation before launch and alarm configuration.
- API Success Rate: Successful requests divided by total requests, split by interface. Data comes from gateway logs; an alarm triggers if it falls below 99.5% for 5 consecutive minutes, to be handled by backend on-call staff.
- Q&A First Token Latency P95: Time from request arrival at the gateway to the model returning the first token. Data comes from the Model Gateway; an alarm triggers if it exceeds 2.5 seconds for 10 minutes.
- Client Crash Rate: Crashed sessions divided by active sessions, split by version and device model. An alarm triggers if the crash rate exceeds 0.3%, or if a new version is 0.1 percentage points higher than the previous one, handled by the client lead.
- Citation Validity Rate: The proportion of citations in answers that exist and whose corresponding materials support the conclusion. Derived from weekly manual sampling, with a target value above 95%. If it falls below 90%, the corresponding prompt template version is suspended.
- Refusal Rate: Refusals divided by total Q&A attempts. A sudden spike in the refusal rate indicates a drop in retrieval quality; a refusal rate below 5% may indicate overly loose thresholds, requiring a review.
- Effective Search Rate: Q&A sessions where citation links were clicked divided by total Q&A sessions.
- Deep Reading Rate: Clicks with dwell time over 60 seconds divided by total clicks.
When metrics change, first segment the data across three dimensions: client version, prompt template version, and content update time. After confirming which factor caused the change, decide whether to roll back or fix. A/B test routing uses user ID hashing to ensure the same user always lands in the same experimental group.
For manual sampling, 300 entries are extracted weekly from Q&A logs, stratified by question type.
