# jeeva-nandam/go-business-referral-dashboard-assessment architecture

> Architecture diagram of the GitHub repository jeeva-nandam/go-business-referral-dashboard-assessment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeeva-nandam/go-business-referral-dashboard-assessment
- Repository: https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment

## Overview

#### 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: [`src/App.jsx`](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/App.jsx) (Router and route map), [`src/components/ProtectedRoute.jsx`](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/components/ProtectedRoute.jsx) (Protected route), [`src/pages/Dashboard.jsx`](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Dashboard.jsx) (Dashboard), [`src/pages/Login.jsx`](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Login.jsx) (Login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_main["App mount<br/>React bootstrap<br/>[main.jsx]"]
  node_router["Router and route map<br/>React routes<br/>[App.jsx]"]
  node_not_found["Not Found<br/>public page<br/>[NotFound.jsx]"]
  node_navbar["Navbar<br/>shared chrome<br/>[Navbar.jsx]"]
  node_footer["Footer<br/>shared chrome<br/>[Footer.jsx]"]
  node_global_styles["Global styles<br/>CSS foundation<br/>[index.css]"]
end

subgraph group_auth["Authentication"]
  node_login["Login<br/>public page<br/>[Login.jsx]"]
  node_protected_route{{"Protected route<br/>route guard<br/>[ProtectedRoute.jsx]"}}
  node_jwt_cookie[("jwt_token cookie<br/>browser auth state")]
end

subgraph group_referrals["Referral workflow"]
  node_dashboard["Dashboard<br/>protected page<br/>[Dashboard.jsx]"]
  node_pagination["Client pagination<br/>in-memory state<br/>[Dashboard.jsx]"]
  node_referral_detail["Referral detail<br/>protected page<br/>[ReferralDetail.jsx]"]
end

subgraph group_external["External boundary"]
  node_referral_api{{"Referral API<br/>backend API"}}
  node_vercel{{"Vercel<br/>static hosting"}}
end

node_main -->|"mounts"| node_router
node_router -->|"public route"| node_login
node_router -->|"protected routes"| node_protected_route
node_router -->|"catch-all route"| node_not_found
node_router -->|"shared chrome"| node_navbar
node_router -->|"shared chrome"| node_footer
node_router -->|"applies"| node_global_styles
node_login -->|"login request"| node_referral_api
node_login -->|"stores JWT"| node_jwt_cookie
node_protected_route -->|"checks"| node_jwt_cookie
node_protected_route -.->|"redirects if absent"| node_login
node_protected_route -->|"permits"| node_dashboard
node_protected_route -->|"permits"| node_referral_detail
node_navbar -->|"clears on logout"| node_jwt_cookie
node_dashboard -->|"search/sort with bearer token"| node_referral_api
node_dashboard -->|"stores full results"| node_pagination
node_dashboard -->|"row navigation"| node_referral_detail
node_referral_detail -->|"fetches by id with bearer token"| node_referral_api
node_vercel -.->|"hosts SPA"| node_main

click node_main "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/main.jsx"
click node_router "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/App.jsx"
click node_not_found "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/NotFound.jsx"
click node_navbar "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/components/Navbar.jsx"
click node_footer "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/components/Footer.jsx"
click node_global_styles "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/index.css"
click node_login "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Login.jsx"
click node_protected_route "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/components/ProtectedRoute.jsx"
click node_dashboard "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Dashboard.jsx"
click node_pagination "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Dashboard.jsx"
click node_referral_detail "https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/ReferralDetail.jsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_router,node_not_found,node_navbar,node_footer,node_global_styles toneBlue
class node_login,node_protected_route,node_jwt_cookie toneAmber
class node_dashboard,node_pagination,node_referral_detail toneMint
class node_referral_api,node_vercel toneRose
```

## Components

### React SPA

Browser-rendered Vite application.

- [App mount](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/main.jsx): React bootstrap · `src/main.jsx`
- [Router and route map](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/App.jsx): React routes · Owns public and protected route composition. · `src/App.jsx`
- [Not Found](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/NotFound.jsx): public page · `src/pages/NotFound.jsx`
- [Navbar](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/components/Navbar.jsx): shared chrome · Clears authentication on logout. · `src/components/Navbar.jsx`
- [Footer](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/components/Footer.jsx): shared chrome · `src/components/Footer.jsx`
- [Global styles](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/index.css): CSS foundation · `src/index.css`

### Authentication

- [Login](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Login.jsx): public page · Authenticates locally and redirects authenticated visitors. · `src/pages/Login.jsx`
- [Protected route](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/components/ProtectedRoute.jsx): route guard · Redirects requests without a token to login. · `src/components/ProtectedRoute.jsx`
- **jwt_token cookie**: browser auth state · Sole authentication state.

### Referral workflow

- [Dashboard](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Dashboard.jsx): protected page · Fetches referral results and renders summaries, sharing UI, and table. · `src/pages/Dashboard.jsx`
- [Client pagination](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/Dashboard.jsx): in-memory state · Slices each fetched result set into pages of ten and resets after refresh. · `src/pages/Dashboard.jsx`
- [Referral detail](https://github.com/jeeva-nandam/go-business-referral-dashboard-assessment/blob/main/src/pages/ReferralDetail.jsx): protected page · Independently fetches one referral and accepts two response contracts. · `src/pages/ReferralDetail.jsx`

### External boundary

- **Referral API**: backend API · Receives bearer-authenticated login and referral requests.
- **Vercel**: static hosting

## Connections

- 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
