This project is a full-stack web application for scraping, analyzing, and displaying political news articles. The backend scrapes articles from a set of URLs, saves them as JSON files, and provides endpoints for the frontend to fetch and display them. The frontend allows users to trigger scraping and view all available articles at once.
- Provide a simple interface to view and analyze the latest political news articles.
- Allow users to trigger scraping of new articles from the frontend.
- Display all available articles in a scrollable list, supporting any number of articles.
- Backend: Python, FastAPI, newspaper3k
- Frontend: SvelteKit, TypeScript, CSS
- Other: Uvicorn (ASGI server), Node.js (for frontend tooling)
./
├── backend/
│ ├── main.py # FastAPI backend
│ ├── scrape_article.py # Scraper script for articles
│ ├── political_articles/ # Folder for scraped article JSON files
│ └── ...
├── frontend/
│ ├── src/components/ # Svelte components
│ ├── src/routes/ # SvelteKit routes
│ └── ...
├── .venv/ # Python virtual environment
├── README.md
├── changelog.md
├── to-do.md
├── .gitignore
├── START.md # Quick start instructions
└── ...
- Start both backend and frontend servers (see START.md).
- Click the politics link in the UI to trigger scraping.
- All articles in the backend/political_articles folder will be loaded and displayed below one another.
- The app supports any number of articles present in the folder.
- Backend:
- Create and activate a virtual environment:
python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install fastapi uvicorn python-dotenv httpx newspaper3k - Start the backend:
uvicorn backend.main:app --reload
- Create and activate a virtual environment:
- Frontend:
- Install dependencies:
npm install - Start the dev server:
npm run dev - The Vite proxy in
vite.config.tsforwards/backendrequests to FastAPI.
- Install dependencies:
- The Vite config rewrites
/backendto/for the backend:server: { proxy: { '/backend': { target: 'http://localhost:8000', changeOrigin: true, rewrite: path => path.replace(/^\/backend/, '') } } }
- The frontend always loads and displays the first available article in
backend/political_articles. - No dropdown or manual selection is shown to the user.
- To add a new article, run the scraper script with the desired URL.
- The new article will be available automatically in the frontend.
For more details, see the code and comments in PoliticalNewsExample.svelte and backend/main.py.
- Start the Backend Server:
(Ensure your virtual environment is activated)
cd backend uvicorn main:app --reload # Server runs at http://localhost:8000 cd ..
- Start the Frontend Dev Server:
cd frontend npm run dev -- --open # App runs at http://localhost:5173 (or next available port)
deconstructed is a web application designed to combat division and distrust by presenting news content in a neutral, emotion-free manner. It fetches articles, analyzes them using an LLM backend (integrated with OpenRouter), and displays the deconstructed content through a SvelteKit frontend.
The primary goal is to provide users with a tool that helps them understand news events without the emotional charge often found in standard reporting. By stripping away polarizing language and focusing on factual content, the project aims to foster more informed and rational public discourse.
- Framework: SvelteKit (with Svelte 5 Runes)
- Language: TypeScript
- Styling: CSS with CSS Variables (component-scoped and global styles defined in
src/styles) - Fonts: Google Fonts (imported via
src/styles/fonts.css) - Animations: Svelte built-in transitions and custom animations (
src/components/animations.ts)
- Framework: FastAPI (Python)
- LLM Integration: OpenRouter API
- HTTP Client: httpx
- Environment Management: python-dotenv
- Version Control: Git
- IDE: VS Code with Cursor
- Package Manager: npm (frontend), pip (backend)
destructured/
├── backend/ # FastAPI backend (Python, LLM integration)
│ ├── articles/ # Example articles for analysis (Markdown)
│ ├── context/ # Context files for LLM analysis (Markdown)
│ ├── __pycache__/ # Python cache (ignored)
│ ├── main.py # FastAPI app entry point
│ └── requirements.txt # Python dependencies
├── frontend/ # SvelteKit frontend
│ ├── src/
│ │ ├── components/ # Reusable Svelte components
│ │ │ └── index.ts # Barrel file for component exports
│ │ ├── routes/ # SvelteKit page routes (+layout.svelte, +page.svelte)
│ │ └── styles/ # Global CSS files (app.css, colors.css, fonts.css)
│ ├── static/ # Static assets (e.g., favicon)
│ ├── node_modules/ # Node.js dependencies (ignored)
│ ├── .svelte-kit/ # SvelteKit build files (ignored)
│ ├── package.json
│ ├── package-lock.json
│ ├── svelte.config.js
│ ├── tsconfig.json
│ └── vite.config.ts
├── .cursor/ # Cursor configuration/rules
├── .venv/ # Python virtual environment (ignored)
├── archive/ # Archived files (ignored)
├── .env # Environment variables (ignored)
├── .gitignore # Git ignore configuration
├── .npmrc # Npm configuration
├── changelog.md # Project changelog
├── LICENSE # Project license
├── README.md # This file
└── to-do.md # Project to-do list
- Node.js and npm
- Python and pip
- Git
- Clone the repository:
git clone <repository-url> cd deconstructed
- Backend Setup:
cd backend python -m venv ../.venv # Create virtual env in root .venv folder # Activate the virtual environment (adjust for your OS/shell) # Windows (Git Bash/Linux Subsystem): source ../.venv/Scripts/activate # Windows (Command Prompt): ..\.venv\Scripts\activate.bat # Windows (PowerShell): ..\.venv\Scripts\Activate.ps1 pip install -r requirements.txt # Create a .env file in the *project root* (/) and add your OPENROUTER_API_KEY # Example .env: # OPENROUTER_API_KEY=sk-or-... cd ..
- Frontend Setup:
cd frontend npm install cd ..
- Uses FastAPI.
- Integrates with OpenRouter LLM API (requires
OPENROUTER_API_KEYin root.envfile). - Analyzes articles from
backend/articles/using context frombackend/context/. /analyzeendpoint takesarticle_filenameand usertext(question/instruction).- Constructs a prompt for the LLM, combining context and the article content.
- Handles file not found errors.
- Planned: Support scraping articles directly from URLs.
- Responsive grid layout using CSS Grid.
- Component-based architecture (Svelte 5 Runes) with barrel file exports.
- Centralized CSS theming (
src/styles/colors.css,src/styles/fonts.css). - Scoped component styles alongside global styles (
src/styles/app.css). - Type-safe development with TypeScript.
- LLM-powered article analysis via FastAPI backend.
- Interactive splash screen on load.
- Standardized CSS variable naming and usage.
A tool that scrapes and deconstructs news content from multiple sources. Users can select news categories like Political, Financial, or World news. Initially supporting Political news only. The system scrapes predetermined sites for popular stories, processes them through the deconstructor, and presents neutral, fact-based content.
- Multi-source news aggregation
- Political bias detection
- Emotional language filtering
- Fact-based content generation
- Source diversity (left/center/right)
-
Category Selection
- Select news category
- Validate selection
- Initialize session
-
Source Management
- Load source configuration
- Check source health
- Manage source rotation
- Set rate limits
-
Content Gathering
- Scan websites
- Handle request failures
- Clean content
- Store articles
-
Article Analysis
- Group similar stories
- Calculate popularity
- Check source diversity
- Select top stories
-
Content Processing
- Find related content
- Verify relevance
- Group by perspective
- Extract key facts
-
Depolarization
- Analyze sentiment
- Filter charged language
- Verify facts
- Generate summary
- Add attribution
-
Quality Assurance
- Validate content
- Check facts
- Ensure balance
- Verify clarity
-
Content Delivery
- Format content
- Add metadata
- Generate output
- Update UI
-
System Monitoring
- Track metrics
- Monitor sources
- Collect feedback
- Update scores
-
Error Management
- Log errors
- Recover gracefully
- Use cache
- Alert admins
- Initialize project
- Set up TypeScript
- Configure dev environment
- Set up version control
- Create directory structure
- Configure project
- Set up Git
- Add gitignore
- Build header
- Create navigation
- Add content viewer
- Create URL input
- Add placeholders
- Implement grid layout
- Set up CSS system
- Add fonts
- Create animations
- Add category selector
- Show loading states
- Create feedback system
- Ensure accessibility
- Set up FastAPI backend
- Integrate OpenRouter LLM API
- Load context files from backend/context
- Analyze a specified article from backend/articles using context
- [Future] Support analyzing articles scraped from URLs
- Set up news sources
- Add source categories
- Configure metadata
- Validate sources
- Extract articles
- Clean content
- Detect duplicates
- Validate content