# hari-x-haran/affiliate-marketing architecture

> Architecture diagram of the GitHub repository hari-x-haran/affiliate-marketing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hari-x-haran/affiliate-marketing
- Repository: https://github.com/hari-x-haran/affiliate-marketing

## Overview

AffiliateX is a browser-based affiliate-link manager. Users register or sign in, create Amazon or Flipkart short links, then manage links and inspect click, analytics, and estimated-earnings views. React context holds authentication and link state; browser storage persists it, with synchronization to a backend endpoint. The route shell also exposes profile and database-management screens. Evidence is based on the provided excerpts and source index; several page implementations and route details were not sampled.

Main entry points: [`src/App.jsx`](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/App.jsx) (Route shell), [`src/context/LinkContext.jsx`](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/context/LinkContext.jsx) (Link context), [`src/context/AuthContext.jsx`](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/context/AuthContext.jsx) (Auth context), [`src/pages/Dashboard.jsx`](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Dashboard.jsx) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routing["Application shell"]
  node_app["Route shell<br/>[App.jsx]"]
  node_navbar["Navigation bar<br/>[Navbar.jsx]"]
  node_sidebar["Sidebar<br/>[Sidebar.jsx]"]
end

subgraph group_account["Account access"]
  node_login["Sign in<br/>[Login.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_auth["Auth context<br/>[AuthContext.jsx]"]
  node_profile["Profile<br/>[Profile.jsx]"]
  node_protected["Route guard<br/>[ProtectedRoute.jsx]"]
end

subgraph group_links["Link management"]
  node_create["Create link<br/>[CreateLink.jsx]"]
  node_linksctx["Link context<br/>[LinkContext.jsx]"]
  node_shortid["Short ID generator<br/>[generateShortId.js]"]
  node_validators["URL validation<br/>[validators.js]"]
  node_mylinks["My links<br/>[MyLinks.jsx]"]
  node_linkcard["Link card<br/>[LinkCard.jsx]"]
  node_copy["Copy button<br/>[CopyButton.jsx]"]
end

subgraph group_insights["Performance insights"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_analytics["Analytics<br/>[Analytics.jsx]"]
  node_earnings["Earnings<br/>[Earnings.jsx]"]
  node_statcard["Metric card<br/>[StatCard.jsx]"]
end

subgraph group_persistence["Persistence"]
  node_databasepage["Database editor<br/>[Database.jsx]"]
  node_storage[("Browser storage<br/>[storage.js]")]
end

node_user(("Browser user"))
node_backend["Sync endpoint"]

node_user -->|"uses"| node_app
node_app -->|"provides context"| node_auth
node_app -->|"provides context"| node_linksctx
node_app -->|"guards routes"| node_protected
node_app -->|"renders"| node_navbar
node_app -->|"renders"| node_sidebar
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_create
node_app -->|"routes to"| node_mylinks
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_earnings
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_databasepage
node_login -->|"authenticates"| node_auth
node_register -->|"registers through"| node_auth
node_navbar -->|"logs out through"| node_auth
node_profile -->|"reads account"| node_auth
node_profile -->|"reads links"| node_linksctx
node_auth -->|"reads and writes"| node_storage
node_create -->|"validates URL"| node_validators
node_create -->|"creates link"| node_linksctx
node_create -->|"renders"| node_copy
node_linksctx -->|"reads user"| node_auth
node_linksctx -->|"generates ID"| node_shortid
node_linksctx -->|"reads and writes"| node_storage
node_mylinks -->|"reads links"| node_linksctx
node_mylinks -->|"renders"| node_linkcard
node_linkcard -->|"records clicks"| node_linksctx
node_linkcard -->|"renders"| node_copy
node_dashboard -->|"reads user"| node_auth
node_dashboard -->|"reads and deletes"| node_linksctx
node_dashboard -->|"renders"| node_statcard
node_dashboard -->|"renders"| node_linkcard
node_analytics -->|"reads links"| node_linksctx
node_analytics -->|"renders"| node_statcard
node_earnings -->|"reads clicks"| node_linksctx
node_earnings -->|"renders"| node_statcard
node_databasepage -->|"reads and writes"| node_storage
node_storage -->|"syncs data"| node_backend
node_app -->|"loads database"| node_backend

click node_app "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/App.jsx"
click node_navbar "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/Navbar.jsx"
click node_sidebar "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/Sidebar.jsx"
click node_login "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Login.jsx"
click node_register "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Register.jsx"
click node_auth "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/context/AuthContext.jsx"
click node_profile "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Profile.jsx"
click node_protected "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/ProtectedRoute.jsx"
click node_create "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/CreateLink.jsx"
click node_linksctx "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/context/LinkContext.jsx"
click node_shortid "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/utils/generateShortId.js"
click node_validators "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/utils/validators.js"
click node_mylinks "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/MyLinks.jsx"
click node_linkcard "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/LinkCard.jsx"
click node_copy "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/CopyButton.jsx"
click node_dashboard "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Dashboard.jsx"
click node_analytics "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Analytics.jsx"
click node_earnings "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Earnings.jsx"
click node_statcard "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/StatCard.jsx"
click node_databasepage "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Database.jsx"
click node_storage "https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/utils/storage.js"

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_app,node_navbar,node_sidebar,node_user toneBlue
class node_login,node_register,node_auth,node_profile,node_protected toneAmber
class node_create,node_linksctx,node_shortid,node_validators,node_mylinks,node_linkcard,node_copy toneMint
class node_dashboard,node_analytics,node_earnings,node_statcard toneRose
class node_databasepage,node_storage,node_backend toneIndigo
```

## Components

### Application shell

- [Route shell](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/App.jsx): `src/App.jsx`
- [Navigation bar](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/Navbar.jsx): `src/components/Navbar.jsx`
- [Sidebar](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/Sidebar.jsx): `src/components/Sidebar.jsx`

### Account access

- [Sign in](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Login.jsx): `src/pages/Login.jsx`
- [Registration](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Register.jsx): `src/pages/Register.jsx`
- [Auth context](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Profile](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Profile.jsx): `src/pages/Profile.jsx`
- [Route guard](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/ProtectedRoute.jsx): `src/components/ProtectedRoute.jsx`

### Link management

- [Create link](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/CreateLink.jsx): `src/pages/CreateLink.jsx`
- [Link context](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/context/LinkContext.jsx): `src/context/LinkContext.jsx`
- [Short ID generator](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/utils/generateShortId.js): `src/utils/generateShortId.js`
- [URL validation](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/utils/validators.js): `src/utils/validators.js`
- [My links](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/MyLinks.jsx): `src/pages/MyLinks.jsx`
- [Link card](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/LinkCard.jsx): `src/components/LinkCard.jsx`
- [Copy button](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/CopyButton.jsx): `src/components/CopyButton.jsx`

### Performance insights

- [Dashboard](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Dashboard.jsx): `src/pages/Dashboard.jsx`
- [Analytics](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Analytics.jsx): `src/pages/Analytics.jsx`
- [Earnings](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Earnings.jsx): `src/pages/Earnings.jsx`
- [Metric card](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/components/StatCard.jsx): `src/components/StatCard.jsx`

### Persistence

- [Database editor](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/pages/Database.jsx): `src/pages/Database.jsx`
- [Browser storage](https://github.com/hari-x-haran/affiliate-marketing/blob/main/src/utils/storage.js): `src/utils/storage.js`

### Other components

- **Browser user**
- **Sync endpoint**

## Connections

- Browser user → Route shell: uses
- Route shell → Auth context: provides context (evidence: `src/App.jsx`)
- Route shell → Link context: provides context (evidence: `src/App.jsx`)
- Route shell → Route guard: guards routes (evidence: `src/App.jsx`)
- Route shell → Navigation bar: renders (evidence: `src/App.jsx`)
- Route shell → Sidebar: renders (evidence: `src/App.jsx`)
- Route shell → Sign in: routes to (evidence: `src/App.jsx`)
- Route shell → Registration: routes to (evidence: `src/App.jsx`)
- Route shell → Dashboard: routes to (evidence: `src/App.jsx`)
- Route shell → Create link: routes to (evidence: `src/App.jsx`)
- Route shell → My links: routes to (evidence: `src/App.jsx`)
- Route shell → Analytics: routes to (evidence: `src/App.jsx`)
- Route shell → Earnings: routes to (evidence: `src/App.jsx`)
- Route shell → Profile: routes to (evidence: `src/App.jsx`)
- Route shell → Database editor: routes to (evidence: `src/App.jsx`)
- Sign in → Auth context: authenticates (evidence: `src/pages/Login.jsx`)
- Registration → Auth context: registers through (evidence: `src/pages/Register.jsx`)
- Navigation bar → Auth context: logs out through (evidence: `src/components/Navbar.jsx`)
- Profile → Auth context: reads account (evidence: `src/pages/Profile.jsx`)
- Profile → Link context: reads links (evidence: `src/pages/Profile.jsx`)
- Auth context → Browser storage: reads and writes (evidence: `src/context/AuthContext.jsx`)
- Create link → URL validation: validates URL (evidence: `src/pages/CreateLink.jsx`)
- Create link → Link context: creates link (evidence: `src/pages/CreateLink.jsx`)
- Create link → Copy button: renders (evidence: `src/pages/CreateLink.jsx`)
- Link context → Auth context: reads user (evidence: `src/context/LinkContext.jsx`)
- Link context → Short ID generator: generates ID (evidence: `src/context/LinkContext.jsx`)
- Link context → Browser storage: reads and writes (evidence: `src/context/LinkContext.jsx`)
- My links → Link context: reads links (evidence: `src/pages/MyLinks.jsx`)
- My links → Link card: renders (evidence: `src/pages/MyLinks.jsx`)
- Link card → Link context: records clicks (evidence: `src/components/LinkCard.jsx`)
- Link card → Copy button: renders (evidence: `src/components/LinkCard.jsx`)
- Dashboard → Auth context: reads user (evidence: `src/pages/Dashboard.jsx`)
- Dashboard → Link context: reads and deletes (evidence: `src/pages/Dashboard.jsx`)
- Dashboard → Metric card: renders (evidence: `src/pages/Dashboard.jsx`)
- Dashboard → Link card: renders (evidence: `src/pages/Dashboard.jsx`)
- Analytics → Link context: reads links (evidence: `src/pages/Analytics.jsx`)
- Analytics → Metric card: renders (evidence: `src/pages/Analytics.jsx`)
- Earnings → Link context: reads clicks (evidence: `src/pages/Earnings.jsx`)
- Earnings → Metric card: renders (evidence: `src/pages/Earnings.jsx`)
- Database editor → Browser storage: reads and writes (evidence: `src/pages/Database.jsx`)
- Browser storage → Sync endpoint: syncs data (evidence: `src/utils/storage.js`)
- Route shell → Sync endpoint: loads database (evidence: `src/App.jsx`)
