How irfan-chowdhury/ph-level2-b5-assignment-6-frontend works
1. Overall shape
This is a single-page frontend built with React + Vite + TypeScript, styled with TailwindCSS and a large set of Radix/shadcn-style UI primitives. The app is organized around role-based experiences for User, Agent, and Admin, with a public marketing/landing area and separate authenticated dashboards.
2. Entry and application shell
The runtime starts in src/main.tsx, which mounts the app and applies global providers. src/App.tsx and src/routes/index.tsx appear to own top-level route composition, while src/index.css provides global styling. The app also wraps theme handling through src/providers/theme.provider.tsx and src/context/theme.context.ts.
3. Routing and access control
Route boundaries are enforced in src/utils/ProtectedRoute.tsx, src/utils/withAuth.tsx, and src/utils/generateRoutes.ts. These utilities gate access by authentication state and role, and likely redirect unauthorized users to src/pages/Unauthorized.tsx. This is the key boundary between public pages and dashboard-only pages.
4. Public-facing pages
The public surface includes Homepage, About, Features, FAQ, Pricing, Contact, Privacy, Terms, Tours, TourDetails, Booking, plus Login, Register, Verify, and payment result pages (Success, Fail). These pages are mostly routed through a common layout and share a landing-page style UX rather than dashboard chrome.
5. Role-based dashboard layouts
There are distinct layout shells for each role in src/components/layout and mirrored dashboard page shells under src/pages/Dashboard/{Admin,Agent,User}. Each role has its own Navbar, Sidebar, and Footer, which means the UI boundary is not just route-based but also layout-based. This is where the authenticated workspace is visually and functionally separated.
6. Core wallet domain flows
The wallet application centers on wallet balance and transaction operations. User pages handle deposit, send money, withdraw money, transaction history, and profile management. Agent pages handle cash-in/cash-out on behalf of users and their own wallet actions. Admin pages manage users, agents, wallets, and transaction oversight. These flows are the main business paths that should dominate any architecture diagram.
7. State management and server communication
The data layer is centered on Redux Toolkit with RTK Query-style APIs in src/redux. Important API slices include auth.api.ts, walletApi.ts, profileApi.ts, adminApi.ts, dashboardApi.ts, booking.api.ts, tour.api.ts, and division.api.ts. Requests are built on a custom Axios base layer in src/redux/axiosBaseQuery.ts and src/lib/axios.ts, with a shared store in src/redux/store.ts.
8. Backend boundary
The frontend talks to a backend API configured through VITE_BASE_URL in the environment. The README indicates REST endpoints for authentication, wallet actions, transaction history, and admin management. So the architecture boundary is a classic React client → HTTP API backend model, with no local persistence layer beyond client state and auth/session handling.
9. Authentication and role model
Auth is handled through Redux-backed APIs plus service wrappers in src/services/authService.ts, src/services/userService.ts, and src/services/walleteService.ts. Role constants live in src/constants/role.ts, and login/logout behavior is supported by hooks like useLogout. The key architectural concern is role-aware session state that drives both routing and menu visibility.
10. Reusable UI and form infrastructure
Shared interaction pieces live under src/components/ui and include dialogs, tables, forms, inputs, selects, sheets, tooltips, and alerts. Higher-level reusable components such as ProfileForm, SingleImageUploader, MultipleImageUploader, and confirmation dialogs support multiple features across pages. This keeps feature pages thin and pushes interaction patterns into reusable modules.
11. Theme and device responsiveness
The app supports dark/light mode via ModeToggler, useTheme, and the theme provider/context pair. Responsive behavior is also supported through use-mobile and mobile-oriented layout components. These are cross-cutting concerns rather than feature-specific code, so they sit beside routing and auth in the architecture.
12. Feature modules and legacy/secondary domain code
There is a secondary feature set around tour/division/admin content management under src/components/modules/Admin, src/components/modules/Tours, and related pages like AddTour, AddDivision, and AddTourType. This looks like either a shared template layer or legacy domain code coexisting with the wallet product. For diagramming, treat it as a separate feature area adjacent to the wallet core, not the main business spine.
13. Deployment/runtime tooling
The project is configured for Vite-based frontend builds, with deployment files such as vercel.json and deploy.yml. The app is therefore a static frontend artifact that depends on an external API service at runtime, rather than a server-rendered or monolithic backend app.
14. Important diagram takeaway
The clearest architecture view is: public marketing/auth pages → authenticated role-based dashboards → Redux/RTK Query + Axios data layer → remote wallet/admin API. Around that core are shared UI primitives, theme/responsiveness concerns, and a smaller set of legacy tour-management modules.
Main entry points: axiosBaseQuery.ts Axios base · store.ts Redux store · Homepage.tsx Public pages · AdminOverview.tsx Admin dashboard
Components 26
Public surface
Landing, auth, and public content routes.
- Public pages · Homepage, marketing pages, auth pages, and payment result pages.
src/pages/Homepage.tsx
Role dashboards
Authenticated workspaces split by user role.
- Role layouts · Admin, agent, and user dashboard layout shells.
src/components/layout/AdminLayout.tsx - Admin dashboard · Admin overview, users, agents, wallets, and transactions.
src/pages/Dashboard/Admin/AdminOverview.tsx - Agent dashboard · Agent cash-in, cash-out, overview, and transactions.
src/pages/Dashboard/Agent/AgentOverview.tsx - User dashboard · User deposit, send, withdraw, history, and profile flows.
src/pages/Dashboard/User/UserOverview.tsx
Data layer
Redux, API slices, axios base, and service wrappers.
- Wallet API · Wallet and transaction endpoints for the main business flow.
src/redux/walletApi.ts - Auth API · Authentication and session-related endpoints.
src/redux/features/auth/auth.api.ts - Profile API · Profile retrieval and updates.
src/redux/profileApi.ts - Admin API · Admin management endpoints for users, agents, and oversight.
src/redux/adminApi.ts - Dashboard API · Dashboard summary and role-specific aggregates.
src/redux/dashboardApi.ts - Axios base · Custom base query backed by Axios.
src/redux/axiosBaseQuery.ts - Axios client · Shared Axios configuration and instance helpers.
src/lib/axios.ts - Redux store · Central Redux Toolkit store and middleware setup.
src/redux/store.ts - Redux hooks · Typed hooks for dispatch and selector usage.
src/redux/hook.ts
Shared shell
Cross-cutting layout, theme, and reusable UI.
- main · Bootstraps the React app and mounts global providers.
src/main.tsx - App routes · Top-level app composition and route wiring.
src/App.tsx - Route map · Central route definitions and composition.
src/routes/index.tsx - Protected route · Role- and auth-based route gating.
src/utils/ProtectedRoute.tsx - withAuth · Higher-order auth/role wrapper for pages and routes.
src/utils/withAuth.tsx - Generate routes · Builds route structures from role and auth state.
src/utils/generateRoutes.ts - Theme provider · Provides light/dark theme context to the app.
src/providers/theme.provider.tsx - Theme context · Theme state and related context wiring.
src/context/theme.context.ts - Common layout · Shared public-facing layout chrome.
src/components/layout/CommonLayout.tsx - UI primitives · Shared dialog, table, form, input, and navigation primitives.
src/components/ui/button.tsx - Form widgets · Reusable profile forms, uploaders, and confirmation dialogs.
src/components/ProfileForm.tsx
Secondary features
Tour and division content-management modules.
- Tour modules · Tour and division management modules used by secondary content flows.
src/components/modules/Tours/TourFilters.tsx
Connections 39
- main → Theme provider: wraps · The app bootstraps global theme handling.
- main → App routes: mounts · Main mounts the application shell and routing.
- App routes → Route map: uses · App composition is driven by route definitions.
- Route map → Protected route: guards · Protected routes enforce auth and role access.
- Route map → withAuth: wraps · Route entries are wrapped with auth helpers.
- Route map → Generate routes: builds · Dynamic route structures are generated from shared helpers.
- Protected route → Public pages: allows · Public pages remain accessible without dashboard auth.
- Protected route → Admin dashboard: permits · Admin workspace is behind role checks.
- Protected route → Agent dashboard: permits · Agent workspace is behind role checks.
- Protected route → User dashboard: permits · User workspace is behind role checks.
- Theme provider → Theme context: provides · Provider supplies theme state through context.
- Public pages → Common layout: renders in · Public pages share common marketing/auth layout.
- Admin dashboard → Role layouts: renders in · Admin workspace uses its role shell.
- Agent dashboard → Role layouts: renders in · Agent workspace uses its role shell.
- User dashboard → Role layouts: renders in · User workspace uses its role shell.
- Admin dashboard → Admin API: fetches · Admin screens consume admin management endpoints.
- Admin dashboard → Dashboard API: fetches · Admin screens also use dashboard aggregates.
- Agent dashboard → Wallet API: fetches · Agent cash flows depend on wallet actions.
- Agent dashboard → Profile API: fetches · Agent profile views and edits use profile data.
- User dashboard → Wallet API: fetches · User money movement depends on wallet endpoints.
- User dashboard → Profile API: fetches · User profile pages use profile data.
- Public pages → Auth API: fetches · Login, register, and verify pages use auth endpoints.
- Public pages → Axios base: requests · Public and authenticated pages call the shared HTTP layer.
- Wallet API → Axios base: uses · Wallet data operations run through the base query.
- Auth API → Axios base: uses · Auth requests run through the shared HTTP layer.
- Profile API → Axios base: uses · Profile requests run through the shared HTTP layer.
- Admin API → Axios base: uses · Admin requests run through the shared HTTP layer.
- Dashboard API → Axios base: uses · Dashboard queries use the shared HTTP layer.
- Axios base → Axios client: wraps · Axios configuration powers the custom base query.
- Redux store → Redux hooks: exports · Typed hooks are built around the shared store.
- Redux store → Auth API: registers · Auth API slice is part of the store.
- Redux store → Wallet API: registers · Wallet API slice is part of the store.
- Redux store → Profile API: registers · Profile API slice is part of the store.
- Redux store → Admin API: registers · Admin API slice is part of the store.
- Redux store → Dashboard API: registers · Dashboard API slice is part of the store.
- Public pages → UI primitives: uses · Public pages are composed from shared primitives.
- User dashboard → Form widgets: uses · User forms and upload flows rely on reusable widgets.
- Admin dashboard → Form widgets: uses · Admin forms and dialogs reuse shared widgets.
- Tour modules → UI primitives: uses · Tour management UI is built on the shared primitive library.