Project-specific guide for working on Alex's I Ching Study app.
/home/avalon/apps/iching-studyhttps://iching-study.apps.poofc.comiching-studyfiremountain/iching-studyAlways use the app's build command, then restart PM2, then verify the built asset timestamps.
cd /home/avalon/apps/iching-study
npm run build
pm2 restart iching-study
pm2 save
stat dist/assets/index-*.css dist/assets/index-*.js
Then visually verify the live site at https://iching-study.apps.poofc.com.
src/App.tsxsrc/index.csssrc/data/hexagrams.tssrc/lib/divination.tssrc/lib/humanDesignCenters.tssrc/App.test.tsx, src/lib/divination.test.tsThe app now includes a quiz section for memorizing which Human Design gates/hexagrams belong to which centers, plus the gate's exact visual slot within each center.
Quiz section entry separate from study/divination/admin.Human Design centers.src/App.tsx by extending ViewMode with quiz and using a small activeQuizId for sub-quiz selection.src/lib/humanDesignCenters.ts.GATE_TO_CENTER, ALL_HUMAN_DESIGN_GATES, and helper lookups from the shared center data so tests/UI stay in sync.hexagrams.ts dataset so gate = hexagram and the quiz can display the standard line glyph.The correct source of truth was the HD Prism app on the same server, not a hand-made recreation.
Use these HD Prism sources:
- center shapes / bodygraph SVG: /home/avalon/apps/hd-prism/apps/hdprism/public/svg/empty-bodygraph.svg
- gate-to-center mapping: /home/avalon/apps/hd-prism/apps/hdprism/lib/constants.ts
- placement logic reference: /home/avalon/apps/hd-prism/apps/hdprism/components/BodygraphScreen.tsx
The fastest reusable workflow was:
1. Read constants.ts for gate-to-center truth.
2. Read BodygraphScreen.tsx to understand how gate labels were placed on the SVG.
3. Extract center SVG paths and channel endpoints from empty-bodygraph.svg.
4. Build a compact local data file in the I Ching app (src/lib/humanDesignCenters.ts) rather than coupling directly to HD Prism runtime code.
This is better than trying to import HD Prism components directly because the I Ching app only needs stable geometry + mappings, not the whole bodygraph renderer.
When editing quizzes, cover at least:
- sidebar opens and shows Quiz section
- quiz home opens from the sidebar
- human design center quiz launches
- prompt exposes a gate number
- selecting the correct numbered slot produces a success state and next-gate CTA
The app now includes a dedicated mobile-only divination mode launched from the sidebar.
Start divinationview mode in src/App.tsx321)0)hexagram.linesUse pure helpers in src/lib/divination.ts for:
- coin value mapping
- line generation from 3 faces
- completion detection
- hexagram lookup from 6 lines
Keep UI-specific animation/state in src/App.tsx.
Simple generic gold circles looked cheap and failed user expectations. The better pattern was:
- ancient Chinese cash-coin styling with a square center hole
- visible bronze/brass rim, inner ring, patina, and depth cues
- explicit Yin/Yang labeling on the coins (陰 Yin, 陽 Yang)
- explicit role markers requested by user (Woman, Man, with ♀ / ♂)
- randomized per-cast motion values so coins do NOT land in the same pile every time
- higher toss arc, faster drop, and bounce/settle phases feel better than a soft float-up/float-down animation
For each cast, generate per-coin values for: - horizontal drift - vertical drift - spin - tilt - animation delay - rise height - bounce amount - settle rotation - faux depth
Then feed them into CSS custom properties and a single keyframe animation. This keeps animation expressive without adding a physics library.
If a visual review says the coins feel like a repeated tidy preset rather than tossed physical objects, increase: - toss height - drop speed contrast - per-coin randomization - spread/rotation variance
If Yin/Yang is not obvious in a screenshot, do not rely on subtle engraved details alone — add explicit readable text labels.
- Divination logic: src/lib/divination.ts
The app now includes a mobile-first coin divination mode launched from the sidebar.
Start divination action under its own Divination section.view === 'divination' mode rather than layering over study/admin views.The divination screen should feel nearly blank and immersive: - Keep only the discreet top-left floating menu button visible outside the main interaction area. - Do NOT reuse the normal study top bar on this screen. - Center the coin throw interaction and keep the accumulated lines anchored near the bottom. - Initial state should be minimal: no big explanatory copy blocks, just the throw state and button.
321)0)hexagrams.ts and open that hexagram's existing detail card.Use pure helper functions in src/lib/divination.ts for reusable logic:
- getCoinValue()
- getLineFromCoins()
- isDivinationComplete()
- getHexagramFromThrownLines()
- throwCoins()
Keep the UI state in App.tsx, but keep coin math and hexagram resolution out of the component.
When editing this flow, cover both pure logic and UI behavior:
- src/lib/divination.test.ts for heads/tails values, odd/even line conversion, completion, and hexagram lookup.
- src/App.test.tsx for sidebar entry, divination screen launch, first throw result, and six-throw completion opening the resolved hexagram.
The front-of-card hexagram should look like a normal I Ching hexagram — relatively narrow/tall, not stretched wide.
The glyph is rendered by LineGlyph in src/App.tsx and styled in src/index.css.
Important styling constraints:
- Keep .line-glyph width constrained (~11rem max) so the six-line stack does not look flattened.
- Keep vertical line spacing balanced with width.
- Avoid giving the glyph full-card width.
- Rounded modern line styling is okay, but the width-to-height ratio must still read as a traditional hexagram.
For compact trigram cards on the back/details side:
- Use a smaller fixed width (~4.2rem)
- Keep the compact line gap tighter than the full hexagram
- Slightly thicker compact lines are okay if the overall trigram remains legible
A text-only trigram section can look broken or "missing" even if the data is present.
For each trigram card, show ALL of the following together:
1. Compact line glyph (LineGlyph ... compact)
2. Trigram symbol character (☰, etc.)
3. Human-readable image label (heaven, earth, etc.)
4. Name and attribute text
Wrap the trigram visuals in a dedicated visual block:
- .trigram-visual
- .trigram-symbol-block
- .trigram-symbol
- .trigram-image-label
This makes the trigram instantly readable and prevents the symbol area from looking empty in browser screenshots or on mobile.
If a user says a visual element is "not showing," don't assume the data binding is broken.
In this app, the trigram data existed and LineGlyph rendered, but the presentation was too subtle. The correct fix was to improve the visual affordance, not to debug API/data flow.
The app now includes a dedicated mobile-only divination mode launched from the sidebar.
Start divination1)0)src/lib/divination.tssrc/App.tsxhexagramssrc/lib/divination.test.tssrc/App.test.tsxIf Alex asks for the coins to feel "cool," "ancient Chinese," or more premium, the correct direction is: - Ancient Chinese cash coin look with square hole in the center - Coins should feel like aged bronze/brass artifacts, not flat yellow UI circles - Use: - rim + inner ring - patina / oxidation variation - darker recesses around square hole - engraved character treatment - stronger contact shadows - visible thickness / perspective - Larger coins read better on mobile; do not keep them too small - Remove tiny visual labels around the coins if they clutter the hero composition; use screen-reader-only text instead
Cheap coin motion feels fake immediately. Better results come from: - per-coin drift and staggered timing - larger toss arc - stronger tumbling / rotation variation per coin - settle state with convincing shadow placement - a more ceremonial, sparse composition rather than crowding the screen
For this app, minimalist is good, but "empty + generic" is not. The divination screen only feels premium when the coins themselves become the hero object. If the coins are too small, too flat, or too labeled, the whole experience reads like placeholder UI instead of ritual interaction.
The app now supports a full Wilhelm translation panel on the hexagram details side.
Do NOT rely on the PDF text layer for Wilhelm extraction. In this PDF, direct text extraction is garbage due to font encoding.
Use this pipeline instead:
1. Use PDF bookmarks / TOC to map each hexagram to page ranges.
2. Render those pages to PNGs.
3. Use a vision-capable model to transcribe the PNGs into structured JSON.
4. Preserve source page images in the repo for fidelity and future spot-checks.
5. Merge the generated Wilhelm data into src/data/hexagrams.ts.
scripts/extract-wilhelm-vision.tsdata/wilhelm-section-map.jsonsrc/data/wilhelm-extracted.generated.jsonpublic/wilhelm/<hexagram-number>/page-XXX.pngsrc/data/hexagrams.tssrc/App.tsxsrc/index.csssrc/App.test.tsxThe Judgement, The Image, and The Lines far better than Tesseract cleanup.Romanized / English name, ElementExtend Hexagram with:
- wilhelm?: { heading, pageStart, pageEnd, sourceImages, above, below, judgement, image, lines, notes, fullText }
Render a dedicated WilhelmPanel on the details/back side with:
- heading
- page range
- above / below cards
- Judgement block
- Image block
- line cards for The Lines
Use white-space: pre-wrap for Wilhelm text so line breaks survive.
npx tsx scripts/extract-wilhelm-vision.ts --samplenpx tsx scripts/extract-wilhelm-vision.tscp docs/reports/wilhelm-vision-full.json src/data/wilhelm-extracted.generated.jsonOnce Wilhelm is in the UI, existing tests may start failing from ambiguous matches because the same phrases appear in both the modern summary copy and the Wilhelm panel.
Fix tests by scoping assertions with within(panel) and using heading levels when needed.
After changing card/trigram visuals, divination visuals, or Wilhelm content:
1. Build succeeds
2. PM2 process restarts cleanly
3. dist/ asset timestamps are fresh
4. Front card hexagram looks narrower and closer to traditional proportions
5. Back/details shows clearly visible upper + lower trigram visuals
6. Divination sidebar entry exists and opens correctly
7. Divination screen shows 3 visible premium coins before the first cast
8. Casting animation completes and line progress updates correctly
9. Six casts resolve to a matching hexagram and open its details view
10. Wilhelm panel appears on the hexagram details side with heading, sections, and lines
11. Live browser check shows no JS errors
12. Commit and push changes to GitHub
Always commit and push after changes:
git add src/App.tsx src/index.css
git commit -m "Fix hexagram proportions and trigram visuals"
git push origin main