# andliu7/blueberry architecture

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

- Interactive diagram: https://gitdiagram.com/andliu7/blueberry
- Repository: https://github.com/andliu7/blueberry

## Overview

Blueberry is a chemistry-learning web app: students choose a study deck or enter the interactive game, work through questions or lessons, and retain progress. Its runtime spans the original deck-study experience and a broader chemistry game with lesson beats, reaction authoring, and feedback. The README documents deck capabilities; source evidence is limited to the excerpts and SOURCE INDEX, so links for unsampled areas are omitted rather than inferred.

Main entry points: [`src/game/App.tsx`](https://github.com/andliu7/blueberry/blob/main/src/game/App.tsx) (Game router), [`src/components/review/DeckPage.tsx`](https://github.com/andliu7/blueberry/blob/main/src/components/review/DeckPage.tsx) (Deck study), [`packages/interaction/src/shapes/mechanism.ts`](https://github.com/andliu7/blueberry/blob/main/packages/interaction/src/shapes/mechanism.ts) (Mechanism interaction), [`src/App.tsx`](https://github.com/andliu7/blueberry/blob/main/src/App.tsx) (Site router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_study["Deck study"]
  node_site["Site router<br/>[App.tsx]"]
  node_hub["Deck hub<br/>[HomePage.tsx]"]
  node_deckdata["Deck content<br/>[index.ts]"]
  node_deckview["Deck study<br/>[DeckPage.tsx]"]
end

subgraph group_game["Interactive game"]
  node_gameapp["Game router<br/>[App.tsx]"]
  node_gameshell["Game shell<br/>[Shell.tsx]"]
  node_gamehooks["Game hooks<br/>[hooks.ts]"]
  node_beats["Lesson beats<br/>[BeatRunner.tsx]"]
  node_admin["Admin viewer<br/>[AdminViewer.tsx]"]
end

subgraph group_chem["Chemistry engine"]
  node_reactiondata["Reaction catalog<br/>[reactions.ts]"]
  node_curriculum["Reaction curriculum<br/>[reaction.ts]"]
  node_placement["Lesson placement<br/>[placement.ts]"]
  node_chemcore["Chemistry core<br/>[routes.ts]"]
  node_interaction["Mechanism interaction<br/>[mechanism.ts]"]
  node_arrowinference["Arrow inference<br/>[arrowInference.ts]"]
  node_notices["Interaction notices<br/>[notices.ts]"]
end

subgraph group_identity["Accounts and state"]
  node_deckprogress["Saved progress<br/>[progress.ts]"]
  node_browserstore[("Browser storage")]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_session["Session provider<br/>[useSession.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
end

node_student(("Student"))

node_student -->|"opens"| node_site
node_site -->|"routes to"| node_hub
node_student -->|"chooses deck"| node_hub
node_hub -->|"opens deck"| node_deckview
node_site -->|"routes to"| node_deckview
node_deckview -->|"shows questions"| node_deckdata
node_deckview -->|"saves ratings"| node_deckprogress
node_deckprogress -->|"persists"| node_browserstore
node_student -.->|"enters game"| node_gameapp
node_gameapp -->|"renders shell"| node_gameshell
node_gameapp -->|"renders lesson"| node_beats
node_gameapp -->|"renders admin"| node_admin
node_gamehooks -->|"uses progress"| node_deckprogress
node_curriculum -->|"uses placement"| node_placement
node_curriculum -.->|"searches reactions"| node_reactiondata
node_interaction -->|"uses chemistry"| node_chemcore
node_interaction -->|"delegates inference"| node_arrowinference
node_arrowinference -->|"resolves targets"| node_chemcore
node_interaction -->|"emits notices"| node_notices
node_session -->|"reads identity"| node_auth
node_session -->|"checks configuration"| node_supabase
node_auth -->|"uses client"| node_supabase

click node_site "https://github.com/andliu7/blueberry/blob/main/src/App.tsx"
click node_hub "https://github.com/andliu7/blueberry/blob/main/src/components/HomePage.tsx"
click node_deckdata "https://github.com/andliu7/blueberry/blob/main/src/data/decks/index.ts"
click node_deckview "https://github.com/andliu7/blueberry/blob/main/src/components/review/DeckPage.tsx"
click node_deckprogress "https://github.com/andliu7/blueberry/blob/main/src/game/app/progress.ts"
click node_gameapp "https://github.com/andliu7/blueberry/blob/main/src/game/App.tsx"
click node_gameshell "https://github.com/andliu7/blueberry/blob/main/src/game/app/Shell.tsx"
click node_gamehooks "https://github.com/andliu7/blueberry/blob/main/src/game/app/hooks.ts"
click node_beats "https://github.com/andliu7/blueberry/blob/main/src/game/beats/BeatRunner.tsx"
click node_admin "https://github.com/andliu7/blueberry/blob/main/src/game/admin/AdminViewer.tsx"
click node_reactiondata "https://github.com/andliu7/blueberry/blob/main/src/data/reactions.ts"
click node_curriculum "https://github.com/andliu7/blueberry/blob/main/packages/curriculum/src/reactions/reaction.ts"
click node_placement "https://github.com/andliu7/blueberry/blob/main/packages/curriculum/src/placement.ts"
click node_chemcore "https://github.com/andliu7/blueberry/blob/main/packages/chem-core/src/routes.ts"
click node_interaction "https://github.com/andliu7/blueberry/blob/main/packages/interaction/src/shapes/mechanism.ts"
click node_arrowinference "https://github.com/andliu7/blueberry/blob/main/packages/interaction/src/shapes/arrowInference.ts"
click node_notices "https://github.com/andliu7/blueberry/blob/main/packages/interaction/src/notices.ts"
click node_auth "https://github.com/andliu7/blueberry/blob/main/src/lib/AuthContext.tsx"
click node_session "https://github.com/andliu7/blueberry/blob/main/src/lib/useSession.ts"
click node_supabase "https://github.com/andliu7/blueberry/blob/main/src/lib/supabase.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_site,node_hub,node_deckdata,node_deckview toneBlue
class node_gameapp,node_gameshell,node_gamehooks,node_beats,node_admin toneAmber
class node_reactiondata,node_curriculum,node_placement,node_chemcore,node_interaction,node_arrowinference,node_notices toneMint
class node_deckprogress,node_browserstore,node_auth,node_session,node_supabase toneRose
class node_student toneIndigo
```

## Components

### Deck study

- [Site router](https://github.com/andliu7/blueberry/blob/main/src/App.tsx): `src/App.tsx`
- [Deck hub](https://github.com/andliu7/blueberry/blob/main/src/components/HomePage.tsx): `src/components/HomePage.tsx`
- [Deck content](https://github.com/andliu7/blueberry/blob/main/src/data/decks/index.ts): `src/data/decks/index.ts`
- [Deck study](https://github.com/andliu7/blueberry/blob/main/src/components/review/DeckPage.tsx): `src/components/review/DeckPage.tsx`

### Interactive game

- [Game router](https://github.com/andliu7/blueberry/blob/main/src/game/App.tsx): `src/game/App.tsx`
- [Game shell](https://github.com/andliu7/blueberry/blob/main/src/game/app/Shell.tsx): `src/game/app/Shell.tsx`
- [Game hooks](https://github.com/andliu7/blueberry/blob/main/src/game/app/hooks.ts): `src/game/app/hooks.ts`
- [Lesson beats](https://github.com/andliu7/blueberry/blob/main/src/game/beats/BeatRunner.tsx): `src/game/beats/BeatRunner.tsx`
- [Admin viewer](https://github.com/andliu7/blueberry/blob/main/src/game/admin/AdminViewer.tsx): `src/game/admin/AdminViewer.tsx`

### Chemistry engine

- [Reaction catalog](https://github.com/andliu7/blueberry/blob/main/src/data/reactions.ts): `src/data/reactions.ts`
- [Reaction curriculum](https://github.com/andliu7/blueberry/blob/main/packages/curriculum/src/reactions/reaction.ts): `packages/curriculum/src/reactions/reaction.ts`
- [Lesson placement](https://github.com/andliu7/blueberry/blob/main/packages/curriculum/src/placement.ts): `packages/curriculum/src/placement.ts`
- [Chemistry core](https://github.com/andliu7/blueberry/blob/main/packages/chem-core/src/routes.ts): `packages/chem-core/src/routes.ts`
- [Mechanism interaction](https://github.com/andliu7/blueberry/blob/main/packages/interaction/src/shapes/mechanism.ts): `packages/interaction/src/shapes/mechanism.ts`
- [Arrow inference](https://github.com/andliu7/blueberry/blob/main/packages/interaction/src/shapes/arrowInference.ts): `packages/interaction/src/shapes/arrowInference.ts`
- [Interaction notices](https://github.com/andliu7/blueberry/blob/main/packages/interaction/src/notices.ts): `packages/interaction/src/notices.ts`

### Accounts and state

- [Saved progress](https://github.com/andliu7/blueberry/blob/main/src/game/app/progress.ts): `src/game/app/progress.ts`
- **Browser storage**
- [Authentication](https://github.com/andliu7/blueberry/blob/main/src/lib/AuthContext.tsx): `src/lib/AuthContext.tsx`
- [Session provider](https://github.com/andliu7/blueberry/blob/main/src/lib/useSession.ts): `src/lib/useSession.ts`
- [Supabase client](https://github.com/andliu7/blueberry/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Student**

## Connections

- Student → Site router: opens
- Site router → Deck hub: routes to (evidence: `src/App.tsx`)
- Student → Deck hub: chooses deck
- Deck hub → Deck study: opens deck
- Site router → Deck study: routes to (evidence: `src/App.tsx`)
- Deck study → Deck content: shows questions
- Deck study → Saved progress: saves ratings
- Saved progress → Browser storage: persists
- Student → Game router: enters game
- Game router → Game shell: renders shell (evidence: `src/game/App.tsx`)
- Game router → Lesson beats: renders lesson (evidence: `src/game/App.tsx`)
- Game router → Admin viewer: renders admin (evidence: `src/game/App.tsx`)
- Game hooks → Saved progress: uses progress (evidence: `src/game/app/hooks.ts`)
- Reaction curriculum → Lesson placement: uses placement (evidence: `packages/curriculum/src/reactions/reaction.ts`)
- Reaction curriculum → Reaction catalog: searches reactions
- Mechanism interaction → Chemistry core: uses chemistry (evidence: `packages/interaction/src/shapes/mechanism.ts`)
- Mechanism interaction → Arrow inference: delegates inference (evidence: `packages/interaction/src/shapes/mechanism.ts`)
- Arrow inference → Chemistry core: resolves targets (evidence: `packages/interaction/src/shapes/arrowInference.ts`)
- Mechanism interaction → Interaction notices: emits notices (evidence: `packages/interaction/src/shapes/mechanism.ts`)
- Session provider → Authentication: reads identity (evidence: `src/lib/useSession.ts`)
- Session provider → Supabase client: checks configuration (evidence: `src/lib/useSession.ts`)
- Authentication → Supabase client: uses client (evidence: `src/lib/AuthContext.tsx`)
