diff --git a/CHANGELOG.md b/CHANGELOG.md index ed3809c..2e67fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Format: [Keep a Changelog](https://keepachangelog.com/); versioning: [SemVer](ht ## [Unreleased] ### Added +- Data saver: a header switch (automatic on Save-Data and 2G/3G) that serves lighter Cloudinary renditions and the `sd` streaming ladder; 33–76% fewer bytes measured (Phase 21) - Concept Map `/concepts` and Compare view `/concepts/[key]`: the same concept from every teacher as one Compare Reel (Phase 19) - Cloudinary asset index: tags and contextual metadata on each session's asset, synced from the Studio and read back with the Search API (Phase 19) diff --git a/README.md b/README.md index 50ccce9..1ffc23f 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Colleges, clubs and coaching institutes record hundreds of hours of lectures and | **Answer Reels** | The moments an answer cites, from different speakers and sessions, stitched into one labelled video. | | **Concept Map** | `/concepts` lines up every concept your lectures teach and how many different teachers explain it. Open one and hear the same idea from each lecturer, back to back, as one Cloudinary-spliced video, until one explanation clicks. | | **Learning Paths** | `/learn`: type a topic and get a 3–5 step course, ordered basics first, drawn from moments across the library and edited into one video. | +| **Data saver** | One switch (and automatic on Save-Data or 2G/3G) serves smaller, lower-quality Cloudinary renditions: thumbnails 76% lighter, clips and reels 38–41%, and a streaming ladder that tops out at 0.9 Mbps instead of 3.4. Built for India’s mobile data. | | **Study Packs** | Every session gets a summary, key concepts, a quiz whose explanations **play the moment** the teacher explains it, and a "Session in 60 seconds" highlight reel. Pravaha generates them automatically from the transcript. | | **Moments** | One tap turns any cited clip into a vertical, AI-cropped, subtitled short for WhatsApp or Instagram, with its own share page and preview card. The short is just a Cloudinary URL; nothing is rendered. | | **Insights** | Organizers see what learners ask, the **knowledge gaps** the library can't answer yet (what to record next), and which Moments get shared. Every report downloads as CSV. Visitors can explore a read-only demo of the Studio. | @@ -121,6 +122,7 @@ Cloudinary isn't just storage here; the product depends on it. | `e_preview:duration_6` | **AI hover previews** on library cards: the session's most interesting moments in 6 silent seconds | | `so_`/`eo_` + `c_fill,ar_9:16,g_auto` + timed `l_text` captions + `f_auto,q_auto` | **Moments**: trimmed, subject-tracked, subtitled vertical clips | | `g_auto` thumbnails and poster frames | Content-aware library cards, results and social preview cards | +| `q_auto:low`, `c_limit`/`w_` sizing, `sp_sd` streaming profile | **Data saver**: every video, reel, thumbnail and the HLS ladder re-requested lighter for slow or metered connections | | `l_video:…,fl_splice` + timed `l_text` labels | **Answer Reels** and **Session in 60 seconds**: moments from one or more sessions stitched into one video | | Webhooks (`notification_url`, signature-verified) | Upload → transcribed → `ready` with no polling | | Incoming transformation `eo_60` on a second signed preset | **Try it** uploads: Cloudinary keeps only the first 60 seconds, so a public upload can't cost more | diff --git a/docs/CLOUDINARY.md b/docs/CLOUDINARY.md index 008f5a4..b1619de 100644 --- a/docs/CLOUDINARY.md +++ b/docs/CLOUDINARY.md @@ -20,6 +20,7 @@ Learner (browser) ◀── HLS adaptive stream · Moment clips · g_auto thumbn |---|---|---| | Ingest | Signed direct upload (Upload Widget) | Large-file upload handling + object storage | | Watch | `auto_transcription` | A speech-to-text pipeline (Whisper on GPUs) | +| Watch | `sp_sd` streaming profile, `q_auto:low`, `w_`/`c_limit` sizing | A second, lower-bitrate encode of the whole library and a client-side switch between them | | Watch | `auto_chaptering` | A chaptering model | | Watch | Video Player: HLS adaptive streaming, chapters, subtitles | An encoding ladder (FFmpeg) + HLS packaging + a player | | Find / Ask | The transcript is the corpus both pillars search | Our own STT output | diff --git a/docs/COST.md b/docs/COST.md index e99ab5d..2ca4e10 100644 --- a/docs/COST.md +++ b/docs/COST.md @@ -4,7 +4,7 @@ Every figure is tagged **ACTUAL** (by design / confirmed plan mechanics), **ESTI | Service | Tier | Tag | Notes | |---|---|---|---| -| Cloudinary | Free — 25 credits/month (1 credit = 1,000 transformations, 1 GB storage or 1 GB bandwidth); 100 MB per video | **ACTUAL** (Oct 2 usage check) | Video processing is the heavy item: each SD second counts 2 transformations, each HD second 4. Testing on two short clips used 11.2 credits. An HLS ladder multiplies that per rendition, so the player uses `hd_lean` (720p/360p/180p) instead of `full_hd`'s six renditions: roughly 8 transformations per second of video instead of about 16. The demo library is sized to fit: ~6 sessions of 2–3 minutes | +| Cloudinary | Free — 25 credits/month (1 credit = 1,000 transformations, 1 GB storage or 1 GB bandwidth); 100 MB per video | **ACTUAL** (Oct 2 usage check) | Video processing is the heavy item: each SD second counts 2 transformations, each HD second 4. Testing on two short clips used 11.2 credits. An HLS ladder multiplies that per rendition, so the player uses `hd_lean` (720p/360p/180p) instead of `full_hd`'s six renditions: roughly 8 transformations per second of video instead of about 16. The demo library is sized to fit: ~6 sessions of 2–3 minutes. Data saver adds a second, lighter `sd` ladder per session, generated the first time someone views it in that mode | | Google Gemini (Flash / Flash-Lite) | Free tier / pay-as-you-go | **ASSUMPTION** | ~2–3k tokens per Ask; Flash-class pricing is a fraction of a cent per Ask; a few hundred Asks during build + judging. Hard-bounded by the app rate limits (60/h/IP, 500/day) **and** a budget alert in Google AI Studio / Cloud billing | | Neon Postgres | Free | **ESTIMATE** | Thousands of segment rows ≈ a few MB | | Vercel | Hobby | **ESTIMATE** | Demo traffic is tiny; Ask's `maxDuration` (30 s) and Study Packs' (60 s) fit Hobby function limits | diff --git a/docs/DEMO.md b/docs/DEMO.md index 70249b3..ba4d40f 100644 --- a/docs/DEMO.md +++ b/docs/DEMO.md @@ -26,6 +26,8 @@ Never show setup, code, dashboards or waiting. Every shot is the problem, the pr | 2:24–2:35 | **Cloudinary under the hood** panel on the answer: each URL step explained | "Every clip, reel and short is a Cloudinary transformation, and Pravaha shows exactly which." | | 2:35–2:45 | Architecture strip: Cloudinary (transcription · chaptering · streaming · g_auto · e_preview · transformations) + Pravaha (retrieval · grounded Ask · Moments · Insights) · team | "Cloudinary turns video into data. Pravaha turns data into answers you can watch. Code Blooded, Track 3." | +**Bonus shot (if there is time):** header → **Data saver** on → the same answer reel and thumbnails reload visibly lighter. Voice-over: "Built for India’s mobile data: one switch, and Cloudinary serves everything at a fraction of the bytes." + ## Pre-Recording Checklist - **Cloudinary credits first** (free plan: 25 a month). Check usage before recording. New uploads, new answer clips, reels and Moments cost credits; already-generated URLs don't. If usage is near the limit, upgrade first. If you can't, film the upload shot from an existing recording, and ask only questions that have been asked before (their clips are cached). diff --git a/docs/IMPLEMENTATION_PLAN.md b/docs/IMPLEMENTATION_PLAN.md index 63a19de..67e4502 100644 --- a/docs/IMPLEMENTATION_PLAN.md +++ b/docs/IMPLEMENTATION_PLAN.md @@ -94,3 +94,4 @@ The core loop (Phases 01–09) is built and verified on real Cloudinary + Neon. | 18 | Query understanding, Learning Paths, AI reliability | Rewrite questions into the library's words (and translate them), honest near-miss answers, `/learn` micro-courses as one Cloudinary reel, circuit breaker + deep health | ✅ done (Oct 3) | | 19 | Concept Map & Cloudinary asset index | Same concept, every teacher, as one Compare Reel; tags + contextual metadata on Cloudinary assets, read back with the Search API | ✅ done (Oct 3) | +| 21 | Data saver | Light Cloudinary renditions (35–76% fewer bytes, sd streaming ladder) for slow or metered connections; follows Save-Data and 2G/3G automatically | ✅ done (Oct 3) | diff --git a/docs/phases/PHASE-21-data-saver.md b/docs/phases/PHASE-21-data-saver.md new file mode 100644 index 0000000..0c9debe --- /dev/null +++ b/docs/phases/PHASE-21-data-saver.md @@ -0,0 +1,27 @@ +# Phase 21 — Data saver + +**Status: DONE (Oct 3)** · branch `feature/data-saver-mode` + +## Why +Most learners in India watch on mobile data that is slow, metered, or both. A 720p lecture stream and a full-size clip can cost more than a student wants to spend on one question. Cloudinary can serve any asset at any size and quality from one public id, so the fix is a choice of URL, not a second copy of the library. + +## What shipped +- **One rewrite, `liteUrl()`** (`src/lib/media.ts`): turns any Cloudinary URL Pravaha builds into its light version. Frames halve (reels 1280×720 → 640×360, Moments 720 → 360 wide, thumbnails and previews 640 → 320), `q_auto` becomes `q_auto:low`, original-framing clips are capped at 640 wide, and burned-in captions and labels shrink with the frame so they stay in proportion. It lives beside the builders whose constants it mirrors, and tests build real URLs and check the result. +- **Player:** streams the `sd` ladder (top rendition 931 kbps, against 3.4 Mbps for `hd_lean`) and skips the seek-bar sprite and highlights graph, two extra downloads. The player is created only after the mode is known, so a slow connection never starts on the full ladder. +- **Library cards** stop loading hover previews. +- **Switch** in the header. With nothing stored it follows the browser: it turns on by itself for Save-Data and 2G/3G connections. The choice is remembered on this device only (`src/lib/data-saver.ts`). + +## Measured on real Cloudinary output +| Asset | Full | Data saver | Saved | +|---|---|---|---| +| Thumbnail | 46.7 KB | 11.2 KB | 76% | +| Clip (original framing) | 397.6 KB | 233.5 KB | 41% | +| Answer / Compare reel (2 clips) | 794.6 KB | 490.0 KB | 38% | +| Moment (vertical, captioned) | 344.2 KB | 223.6 KB | 35% | +| Hover preview | 145.0 KB | 97.4 KB | 33% | +| Streaming ladder, top rendition | 3.4 Mbps | 0.93 Mbps | 73% | + +Browser-checked: the switch flips thumbnails `w_640,q_auto` → `w_320,q_auto:low`, reels to 640×360, and the player requests `sp_sd` / `br_sd480` instead of `sp_hd_lean` / `br_hd720`. + +## Cost note +The first light view of a session generates the `sd` ladder once (extra transformation credits); after that it is CDN-cached like everything else. Light renditions are smaller, so they cost less bandwidth. diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 0ca2c0c..a78bf21 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata, Viewport } from "next"; import { Inter } from "next/font/google"; import Link from "next/link"; +import { DataSaverToggle } from "@/components/DataSaverToggle"; import { LogoMark } from "@/components/Logo"; import { SearchShortcut } from "@/components/SearchShortcut"; import { SiteChrome } from "@/components/SiteChrome"; @@ -72,6 +73,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) > Try it + diff --git a/src/components/AskAnswer.tsx b/src/components/AskAnswer.tsx index c7587b5..674346f 100644 --- a/src/components/AskAnswer.tsx +++ b/src/components/AskAnswer.tsx @@ -8,6 +8,7 @@ import { MomentButton } from "@/components/MomentButton"; import { UnderTheHood } from "@/components/UnderTheHood"; import { Snippet } from "@/components/ResultCard"; import { SaveButton } from "@/components/SaveButton"; +import { useLiteUrl } from "@/lib/data-saver"; import { formatTime } from "@/lib/format"; import type { SnippetPart } from "@/lib/highlight"; import type { TimedWord } from "@/lib/segments"; @@ -245,6 +246,7 @@ const VOTE_KEY = (id: string) => `pravaha-vote-${id}`; // Perplexity-style action bar under an answer: what it was built from, then Share, Copy and 👍/👎. function AnswerActions({ data, question }: { data: Extract; question: string }) { + const lt = useLiteUrl(); const [copied, setCopied] = useState<"link" | "text" | null>(null); const [vote, setVote] = useState<"up" | "down" | null>(null); const answerId = data.answerId ?? null; @@ -310,7 +312,7 @@ function AnswerActions({ data, question }: { data: Extract ( }) { const [playing, setPlaying] = useState(false); + const lt = useLiteUrl(); if (playing) { - return