How aimanashna12/smartnews works
Project type and purpose
• This is a two‐tier, full‐stack web application:
• Frontend: A React single‐page app (SPA) that displays news, filters by category, and manages favorites.
• Backend: A Node.js HTTP server acting as a proxy to an external News API (no database).
File structure
• Top-level directories:
• /frontend – contains a standard Create React App structure (public assets + src with components).
• /backend – contains server.js, package.json, and a vercel.json (deployment config).
• Frontend components: Navbar, CategoryFilter, NewsCard, Favorites, Footer, plus App.js orchestrating them.
• Backend: a single‐endpoint server.js reading NEWS_API_KEY from .env and forwarding requests to the News API.
README insights
• No database or caching layer—backend simply proxies calls to the external News API.
• Deployment target is Vercel (backend vercel.json).
• Two separate “run” commands: node server.js for backend, npm start for frontend.
a. Main components:
• Client (browser)
• Frontend SPA (React)
• Backend Server (Node.js)
• External News API Service
b. Relationships and interactions:
1. User → Browser (UI interaction).
2. Browser loads the React SPA.
3. React components render and, on events (e.g., “load top headlines” or “change category”), send HTTP(S) requests (GET /news?category=…) to the backend.
4. Backend receives requests, reads NEWS_API_KEY from environment, forwards an HTTP(S) request to the external News API.
5. External News API returns JSON payload.
6. Backend processes the payload (optional filtering) and returns it to the React SPA.
7. SPA updates the state and re-renders NewsCard components.
c. Architectural patterns/design principles:
• Client–server separation (presentation vs. data layer).
• Single‐page app (SPA) on the frontend.
• API Gateway/Proxy pattern on the backend (no direct client → News API calls).
• Environment configuration (.env) for secrets.
• Component‐driven UI (React).
d. Key technologies/frameworks:
• Frontend: React, Create React App, JSX, CSS modules.
• Backend: Node.js, Express‐style server (server.js), dotenv for env vars.
• Deployment: Vercel (vercel.json).
• External Service: News API.