NewsSphere is a responsive, authenticated news dashboard for discovering current stories across major categories. Users can create an account, browse a paginated news feed, open original articles, and view AI-generated summaries without leaving the app.
The frontend is designed to work with the NewsSphere backend API, which supplies authentication, news, and summarization endpoints.
- React
- React-Router-Dom
- Vite
- TailwindCSS
- Axios
- Lucide-React
- Node.js
- Express.js
- Mongoose
- BCrypt
- JWT
- Mongodb
- News API
- Gemini API
- Clean, responsive reading experience built for desktop and mobile.
- Category-based feeds with client-side caching and incremental loading.
- AI summary modal that preserves a generated summary while the session is active.
- Protected routes and automatic sign-out when an API session is no longer valid.
flowchart LR
U[User] --> R[React + Vite frontend]
R --> A[Auth context and protected routes]
R --> S[Axios service layer]
S -->|Bearer token| B[NewsSphere backend API]
B --> N[News and summary services]
B --> D[(User data store)]
R --> C[LocalStorage and SessionStorage]
- Account registration and sign-in.
- Protected dashboard and public-only authentication routes.
- News feeds for All, Business, Technology, Sports, Health, Entertainment, and Science.
- Refresh and load-more controls for paginated articles.
- Article cards with image fallback, source, author, date, and original-article links.
- AI-generated article summaries in an accessible modal.
- Per-category session caching to reduce repeat requests during a browsing session.
- Friendly API error states and automatic handling of unauthorized responses.
| Area | Technology |
|---|---|
| Frontend | React 18, React DOM |
| Build tool | Vite 6 |
| Styling | Tailwind CSS, PostCSS, Autoprefixer |
| Routing | React Router DOM |
| HTTP client | Axios |
| Icons | Lucide React |
| Backend | NewsSphere Backend API |
| Hosting configuration | Vercel |
News Sphere is Live at: https://news-sphere-silk.vercel.app/
The production API is Live at https://news-sphere-backend-api.onrender.com/api.
| Description | Image |
|---|---|
| Landing Page | ![]() |
| Sign Up Page | ![]() |
| Dashboard Page | ![]() |
| entertainment category page | ![]() |
| Summary Modal | ![]() |
| About Page | ![]() |
├── docs/ # screenshots and gif of the project
├── src/
│ ├── components/ # Reusable UI components and summary modal
│ ├── context/ # Authentication provider and state
│ ├── hooks/ # Reusable React hooks
│ ├── pages/ # Landing, auth, dashboard, and about pages
│ ├── routes/ # Public and protected route definitions
│ ├── services/ # Axios client, auth, and news API calls
│ ├── utils/ # Error and date helpers
│ ├── App.jsx
│ └── main.jsx
├── .env.example # Required frontend environment variables
├── vercel.json # SPA rewrite configuration for Vercel
├── vite.config.js
└── package.json
The API uses MongoDB through Mongoose. It currently defines User and
savedArticles collections; saved articles are modeled for future use.
| Field | Type | Required | Description |
|---|---|---|---|
_id |
ObjectId |
Generated | Unique user identifier. |
username |
String |
Yes | User's username. |
name |
String |
Yes | User's display name. |
email |
String |
Yes | User's email address. |
password |
String |
Yes | bcrypt-hashed password. |
savedArticles |
ObjectId[] |
No | References to documents in the savedArticles collection. |
createdAt |
Date |
Generated | Account creation timestamp; defaults to the current date and time. |
| Field | Type | Required | Description |
|---|---|---|---|
_id |
ObjectId |
Generated | Unique saved-article identifier. |
userId |
ObjectId |
Yes | Reference to the owning User. |
articleId |
String |
Yes | Identifier for the source article. |
summary |
String |
Yes | Saved AI-generated article summary. |
savedAt |
Date |
Generated | Save timestamp; defaults to the current date and time. |
Relationship: one user can reference many saved articles through
users.savedArticles; each saved-article document belongs to one user through savedArticles.userId.
Both schemas disable Mongoose's default __v version field.
Create a .env file in the project root:
VITE_API_BASE_URL=http://localhost:5000/apiFor the deployed API, set the value to:
VITE_API_BASE_URL=https://news-sphere-backend-api.onrender.com/apiVite exposes only variables prefixed with VITE_ to the client. Do not place secrets in this file.
-
Clone the frontend repository.
git clone https://github.com/DeShyam01/news-sphere.git cd news-sphere -
Install dependencies.
npm install
-
Copy
.env.exampleto.envand setVITE_API_BASE_URLto a running NewsSphere backend instance. (Localhost or Deployed backend) -
Set up and run the backend API if you are using a local API URL.
Before starting the frontend, if you are using a local API URL, then ensure that the backend API is running locally.
Then run the frontend:
npm run devOpen the local URL printed by Vite, usually http://localhost:5173. Create an account or sign in, then use the category tabs, refresh control, and Load More button to browse stories. Select View Summary on an article to request its summary.
Other available commands:
npm run build # Create an optimized production build
npm run preview # Preview the production build locallyThe frontend calls the backend endpoints below:
| Action | Endpoint | Payload |
|---|---|---|
| Sign up | POST /users/signup |
name, username, email, password |
| Sign in | POST /users/signin |
username, password |
The token returned by the API is stored in localStorage as newssphere_token. Axios sends it on subsequent API calls through the Authorization: Bearer <token> header. Dashboard and About routes require this token; a 401 response clears it and redirects the user to the landing page.
This project includes a vercel.json rewrite so React Router routes resolve correctly in a Vercel deployment.
- Push the project to GitHub and import it into Vercel.
- Set
VITE_API_BASE_URLin Vercel project environment variables to the deployed backend API URL. - Deploy using the default Vite build settings:
npm run buildwithdistas the output directory.
For other hosts, configure a single-page application fallback so all application routes serve index.html.
- Keeping the reading flow smooth while handling paginated feeds, category changes, duplicate stories, and network errors.
- Supporting slightly different article field shapes from API responses while keeping cards and summaries consistent.
- Managing authentication state across refreshes and safely recovering from expired tokens.
- Preventing duplicate summary requests while making summaries available across cached category feeds.
- React context provides a focused way to share authentication state and actions across routes.
- Service-layer API calls keep components centered on presentation and interaction.
- Session caching improves perceived performance for frequently revisited category feeds.
- Deploying a single-page app requires server rewrites in addition to a successful production build.
- Add search, saved articles, and user reading preferences.
- Add automated tests for authentication, routing, API services, and dashboard interactions.
- Add skeleton loaders and retry strategies for slow news providers.
- Add a live frontend URL, demo GIF, and screenshots to this README.
- Support dark mode and improved accessibility preferences.
Contributions are welcome.
- Fork the repository and create a branch for your change.
- Make focused changes and verify the production build with
npm run build. - Open a pull request describing the problem, solution, and any UI changes.
Made with ❤️ by Shyamsundar Gayen.






