# cbrennan18/fpl-pulse architecture

> Architecture diagram of the GitHub repository cbrennan18/fpl-pulse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cbrennan18/fpl-pulse
- Repository: https://github.com/cbrennan18/fpl-pulse

## Overview

#### Purpose and Entry Points
FPL Pulse is a client-side React application that turns Fantasy Premier League data into league dashboards, awards, and a season “Wrapped” recap. Vite boots the app from `index.html` through `src/main.jsx`; `src/App.jsx` selects the top-level experience. Shared shell/navigation is centered on `src/components/BaseLayout.jsx` and `src/components/TopBar.jsx`.

#### Application Surfaces
The product has three principal UI flows:
- Landing/onboarding: `src/features/landing/Landing.jsx`.
- Home and league browsing: `src/features/home/HomepageContainer.jsx`, `src/features/league/LeagueListContainer.jsx`, and `src/features/league/LeagueViewContainer.jsx`.
- Pulse Wrapped season recap: `src/features/pulse/wrapped/WrappedContainer.jsx` and `src/features/pulse/wrapped/WrappedScreen.jsx`.

Container components are likely the boundary between data acquisition/state assembly and presentational views; corresponding `Homepage.jsx`, `LeagueList.jsx`, and `LeagueView.jsx` render the assembled models.

#### Data Access and Domain Transformation
The frontend’s API boundary is `src/utils/api.js`, with shared domain constants in `src/utils/constants.js`. League data is normalized for UI and calculations in `src/features/league/transformBlobData.js`; league behavior/configuration is centralized in `src/features/league/leagueConfig.js`.

This establishes a flow of external FPL-oriented source data → API utility → feature-level transformation/configuration → containers → visual components. No backend service or server runtime is present in the repository.

#### League Analytics and Awards
League views combine standings, stat summaries, medals, rankings, and award outputs through `src/features/league/LeagueView.jsx`, `src/features/league/MedalTable.jsx`, and `src/features/league/FullRankingSheet.jsx`. Award rules are discrete calculation modules coordinated by `src/features/league/awards/index.js`, including scoring, transfer, chip, and bi-monthly categories.

Awards can be rendered as exportable graphics using the isolated sharing pipeline in `src/features/league/awards-share/GwAwardsPreview.jsx`, `src/features/league/awards-share/HiddenStage.jsx`, and `src/features/league/awards-share/exportImage.js`. This separates on-screen award presentation from offscreen image capture/export.

#### Wrapped Recap Pipeline
Wrapped has an explicit front door, loading state, recap, and share path: `src/features/pulse/wrapped/frontdoor/Cover.jsx`, `src/features/pulse/wrapped/loading/BuildingSeason.jsx`, `src/features/pulse/wrapped/recap/RecapCarousel.jsx`, and `src/features/pulse/wrapped/share/WrappedHiddenStage.jsx`.

`src/features/pulse/wrapped/PackContext.js` and `src/features/pulse/wrapped/usePack.js` provide the shared season/league data pack to the experience. User flow is selection of league/roster, pack construction, sequential beat navigation, then optional card generation and sharing.

#### Recap Computation and Story Rendering
Pure analytics are organized by recap topic under `src/features/pulse/wrapped/calc/`, such as `captain.js`, `luckVsSkill.js`, and `leagueLegacy.js`. Their outputs drive corresponding visual “beats” in `src/features/pulse/wrapped/beat/`, including `CaptainBeat.jsx`, `LuckSkillBeat.jsx`, and `LegacyPositionChart.jsx`.

`src/features/pulse/wrapped/beat/useBeatNavigation.js` controls progression between beats. The architecture separates deterministic metric computation from animated narrative presentation, making calculations independently testable and reusable by recap and share cards.

#### Share Cards and Runtime Infrastructure
Wrapped sharing maps beats to purpose-built card renderers through `src/features/pulse/wrapped/share/beatCardRegistry.js`; representative cards live in `src/features/pulse/wrapped/share/cards/B2CaptainCard.jsx` and `src/features/pulse/wrapped/share/cards/B10RaceCard.jsx`. `useShareCard.js` coordinates card selection/export behavior.

The app runs as a static Vite build using React 19, Tailwind CSS, Chart.js/react-chartjs-2, and Framer Motion. Deployment is GitHub Pages-oriented, with the static fallback at `public/404.html`. A generated rating lookup artifact, `src/features/pulse/utils/ae64-field-v1.json`, is built by `scripts/build-ae64-field.mjs`.

Main entry points: [`src/App.jsx`](https://github.com/cbrennan18/fpl-pulse/blob/main/src/App.jsx) (App router), [`src/features/league/LeagueViewContainer.jsx`](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueViewContainer.jsx) (League view container), [`src/features/league/LeagueView.jsx`](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueView.jsx) (League dashboard), [`src/utils/api.js`](https://github.com/cbrennan18/fpl-pulse/blob/main/src/utils/api.js) (FPL API boundary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_vite["Vite entry<br/>build entry<br/>[index.html]"]
  node_main["React mount<br/>client entry<br/>[main.jsx]"]
  node_app_root["App router<br/>top-level UI<br/>[App.jsx]"]
  node_shell["Shared layout<br/>navigation shell<br/>[BaseLayout.jsx]"]
  node_api{{"FPL API boundary<br/>API client<br/>[api.js]"}}
  node_landing["Landing<br/>onboarding UI<br/>[Landing.jsx]"]
end

subgraph group_league["League dashboards"]
  node_home["Home container<br/>data container"]
  node_league_list["League list container<br/>data container"]
  node_league_view_container["League view container<br/>data container"]
  node_league_transform{{"League normalization<br/>domain transform"}}
  node_league_config["League configuration<br/>domain config<br/>[leagueConfig.js]"]
  node_league_view["League dashboard<br/>presentational view<br/>[LeagueView.jsx]"]
  node_awards{{"Award calculations<br/>analytics rules<br/>[index.js]"}}
  node_ranking["Rankings and medals<br/>analytics UI"]
  node_award_export["Award image export<br/>sharing pipeline<br/>[exportImage.js]"]
end

subgraph group_wrapped["Pulse Wrapped"]
  node_wrapped_container["Wrapped front door<br/>experience container"]
  node_pack["Season data pack<br/>shared state<br/>[PackContext.js]"]
  node_wrapped_screen["Wrapped screen<br/>recap UI<br/>[WrappedScreen.jsx]"]
  node_recap["Recap carousel<br/>narrative UI<br/>[RecapCarousel.jsx]"]
  node_beat_navigation["Beat navigation<br/>interaction state"]
  node_recap_calc{{"Recap calculations<br/>pure analytics<br/>[captain.js]"}}
  node_share_registry["Share card registry<br/>card mapping"]
  node_share_export["Wrapped share stage<br/>sharing pipeline"]
  node_rating_artifact["Rating lookup<br/>generated data<br/>[ae64-field-v1.json]"]
end

node_vite -->|"loads"| node_main
node_main -->|"mounts"| node_app_root
node_app_root -->|"uses"| node_shell
node_app_root -->|"routes to"| node_landing
node_app_root -->|"routes to"| node_home
node_app_root -->|"routes to"| node_league_list
node_app_root -->|"routes to"| node_league_view_container
node_app_root -->|"routes to"| node_wrapped_container
node_api -->|"supplies data"| node_home
node_api -->|"supplies data"| node_league_list
node_api -->|"supplies data"| node_league_view_container
node_league_view_container -->|"normalizes with"| node_league_transform
node_league_config -->|"configures"| node_league_view_container
node_league_transform -->|"builds model for"| node_league_view
node_league_view_container -->|"renders"| node_league_view
node_awards -->|"provides awards"| node_league_view
node_ranking -->|"provides rankings"| node_league_view
node_league_view -.->|"exports awards"| node_award_export
node_api -->|"supplies source data"| node_wrapped_container
node_wrapped_container -->|"constructs"| node_pack
node_pack -->|"provides"| node_wrapped_screen
node_wrapped_screen -->|"shows"| node_recap
node_recap_calc -->|"drives beats"| node_recap
node_rating_artifact -->|"enriches metrics"| node_recap_calc
node_beat_navigation -->|"advances"| node_recap
node_recap -->|"selects beat card"| node_share_registry
node_recap_calc -.->|"reuses metrics"| node_share_registry
node_share_registry -->|"renders selected card"| node_share_export

click node_vite "https://github.com/cbrennan18/fpl-pulse/blob/main/index.html"
click node_main "https://github.com/cbrennan18/fpl-pulse/blob/main/src/main.jsx"
click node_app_root "https://github.com/cbrennan18/fpl-pulse/blob/main/src/App.jsx"
click node_shell "https://github.com/cbrennan18/fpl-pulse/blob/main/src/components/BaseLayout.jsx"
click node_api "https://github.com/cbrennan18/fpl-pulse/blob/main/src/utils/api.js"
click node_landing "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/landing/Landing.jsx"
click node_home "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/home/HomepageContainer.jsx"
click node_league_list "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueListContainer.jsx"
click node_league_view_container "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueViewContainer.jsx"
click node_league_transform "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/transformBlobData.js"
click node_league_config "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/leagueConfig.js"
click node_league_view "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueView.jsx"
click node_awards "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/awards/index.js"
click node_ranking "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/FullRankingSheet.jsx"
click node_award_export "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/awards-share/exportImage.js"
click node_wrapped_container "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/WrappedContainer.jsx"
click node_pack "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/PackContext.js"
click node_wrapped_screen "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/WrappedScreen.jsx"
click node_recap "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/recap/RecapCarousel.jsx"
click node_beat_navigation "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/beat/useBeatNavigation.js"
click node_recap_calc "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/calc/captain.js"
click node_share_registry "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/share/beatCardRegistry.js"
click node_share_export "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/share/WrappedHiddenStage.jsx"
click node_rating_artifact "https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/utils/ae64-field-v1.json"

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_vite,node_main,node_app_root,node_shell,node_api,node_landing toneBlue
class node_home,node_league_list,node_league_view_container,node_league_transform,node_league_config,node_league_view,node_awards,node_ranking,node_award_export toneAmber
class node_wrapped_container,node_pack,node_wrapped_screen,node_recap,node_beat_navigation,node_recap_calc,node_share_registry,node_share_export,node_rating_artifact toneMint
```

## Components

### App shell

- [Vite entry](https://github.com/cbrennan18/fpl-pulse/blob/main/index.html): build entry · Bootstraps the static React application. · `index.html`
- [React mount](https://github.com/cbrennan18/fpl-pulse/blob/main/src/main.jsx): client entry · `src/main.jsx`
- [App router](https://github.com/cbrennan18/fpl-pulse/blob/main/src/App.jsx): top-level UI · Selects the active product experience. · `src/App.jsx`
- [Shared layout](https://github.com/cbrennan18/fpl-pulse/blob/main/src/components/BaseLayout.jsx): navigation shell · `src/components/BaseLayout.jsx`
- [FPL API boundary](https://github.com/cbrennan18/fpl-pulse/blob/main/src/utils/api.js): API client · Fetches external FPL-oriented source data. · `src/utils/api.js`
- [Landing](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/landing/Landing.jsx): onboarding UI · `src/features/landing/Landing.jsx`

### League dashboards

- [Home container](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/home/HomepageContainer.jsx): data container · `src/features/home/HomepageContainer.jsx`
- [League list container](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueListContainer.jsx): data container · `src/features/league/LeagueListContainer.jsx`
- [League view container](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueViewContainer.jsx): data container · Assembles league data and view models. · `src/features/league/LeagueViewContainer.jsx`
- [League normalization](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/transformBlobData.js): domain transform · `src/features/league/transformBlobData.js`
- [League configuration](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/leagueConfig.js): domain config · `src/features/league/leagueConfig.js`
- [League dashboard](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/LeagueView.jsx): presentational view · Combines standings, statistics, medals, and rankings. · `src/features/league/LeagueView.jsx`
- [Award calculations](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/awards/index.js): analytics rules · Coordinates scoring, transfer, chip, and bi-monthly awards. · `src/features/league/awards/index.js`
- [Rankings and medals](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/FullRankingSheet.jsx): analytics UI · `src/features/league/FullRankingSheet.jsx`
- [Award image export](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/league/awards-share/exportImage.js): sharing pipeline · Captures offscreen award graphics for export. · `src/features/league/awards-share/exportImage.js`

### Pulse Wrapped

- [Wrapped front door](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/WrappedContainer.jsx): experience container · Starts league or roster selection and recap loading. · `src/features/pulse/wrapped/WrappedContainer.jsx`
- [Season data pack](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/PackContext.js): shared state · Provides constructed season and league data to Wrapped. · `src/features/pulse/wrapped/PackContext.js`
- [Wrapped screen](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/WrappedScreen.jsx): recap UI · Hosts loading, recap, and sharing states. · `src/features/pulse/wrapped/WrappedScreen.jsx`
- [Recap carousel](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/recap/RecapCarousel.jsx): narrative UI · Presents sequential seasonal story beats. · `src/features/pulse/wrapped/recap/RecapCarousel.jsx`
- [Beat navigation](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/beat/useBeatNavigation.js): interaction state · `src/features/pulse/wrapped/beat/useBeatNavigation.js`
- [Recap calculations](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/calc/captain.js): pure analytics · Topic-based deterministic metrics drive recap and cards. · `src/features/pulse/wrapped/calc/captain.js`
- [Share card registry](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/share/beatCardRegistry.js): card mapping · Maps recap beats to specialized share cards. · `src/features/pulse/wrapped/share/beatCardRegistry.js`
- [Wrapped share stage](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/wrapped/share/WrappedHiddenStage.jsx): sharing pipeline · Renders cards offscreen for generation and sharing. · `src/features/pulse/wrapped/share/WrappedHiddenStage.jsx`
- [Rating lookup](https://github.com/cbrennan18/fpl-pulse/blob/main/src/features/pulse/utils/ae64-field-v1.json): generated data · Generated by the AE64 field build script. · `src/features/pulse/utils/ae64-field-v1.json`

## Connections

- Vite entry → React mount: loads
- React mount → App router: mounts
- App router → Shared layout: uses
- App router → Landing: routes to
- App router → Home container: routes to
- App router → League list container: routes to
- App router → League view container: routes to
- App router → Wrapped front door: routes to
- FPL API boundary → Home container: supplies data
- FPL API boundary → League list container: supplies data
- FPL API boundary → League view container: supplies data
- League view container → League normalization: normalizes with
- League configuration → League view container: configures
- League normalization → League dashboard: builds model for
- League view container → League dashboard: renders
- Award calculations → League dashboard: provides awards
- Rankings and medals → League dashboard: provides rankings
- League dashboard → Award image export: exports awards
- FPL API boundary → Wrapped front door: supplies source data
- Wrapped front door → Season data pack: constructs
- Season data pack → Wrapped screen: provides
- Wrapped screen → Recap carousel: shows
- Recap calculations → Recap carousel: drives beats
- Rating lookup → Recap calculations: enriches metrics
- Beat navigation → Recap carousel: advances
- Recap carousel → Share card registry: selects beat card
- Recap calculations → Share card registry: reuses metrics
- Share card registry → Wrapped share stage: renders selected card
