# irfanb22/bears-prediction-app architecture

> Architecture diagram of the GitHub repository irfanb22/bears-prediction-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/irfanb22/bears-prediction-app
- Repository: https://github.com/irfanb22/bears-prediction-app

## Overview

Bears Prediction Tracker lets fans authenticate, make and review Chicago Bears season predictions, and view community results. Its central workflow runs from the web app through prediction questions and user picks to Supabase-backed summaries; authentication gates personal activity. The product also includes an admin surface for email campaigns and lifecycle automations, with edge functions for dispatch, unsubscribe handling, and delivery events. The README is only a project name, and sampled source is partial, so uncertain UI-to-function wiring is omitted.

Main entry points: [`src/App.tsx`](https://github.com/irfanb22/bears-prediction-app/blob/main/src/App.tsx) (Application routes), [`src/lib/PredictionContext.tsx`](https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/PredictionContext.tsx) (Prediction state), [`src/lib/auth.tsx`](https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/auth.tsx) (Auth provider), [`supabase/functions/dispatch-campaign/index.ts`](https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/dispatch-campaign/index.ts) (Campaign dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["Application routes<br/>[App.tsx]"]
  node_authform["Sign-in and registration<br/>[AuthForm.tsx]"]
  node_authcallback["Auth callback<br/>[AuthCallback.tsx]"]
end

subgraph group_predictions["Prediction domain"]
  node_predictionui["Prediction interface"]
  node_dashboard["Fan dashboard<br/>[Dashboard.tsx]"]
  node_leaderboard["Leaderboard<br/>[Leaderboard.tsx]"]
  node_recap["Season recap<br/>[SeasonRecap.tsx]"]
  node_predictionstate["Prediction state"]
end

subgraph group_email["Email operations"]
  node_adminemail["Email admin"]
  node_composer["Email composer<br/>[emailComposer.ts]"]
  node_campaign["Campaign dispatch<br/>[index.ts]"]
  node_brevo["Email sending<br/>[index.ts]"]
  node_lifecycle["Lifecycle automation<br/>[index.ts]"]
  node_unsubscribe["Unsubscribe handler<br/>[index.ts]"]
  node_ses_events["Delivery events<br/>[index.ts]"]
end

subgraph group_services["Backend services"]
  node_auth["Auth provider<br/>[auth.tsx]"]
  node_supabaseclient["Supabase client<br/>[supabase.ts]"]
  node_ses["SES mailer<br/>[ses.ts]"]
  node_analytics["Analytics<br/>[analytics.ts]"]
end

node_fan(("Fan"))
node_admin(("Administrator"))
node_scheduler(("Scheduler"))
node_supabase[("Supabase")]
node_mailservice["Email service"]

node_fan -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"presents"| node_authform
node_app -->|"routes to"| node_authcallback
node_app -->|"routes to"| node_predictionui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_leaderboard
node_app -->|"routes to"| node_recap
node_authform -->|"invokes"| node_auth
node_authcallback -->|"uses"| node_auth
node_auth -->|"calls"| node_supabaseclient
node_supabaseclient -->|"connects"| node_supabase
node_predictionui -->|"uses"| node_predictionstate
node_dashboard -->|"uses"| node_predictionstate
node_leaderboard -->|"uses"| node_predictionstate
node_recap -->|"uses"| node_predictionstate
node_predictionstate -->|"reads user"| node_auth
node_predictionstate -->|"fetches and updates"| node_supabaseclient
node_adminemail -->|"edits content"| node_composer
node_scheduler -->|"triggers"| node_campaign
node_admin -->|"dispatches"| node_campaign
node_admin -->|"requests send"| node_brevo
node_scheduler -->|"triggers"| node_lifecycle
node_admin -->|"runs"| node_lifecycle
node_campaign -->|"reads and updates"| node_supabase
node_brevo -->|"reads recipients"| node_supabase
node_lifecycle -->|"claims and records"| node_supabase
node_campaign -->|"sends mail"| node_ses
node_lifecycle -->|"sends mail"| node_ses
node_ses -->|"delivers via"| node_mailservice
node_brevo -->|"sends via"| node_mailservice
node_mailservice -.->|"reports events"| node_ses_events
node_ses_events -->|"records events"| node_supabase
node_fan -->|"requests unsubscribe"| node_unsubscribe
node_unsubscribe -->|"updates preferences"| node_supabase
node_auth -->|"identifies user"| node_analytics

click node_app "https://github.com/irfanb22/bears-prediction-app/blob/main/src/App.tsx"
click node_authform "https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/AuthForm.tsx"
click node_authcallback "https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/AuthCallback.tsx"
click node_auth "https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/auth.tsx"
click node_predictionui "https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/PredictionInterface.tsx"
click node_dashboard "https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/Dashboard.tsx"
click node_leaderboard "https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/Leaderboard.tsx"
click node_recap "https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/SeasonRecap.tsx"
click node_predictionstate "https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/PredictionContext.tsx"
click node_supabaseclient "https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/supabase.ts"
click node_adminemail "https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/AdminEmailDashboard.tsx"
click node_composer "https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/emailComposer.ts"
click node_campaign "https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/dispatch-campaign/index.ts"
click node_brevo "https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/send-brevo-email/index.ts"
click node_lifecycle "https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/run-lifecycle/index.ts"
click node_unsubscribe "https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/unsubscribe-email/index.ts"
click node_ses "https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/_shared/ses.ts"
click node_ses_events "https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/ses-events/index.ts"
click node_analytics "https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/analytics.ts"

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_authform,node_authcallback toneBlue
class node_predictionui,node_dashboard,node_leaderboard,node_recap,node_predictionstate,node_supabase toneAmber
class node_adminemail,node_composer,node_campaign,node_brevo,node_lifecycle,node_unsubscribe,node_ses_events toneMint
class node_auth,node_supabaseclient,node_ses,node_analytics,node_scheduler toneRose
class node_fan,node_admin,node_mailservice toneIndigo
```

## Components

### Web experience

- [Application routes](https://github.com/irfanb22/bears-prediction-app/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in and registration](https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/AuthForm.tsx): `src/components/AuthForm.tsx`
- [Auth callback](https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/AuthCallback.tsx): `src/components/AuthCallback.tsx`

### Prediction domain

- [Prediction interface](https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/PredictionInterface.tsx): `src/components/PredictionInterface.tsx`
- [Fan dashboard](https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/Dashboard.tsx): `src/components/Dashboard.tsx`
- [Leaderboard](https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/Leaderboard.tsx): `src/components/Leaderboard.tsx`
- [Season recap](https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/SeasonRecap.tsx): `src/components/SeasonRecap.tsx`
- [Prediction state](https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/PredictionContext.tsx): `src/lib/PredictionContext.tsx`

### Email operations

- [Email admin](https://github.com/irfanb22/bears-prediction-app/blob/main/src/components/AdminEmailDashboard.tsx): `src/components/AdminEmailDashboard.tsx`
- [Email composer](https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/emailComposer.ts): `src/lib/emailComposer.ts`
- [Campaign dispatch](https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/dispatch-campaign/index.ts): `supabase/functions/dispatch-campaign/index.ts`
- [Email sending](https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/send-brevo-email/index.ts): `supabase/functions/send-brevo-email/index.ts`
- [Lifecycle automation](https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/run-lifecycle/index.ts): `supabase/functions/run-lifecycle/index.ts`
- [Unsubscribe handler](https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/unsubscribe-email/index.ts): `supabase/functions/unsubscribe-email/index.ts`
- [Delivery events](https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/ses-events/index.ts): `supabase/functions/ses-events/index.ts`

### Backend services

- [Auth provider](https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/auth.tsx): `src/lib/auth.tsx`
- [Supabase client](https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [SES mailer](https://github.com/irfanb22/bears-prediction-app/blob/main/supabase/functions/_shared/ses.ts): `supabase/functions/_shared/ses.ts`
- [Analytics](https://github.com/irfanb22/bears-prediction-app/blob/main/src/lib/analytics.ts): `src/lib/analytics.ts`

### Other components

- **Fan**
- **Administrator**
- **Scheduler**
- **Supabase**
- **Email service**

## Connections

- Fan → Application routes: uses
- Administrator → Application routes: uses
- Application routes → Sign-in and registration: presents
- Application routes → Auth callback: routes to
- Application routes → Prediction interface: routes to
- Application routes → Fan dashboard: routes to
- Application routes → Leaderboard: routes to
- Application routes → Season recap: routes to
- Sign-in and registration → Auth provider: invokes
- Auth callback → Auth provider: uses
- Auth provider → Supabase client: calls
- Supabase client → Supabase: connects
- Prediction interface → Prediction state: uses
- Fan dashboard → Prediction state: uses
- Leaderboard → Prediction state: uses
- Season recap → Prediction state: uses
- Prediction state → Auth provider: reads user
- Prediction state → Supabase client: fetches and updates
- Email admin → Email composer: edits content
- Scheduler → Campaign dispatch: triggers
- Administrator → Campaign dispatch: dispatches
- Administrator → Email sending: requests send
- Scheduler → Lifecycle automation: triggers
- Administrator → Lifecycle automation: runs
- Campaign dispatch → Supabase: reads and updates
- Email sending → Supabase: reads recipients
- Lifecycle automation → Supabase: claims and records
- Campaign dispatch → SES mailer: sends mail
- Lifecycle automation → SES mailer: sends mail
- SES mailer → Email service: delivers via
- Email sending → Email service: sends via
- Email service → Delivery events: reports events
- Delivery events → Supabase: records events
- Fan → Unsubscribe handler: requests unsubscribe
- Unsubscribe handler → Supabase: updates preferences
- Auth provider → Analytics: identifies user
