AI News Commentator
An AI-driven platform that curates news from RSS feeds and APIs, provides AI-powered elaborations with strict attribution, enables personal commentary capture through Q&A, and generates publishable drafts for LinkedIn and Substack with automated roundup scheduling.
Project Architecture
**Principles**: Serverless-first, AWS-native, TypeScript end-to-end, strict attribution handling
**Tech Stack**:
**Frontend**: Next.js/Remix + React + TypeScript**Backend**: Lambda functions + API Gateway**Database**: DynamoDB (primary) + OpenSearch (search/ranking) + S3 (cache)**Auth**: Cognito or Clerk/Auth0**AI**: OpenAI (primary) + Anthropic (fallback)**Queue**: SQS for ingestion pipeline**Scheduler**: EventBridge for roundups**Analytics**: Kinesis Firehose → S3 + QuickSight**Security**: Secrets Manager for OAuth tokens, KMS encryptionDevelopment Workflow
Setup Commands
```bash
npm install # Install dependencies
npm run dev # Start dev server (backend:3001, frontend:3000)
npm run build # Build project
npm run test # Run tests
npm run test:watch # Run tests in watch mode
npm run lint # Lint code
npm run type-check # TypeScript validation
npm run db:migrate # Run database migrations
npm run db:seed # Seed database
npm run clean # Clean builds
```
Project Structure
`/backend` - Express.js API server`/frontend` - Remix.js web application`/shared` - Shared TypeScript types and utilities`/docs` - Project documentation and PRD`/tests` - Test files`/database` - Database migrations and seedsDevelopment Process
**CRITICAL: Follow this mandatory process for EVERY development task:**
1. **Make Changes**: Implement features, write tests, update docs
2. **Validate Code** (ALWAYS run ALL steps before committing):
```bash
npm run build # Ensure code compiles
npm run lint # Check code style
npm run type-check # Verify TypeScript
npm run test # Run all tests
```
**Fix any errors before proceeding - NEVER commit failing code**
3. **Review Changes**:
```bash
git status # See modified files
git diff # Review modifications
```
4. **Stage Files**:
```bash
git add <files> # Stage only relevant files
```
5. **Commit Changes**:
```bash
git commit -m "<type>: <description>"
```
- Use branch name to derive issue number if applicable
- Keep messages concise and professional
- Example: `test: add basic test files and fix missing dependencies`
**Commit Message Types**:
`feat:` - New features`fix:` - Bug fixes`test:` - Test additions`chore:` - Infrastructure tasks`refactor:` - Code improvementsGit Rules
**CRITICAL RULES**:
**NEVER commit to main** unless explicitly instructed (and then seek double confirmation)**NEVER add watermarks, signatures, or AI-generated footers to commit messages****NO "Generated with Claude Code" or "Co-Authored-By: Claude" lines**Keep commit messages clean and professionalBranch naming: `type/personid-linearid-description` (e.g., `feature/macs-MAC-121-ticket-prd`)**When to Commit**:
After fixing bugs or errorsAfter adding new featuresAfter creating or updating testsAfter refactoring codeAfter updating documentation**ANY time you make meaningful changes**PR Creation Process
1. Review all changes: `git diff main...HEAD`
2. Run full test suite: `npm run test`
3. Create PR with descriptive title and body
4. Include "Test plan" section with validation steps
5. Tag reviewers if needed
Coding Guidelines
Write TypeScript with strict mode enabledFollow test-driven development - write tests firstUse JSDoc comments for all public functionsFollow existing code style and conventionsValidate with `npm run lint` and `npm run type-check`All features must be tested with VitestFocus on defensive security practices onlyData Model
**DynamoDB Tables**:
`Users` - User profiles and preferences`Sources` - RSS feeds and API sources with trust scores`Items` - Normalized articles with dedupe clustering`UserItemState` - User actions (viewed, saved, dismissed)`Elaborations` - AI summaries with citations`QnAResponses` - User commentary per item`Drafts` - Generated content with version history`Roundups` - Scheduled content compilations`Tokens` - Encrypted OAuth credentials**OpenSearch Index**: `items_idx` for ranking and search
LLM Integration
**Provider Strategy**:
Primary: OpenAI GPT-5 (cost/latency optimized)Fallback: Anthropic HaikuHard guardrails: Force citations, no claims without source anchors**Key Prompts**:
**Elaboration**: 150-250 word synthesis + 3-5 takeaways + citations**Q&A**: 3-5 POV prompts (Who benefits/loses? What could fail? Startup implications?)**Draft Generation**: Platform-specific (LinkedIn/Substack) with user POV integration**Citation Policy**: Post-generation validator enforces ≥1 citation per elaborationMVP Features (Milestone 1)
Curated feed from RSS + News APIs + light web searchPer-item cards (headline, source, time, blurb, trust score)Actions: Interesting, Elaborate, Save, DismissOne-click Elaborate (150-250 words) + 3-5 takeaways + citations + "Why it matters"3-5 Q&A prompts to capture personal POV (saved to item)Draft generator: LinkedIn (short) + Substack (long) with templates, hashtags, titlesRich-text editor + prompt-edits + version historyOAuth: LinkedIn + Substack; copy-to-clipboard fallbackSaved items → Roundup generator (daily/weekly/monthly)Simple scheduler + notificationsSettings: topics, keywords, regions, sources, template presets, privacy toggleAcceptance Criteria
**Time-to-feed**: New user sees ≥10 relevant items within 120s**Elaborate latency**: p50 ≤ 4s, p95 ≤ 8s**Citation integrity**: 100% of elaborations have ≥1 valid source link**Q&A persistence**: Answers survive page refresh and appear in drafts**Draft constraints**: LinkedIn ≤ 3,000 chars with overflow prevention**Publish flow**: Valid OAuth tokens return post URL and success status**Roundup schedule**: Auto-generated drafts appear on user's local scheduleImplementation Notes
Follow implementation plan in `docs/milestone-1-implementation-plan.md`Use Server Components (Next.js 15 or Remix) with React 19Editor: TipTap or Lexical with Markdown import/exportKeyboard-first UX: j/k navigation, e=elaborate, s=save, d=dismissFeature flags via DynamoDB + edge cachingAttribution footer: "Sources: [Title 1](url1), [Title 2](url2)..."External Dependencies
OpenAI API key (primary LLM provider)Anthropic API key (fallback LLM provider)LinkedIn API OAuth (w_member_social scope)Substack API or email-based tokensNews APIs: NewsAPI, Guardian API, or RSS feedsAWS services: Lambda, DynamoDB, OpenSearch, S3, EventBridge