How rohit-k-singh/fintech-news works
Project Type and Purpose
• This is a Next.js (React-based) front-end application with server-side rendering (SSR) / static site generation, using Redux for state management.
• It fetches finance news from the external Finlight API and displays articles on the Home and Details pages.
Main Components
• Next.js Application
– App Router (app/layout.tsx, app/page.tsx, app/details/page.tsx)
– Global styles (app/globals.css)
• UI Component Layer
– src/components (Navbar, PageWrapper, Loader, ArticleList, ArticleItem)
– src/screens (Home, ArticleDetails)
• State Management
– Redux store (src/store/index.ts)
– articleSlice (src/store/slices/articleSlice.ts)
– Custom hook (src/hooks/useReduxStore.ts)
• Data-Fetch Layer
– Axios instance configured with env vars (src/utils/axiosInstance.ts)
– Type definitions (src/utils/types.ts)
• External Service
– Finlight API (secured by NEXT_PUBLIC_FINLIGHT_API key)
• Build & Test
– Build tools/config (next.config.ts, tsconfig.json, postcss.config.mjs)
– Tests (Jest: jest.config.js, src/tests/ReadArticle.test.js)
Core Relationships & Data Flows
1. Browser/Client loads a route (Home or Article Details).
2. Next.js SSR/SSG layer invokes React components under app/.
3. Components dispatch Redux actions via the custom hook.
4. Redux Thunks in articleSlice call the axiosInstance.
5. axiosInstance makes HTTP requests to the Finlight API.
6. Responses flow back into Redux store → selectors → UI components render updated state.
7. Static assets and global styles are served from the public/ directory and app/globals.css.
Architectural Patterns & Design Principles
• Component Hierarchy: Clear separation between layout (Navbar, PageWrapper), screens, and small reusable components (Loader, ArticleItem).
• State Management: Centralized store (Redux Toolkit slice) for predictable state transitions and caching of fetched articles.
• Data-Fetching Abstraction: Single axiosInstance for all API calls, configured via env vars for flexibility.
• Next.js SSR/SSG: Hybrid rendering for performance and SEO.
Putting It All Together
• Below that, place “AxiosInstance” feeding into “Finlight API.”