📄 news‑backend
Regulatory-First Design: Contextual Ads-Free News Portal for Privacy-Driven User Experience
Building privacy‑by‑law systems from day 1. Start with the law, end with trust.
In today's data-protection landscape, regulations like GDPR, CCPA, HIPAA, and DPDPA should form the foundation of product architecture.
Demo-Project Concepts
- Personal Data Vault ("My Privacy Locker") A self-hosted, encrypted vault with immutable consent receipts for documents.
- Contextual Ads-Free News Portal Personalized article recommendations without profiling or cookies.
- Health Check-In App A secure daily wellness check-in for handling Protected Health Information (PHI).
Table of Contents
- Components
- Data Flow
What it does
news‑backend provides a privacy‑first news aggregation service that:
- Eliminates profiling – No user‑profile database, no cookies, and no IP‑address logging beyond essential host logs.
- Keeps personalization client‑side – A deterministic hash‑based interest vector is generated and stored encrypted in the browser’s localStorage, rotating daily.
- Offers transparency – The /privacy-summary endpoint returns a machine‑readable SPDX‑2.2 privacy policy describing data collection (none) and user rights (right to object, right to access).
- Supports opt‑out – The /opt-out endpoint clears any possible server‑side session and signals the UI to stop any residual personalization.
- Enforces strong security defaults – CSP, X‑Content‑Type‑Options, Permissions‑Policy, and X‑Frame‑Options are applied globally via the Shield fairing.
In short, the backend merely serves static assets and a privacy policy; all recommendation logic lives in the browser, guaranteeing a cookie‑less, zero‑profiling news experience.
Architecture – Contextual‑Ads‑Free News Portal
A zero‑profiling, cookie‑less news aggregator whose personalization runs entirely in the browser.
graph LR
subgraph Backend
B1 --> B2
B1 --> B3
Note: All recommendation logic stays in the browser; the backend merely serves static assets and a machine‑readable privacy‑policy.
Components
| Layer | Component | Role |
|---|---|---|
| Backend | Rocket(Rust) | Minimal HTTP server, serves static assets, provides privacy‑summary and opt‑out endpoints. |
| Shield Fairing | Injects security headers (nosniff, interest‑cohort=(), SAMEORIGIN). | |
| Static‑file CDN | Delivers pre‑built Next.js assets (HTML, JS, CSS). | |
| Frontend | React SPA(Next.js) | UI for browsing articles, displaying privacy dashboard, handling opt‑out. |
| Service Worker | Caches articles for offline reading, reduces network chatter. | |
| Browser IndexedDB | Stores fetched articles locally for fast retrieval. | |
| Client‑side Recommendation Engine | Generates a deterministic interest vector from user interactions; never sends data to the server. | |
| Encrypted localStorage | Persists the interest vector, rotates daily to limit exposure. |
Data Flow
- User visits http:/// → Rocket serves the Next.js SPA.
- SPA loads static assets → Service worker caches them.
- Browser fetches /privacy-summary → Receives SPDX‑2.2 JSON, displays it in the “Privacy Dashboard”.
- User reads articles → Interactions feed the client‑side engine, which updates the encrypted vector in localStorage.
- User clicks “Opt‑out” → SPA POSTs to /opt-out; server clears any session data (none in practice) and returns confirmation.
All personalisation data stays on the client, ensuring a truly contextual‑ads‑free experience.
Installation
# Clone the repo
# Add the crate to your
cargo add news-backend
# Or edit manually
news-backend = "0.1.0"
rocket =
serde =
serde_json = "1"
dotenvy = "0.15"
Build the binary:
The executable will appear at target/release/news-backend.
Quick start / usage example
// src/main.rs
# extern crate rocket;
use rocket::;
use rocket::serde::json::Json;
use serde::Serialize;
#
struct PrivacyPolicy
Run the server:
ROCKET_ADDRESS=0.0.0.0 ROCKET_PORT=8000
Visit http://127.0.0.1:8000/privacy-summary – you’ll receive the JSON policy shown above.
Features
- Purpose limitation – Backend only serves static files; no user‑profile database.
- Data minimisation – No IP logging beyond host‑level logs; respects navigator.doNotTrack.
- Transparency – /privacy-summary returns an SPDX‑style machine‑readable policy.
- Cookie‑less tracking – Personalisation data stays encrypted in localStorage, rotated daily.
- Right‑to‑object – /opt-out endpoint clears any possible server‑side session.
- Strong defaults – CSP, X‑Content‑Type‑Options, Permissions‑Policy, X‑Frame‑Options.
- Lightweight – Single‑binary Rust server, minimal runtime dependencies.
Contributing
We welcome contributions! Please read our CONTRIBUTING.md for guidelines on how to submit issues, pull requests, and coding standards.
License
news-backend is released under the MIT license. See the LICENSE file for details.