The DailyNews frontend is a React 18 single-page application that presents a curated news feed to the user. It communicates with the DailyNews backend REST API to fetch, create, update, and delete feed items. The app is bundled by Vite, typed with TypeScript, styled with Tailwind CSS, and navigated with React Router v7. A globalDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/miikorz/DailyNews/llms.txt
Use this file to discover all available pages before exploring further.
ToastContext delivers in-app notifications without any external state management library, and a floating MultiTool button gives quick access to feed creation and dark mode toggling from every page.
Tech Stack
React 18
Component-based UI library. Uses
createRoot and StrictMode for concurrent-ready rendering.Vite
Lightning-fast dev server and build tool. Configured on port 3000 with
@vitejs/plugin-react.TypeScript
Full static typing across components, hooks, contexts, and utility modules.
Tailwind CSS
Utility-first CSS framework with
darkMode: 'class' for togglable dark mode.React Router v7
Declarative client-side routing via
BrowserRouter, Routes, and Route.Jest + React Testing Library
Unit and integration tests with
jest-environment-jsdom and ts-jest.Project Structure
The entire application source lives underfrontend/src/. Each subdirectory has a focused responsibility:
Routing
Routes are declared insrc/main.tsx using React Router v7’s <Routes> and <Route> components. The <Header> and <MultiTool> components are rendered outside the route tree so they remain mounted on every page.
| Path | Component | Description |
|---|---|---|
/ | NewsHome | Main feed — displays the hero heading and the full <NewsList /> |
/new/:id | NewsDetail | Edit an existing feed item identified by :id |
/add | NewsDetail | Create a brand-new feed item (no :id param) |
* | NotFound | 404 catch-all rendered for any unmatched path |
API Configuration
All API endpoint strings are centralised insrc/utils/apiConstants.ts. The base URL is read from the VITE_BACKEND_BASE_URI environment variable at build time. During local development a hardcoded fallback points to http://localhost:3001/feed.
To point the frontend at a remote backend, create a
.env file in the frontend/ directory and set VITE_BACKEND_BASE_URI=https://your-api-host/feed, then uncomment the first line in apiConstants.ts.Global State
The app intentionally avoids Redux or any third-party state library. The only globally shared state is the toast notification queue, provided byToastContext:
ToastProvider— wraps the entire application inmain.tsxand holds thetoastsarray in localuseState.useToast()— hook that exposes{ toasts, addToast, removeToast }to any component in the tree.addToast(message, type)— schedules a toast and automatically removes it after 3 seconds.
useFeedManagement and is scoped to the component that calls the hook.
Dark Mode
Dark mode is implemented with Tailwind’sdarkMode: 'class' strategy. Toggling dark mode adds or removes the dark class on document.body. The MultiTool component’s dark-mode button calls document.body.classList.toggle('dark') and flips a local dark boolean to switch its icon between a moon and a sun.
All Tailwind dark-mode variants (e.g. dark:bg-gray-800, dark:text-gray-100) throughout the component tree react automatically once the class is present on <body>.
Running the Frontend
server.port in vite.config.ts). The preview server also runs on port 3000 with strictPort: true, so make sure that port is free before running either command.