How jeeva-nandam/go-business-referral-dashboard-assessment works
Purpose and Runtime
This is a React 18 single-page referral-management dashboard built with Vite. It provides cookie-based authentication, protected navigation, referral discovery and detail views, and client-side pagination. It runs in the browser; deployment is hosted on Vercel per the README.
Application Bootstrap and Routing
src/main.jsx mounts the application, while src/App.jsx owns the BrowserRouter and route map. Routes include login, the protected dashboard and referral-detail views, plus a public catch-all Not Found page.
• src/main.jsx
• src/App.jsx
• src/pages/NotFound.jsx
Authentication Boundary
Authentication state is represented solely by the jwt_token cookie, managed with js-cookie. Login performs its API call locally and stores the returned JWT; authenticated visitors are redirected away from login. ProtectedRoute gates dashboard/detail routes and redirects missing-token requests to /login. Navbar logout clears the cookie.
• src/pages/Login.jsx
• src/components/ProtectedRoute.jsx
• src/components/Navbar.jsx
Dashboard Data Pipeline
The dashboard is the primary working surface: it fetches referrals using the bearer token, renders overview and service-summary content, exposes referral sharing UI, and renders the referral table. Search and sort changes issue fresh server requests; the API returns the complete matching/sorted result set.
• src/pages/Dashboard.jsx
• src/pages/Dashboard.css
Referral Table State and Pagination
Pagination is intentionally a browser-side concern. Dashboard.jsx receives all rows for the current search/sort request, resets to page one after new data arrives, and slices the in-memory results into pages of ten. Table row navigation leads into the detail route.
• src/pages/Dashboard.jsx
• src/pages/ReferralDetail.jsx
Referral Detail Retrieval
The detail page independently fetches a referral using ?id=<id> and the same JWT bearer boundary. It tolerates two backend response contracts: a direct referral object or an object containing a referrals array. API access and formatting logic are duplicated locally rather than shared through a service layer.
• src/pages/ReferralDetail.jsx
• src/pages/ReferralDetail.css
Shared Presentation Layer
Navbar and footer provide shared application chrome around routed content. Global visual tokens and baseline styles are centralized, while each page/component keeps its own plain CSS. There is no component library, server runtime, or shared API client in the repository.
• src/components/Navbar.jsx
• src/components/Footer.jsx
• src/index.css
Main entry points: App.jsx Router and route map · ProtectedRoute.jsx Protected route · Dashboard.jsx Dashboard · Login.jsx Login
Components 14
React SPA
Browser-rendered Vite application.
- App mount
src/main.jsx - Router and route map · Owns public and protected route composition.
src/App.jsx - Not Found
src/pages/NotFound.jsx - Navbar · Clears authentication on logout.
src/components/Navbar.jsx - Footer
src/components/Footer.jsx - Global styles
src/index.css
Authentication
- Login · Authenticates locally and redirects authenticated visitors.
src/pages/Login.jsx - Protected route · Redirects requests without a token to login.
src/components/ProtectedRoute.jsx - jwt_token cookie · Sole authentication state.
Referral workflow
- Dashboard · Fetches referral results and renders summaries, sharing UI, and table.
src/pages/Dashboard.jsx - Client pagination · Slices each fetched result set into pages of ten and resets after refresh.
src/pages/Dashboard.jsx - Referral detail · Independently fetches one referral and accepts two response contracts.
src/pages/ReferralDetail.jsx
External boundary
- Referral API · Receives bearer-authenticated login and referral requests.
- Vercel
Connections 19
- App mount → Router and route map: mounts
- Router and route map → Login: public route
- Router and route map → Protected route: protected routes
- Router and route map → Not Found: catch-all route
- Router and route map → Navbar: shared chrome
- Router and route map → Footer: shared chrome
- Router and route map → Global styles: applies
- Login → Referral API: login request
- Login → jwt_token cookie: stores JWT
- Protected route → jwt_token cookie: checks
- Protected route → Login: redirects if absent
- Protected route → Dashboard: permits
- Protected route → Referral detail: permits
- Navbar → jwt_token cookie: clears on logout
- Dashboard → Referral API: search/sort with bearer token
- Dashboard → Client pagination: stores full results
- Dashboard → Referral detail: row navigation
- Referral detail → Referral API: fetches by id with bearer token
- Vercel → App mount: hosts SPA