Skip to content

About

News-to-script prototype with RSS ingestion, heuristic ranking, Prisma/SQLite persistence, and optional Gemini/OpenAI generation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NewsScript

A full-stack prototype that turns ranked news feeds into structured video-script drafts, with saved articles, bookmarks and text/PDF exports.

Why this project exists

Turning a news feed into a useful script involves more than calling a language model: stories need to be collected, deduplicated, ranked, stored and made available for revision. NewsScript connects those steps in one application while retaining a local template fallback for development without AI credentials.

Status: development prototype. The repository includes fictional demo articles and simulated ranking signals. Authentication and deployment controls need further work; use the local demo setup below.

Architecture

flowchart LR
    UI[Next.js client] --> API[App Router API routes]
    API --> News[News aggregation service]
    RSS[Google News RSS] --> News
    Optional[Optional NewsAPI] --> News
    News --> Ranking[Heuristic ranking and title deduplication]
    Ranking --> DB[(Prisma / SQLite)]
    News <--> Cache[In-process TTL cache]
    API --> Generator[Script generation service]
    DB --> Generator
    Generator --> LLM[Gemini or OpenAI]
    Generator --> Fallback[Local template fallback]
    Generator --> DB
    API --> Auth[NextAuth credentials / JWT sessions]
Loading

The main boundaries are API routes, news aggregation, script generation, cache and the database schema.

Engineering Highlights

  • Feed processing: Google News RSS, optional NewsAPI input, HTML cleanup and title-based Jaccard deduplication.
  • Persistence: unique article URLs, stored script drafts, per-user saved articles and bookmarks, activity history and API usage records.
  • Reuse: a 15-minute process-local news cache and stored scripts that can be reused or regenerated.
  • Provider fallback: script generation attempts configured Gemini and OpenAI providers before returning a local template.
  • Creator workflow: structured drafts, short/long video formats, copy, text export and PDF export.

Tech Stack

Area Technologies
Application Next.js 16, React 19, TypeScript
UI Tailwind CSS, React Query, Framer Motion, jsPDF
Backend App Router handlers, RSS parser, service classes
Persistence Prisma 5, SQLite
Authentication NextAuth credentials provider, bcrypt, JWT sessions
Optional AI Google Gemini SDK, OpenAI SDK

How It Works

  1. A category request checks the in-process cache and recently stored articles before fetching feeds.
  2. The aggregation service calculates a weighted score: recency 30%, configured source credibility 25%, mentions 25% and engagement 20%. Mentions and engagement are synthetic heuristics, not measured social activity.
  3. Articles with matching URLs or title Jaccard similarity above 0.55 are deduplicated. Up to 20 candidates are upserted; the top 10 are returned.
  4. An article's title, available feed text, source and category become the script prompt. The result contains a hook, summary, key facts, timeline, short/long scripts and suggested metadata. Drafts require human fact-checking.
  5. Signed-in users can save articles and bookmark drafts. The chatbot receives the ten highest-scored article titles, categories and source names as context; it does not perform vector search or full-document retrieval.

/api/cron/refresh provides a refresh endpoint for an external scheduler. No scheduler is included. Script model identifiers are currently hardcoded to gemini-1.5-flash and gpt-4o-mini; live-provider compatibility must be checked before use.

Setup

Use Node.js 20.9 or newer and npm. Run locally with a fresh disposable database:

git clone https://github.com/yashwant938/NewsScript.git
cd NewsScript
npm ci

Create .env:

DATABASE_URL="file:./local-demo.db"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="replace-with-a-new-random-secret"

Generate a secret with node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))" and paste it into the local environment file. Leave AI provider keys unset for the template demo. GEMINI_API_KEY, OPENAI_API_KEY and NEWS_API_KEY are optional for separately configured live integrations; RSS fetching still uses the network.

npx prisma generate
npx prisma db push
node prisma/seed.js
npm run dev -- --hostname 127.0.0.1

The seed command deletes all existing application records. Run it only against the fresh demo database above, never an existing user database. It creates fictional articles and the following local accounts:

Demo account Email Password
Creator user@newsscript.ai userpassword
Admin admin@newsscript.ai adminpassword

Open localhost:3000. These accounts and the committed development database are unsuitable for deployment. Keep .env out of version control.

Available checks:

npm run lint
npm run build

There is no automated test suite configured in package.json yet.

Example

In the local demo, select Technology, open a seeded article and generate a script. With AI keys unset, the result is a template-generated demonstration, not an LLM response. Inspect the hook, key facts and short/long draft sections, then use copy or export. Sign in with the local creator account to save the article or bookmark the draft.

NewsScript dashboard

Engineering Challenges

  • Freshness versus cost: caching and script reuse reduce repeated work, but the cache belongs to one process and refreshes need coordination before multi-instance deployment.
  • Transparent fallbacks: RSS failures can insert fictional demo articles, and missing/failed providers can produce templates. Responses and UI need clearer live/demo provenance.
  • Authorization: the current admin analytics route permits callers without a session. Generation/chat lack request quotas, and the cron secret is enforced only in production when configured. These gaps must be fixed before exposing the app publicly.
  • Output validation: provider JSON is parsed but lacks runtime schema validation. Generated summaries and analysis are drafts, not verified reporting.

Future Improvements

  • Enforce admin authorization, protect refresh/generation endpoints and add negative authorization tests.
  • Label article and script provenance throughout the UI and API; separate demo fixtures from live data.
  • Add configurable model selection, structured-output validation, timeouts and provider integration tests.
  • Replace synthetic popularity signals with documented data sources or expose the score as a transparent heuristic.
  • Add fresh-install CI, deduplication/cache tests and a migration workflow; evaluate shared caching and a server database only when deployment requirements justify them.

About

News-to-script prototype with RSS ingestion, heuristic ranking, Prisma/SQLite persistence, and optional Gemini/OpenAI generation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages