How ritheeshshetty/advance-web-sunshine works
Project Type and Purpose
• This is a full-stack MERN (MongoDB, Express, React, Node.js) news-site application focused on privacy.
• The backend (in backend1/) provides JWT-based authentication, user management, admin analytics, and proxies requests to the external NewsAPI.
• The frontend (in sunshine1/) is a React single-page app that uses Context API for global state, implements infinite scrolling for article feeds, and supports user/admin views and dark mode.
File Structure
• Top-level split:
• backend1/ – Node.js + Express server
– controllers/ (business logic for auth, news grouping, admin)
– routes/ (public & protected API endpoints: auth, news, userData, admin)
– middleware/ (JWT verification, admin checks)
– models/ (Mongoose schemas: User, Stats)
– db.js (MongoDB connection)
– index.js (server bootstrap)
– backup/ (bson dumps of Mongo collections)
• sunshine1/ – React frontend
– public/ (static HTML, manifest, robots.txt)
– src/components/ (UI pieces: Login, Signup, News feed, Admin layouts)
– src/context/userData/ (Context & Provider for auth & user state)
– src/App.js & src/index.js (app entry)
• Config files: package.json, Procfile, vercel.json (deployment settings).
README Insights
• News grouped via NewsAPI calls.
• Infinite scroll + progress bar on feed.
• JWT auth with bcrypt + salt; user data in MongoDB.
• Admin dashboard shows user lists + analytics.
• Context API for efficient state access in React.
Main Components & Interactions
a. Components
• React Frontend (Browser)
• Express Backend (Node.js server)
• MongoDB Database
• External NewsAPI Service
• (Optional) Deployment/Hosting Platform (e.g., Vercel, Heroku)
b. Data Flows & Relationships
1. User → Browser → React UI
2. React UI ↔ Express REST API over HTTPS
3. Express ↔ MongoDB (Mongoose ORM) for user & stats data
4. Express → External NewsAPI for article data
5. Admin actions: React Admin UI → Admin endpoints → DB read/write
6. JWT issuance & verification on protected endpoints
c. Architectural Patterns
• Client-Server (SPA + REST API)
• Token-based auth (JWT)
• Context API for state management (frontend)
• MVC-style layering in backend (routes → controllers → models)
d. Key Technologies & Libraries
• React, Context API, React Router, infinite-scroll libraries
• Node.js, Express, Mongoose
• bcryptjs, jsonwebtoken
• NewsAPI (third-party HTTP calls)