How sakshijha8/blog-frontend works
Project Type and Purpose
• This is a single‐page front‐end application built with React and TypeScript (bootstrapped with Create React App).
• It implements client‐side routing, UI components, state management (Redux Toolkit), and communicates with external APIs (e.g. for login, signup, fetching/posting blogs).
Key File‐Structure Insights
• src/index.tsx: application entry point; bootstraps React into public/index.html.
• src/routes/: defines routing logic via React Router (publicroutes.tsx, privateroutes.tsx, and route registry in index.tsx).
• src/pages/ vs src/components/:
– pages: top‐level views (home, about us, services, create post, sign in/up).
– components: reusable UI blocks (Navbar, Footer, Blogs, Comment, PostBlog, etc).
• src/store/: Redux store and user slice.
• src/utils/: helper functions (e.g. isLogin.ts).
• src/constant, src/interfaces: typed constants and TS interfaces.
• src/styles/: styling organized by component.
a. User & Browser
• User interacts via browser UI.
b. React SPA Container
• Entry (index.tsx) → wraps <App />.
c. Routing Layer
• PublicRoutes & PrivateRoutes determine which pages render based on auth state.
d. Pages
• Each route points to a page component under src/pages.
e. UI Components
• Pages compose atomic/reusable components from src/components.
f. State Management
• Redux store (store.tsx) holds application state; UserSlice handles auth/user data.
• Components dispatch actions / subscribe to state.
g. API/Service Layer
• Thunks or fetch calls (likely in slices or utils) to back‐end REST endpoints (login, signup, CRUD blogs).
h. Assets & Styles
• Assets (images, SVGs) and styles are imported by components/pages.
i. Build & Deployment
• Webpack (via Create React App) bundles code into build/ folder for production.
Relationships and Data Flow
1. User → Browser → React App
2. React App → Routing Layer → Page Component
3. Page Component → UI Components → renders views
4. UI Component → dispatch Redux actions → Store
5. Store (via middleware) → calls external API → updates state
6. State updates → propagates back to Components → UI updates
7. Build pipeline compiles src → static assets served from build/ or public/
Architectural Patterns & Design Principles
• Component‐based UI (React).
• Single Source of Truth (Redux store).
• Declarative routing (React Router).
• Separation of concerns:
• Presentation (components + styles)
• State logic (store + slices)
• Data access (API calls in utils/slices)
• Type safety (TypeScript interfaces & constants).