Smith42 Claude Opus 4.6 commited on
Commit
48f7064
·
1 Parent(s): 1165f77

Add CLAUDE.md with project overview and dev guide

Browse files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. CLAUDE.md +52 -0
CLAUDE.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # g-Harmony
2
+
3
+ Galaxy "interestingness" tournament app. Users compare pairs of galaxy images and vote on which is more interesting, ranked via ELO ratings.
4
+
5
+ ## Tech Stack
6
+
7
+ - **Framework**: Dash (Plotly) with dash-bootstrap-components
8
+ - **Server**: Gunicorn (Flask under the hood via `app.server`)
9
+ - **Data**: HuggingFace `datasets` library (`mwalmsley/gz_euclid`, `Smith42/dating_pool_but_galaxies`)
10
+ - **Persistence**: HuggingFace Hub `CommitScheduler` for ELO state and comparison logs
11
+ - **Deployment**: Docker on HuggingFace Spaces (port 7860)
12
+ - **Python**: 3.9+
13
+
14
+ ## Project Structure
15
+
16
+ ```
17
+ app.py # Entry point, creates Dash app
18
+ src/
19
+ config.py # Env vars (HF_TOKEN, HF_LOG_REPO_ID) and constants
20
+ elo.py # ELO rating system, pair selection, HF state persistence
21
+ callbacks.py # Dash callbacks (card clicks, leaderboard toggle, reset)
22
+ components.py # UI layout, galaxy cards, leaderboard, CSS theme
23
+ galaxy_profiles.py # Loads and exports GALAXY_PROFILES, GALAXY_IDS
24
+ galaxy_data_loader.py # HuggingFace dataset loading with fallback data
25
+ hf_logging.py # JSONL comparison event logging via CommitScheduler
26
+ scripts/
27
+ caption_galaxies.py # Utility for generating galaxy captions
28
+ upload_galaxies.py # Utility for uploading galaxy data
29
+ images/ # Galaxy JPEG images (galaxy_01.jpg, galaxy_02.jpg, ...)
30
+ ```
31
+
32
+ ## Running Locally
33
+
34
+ ```bash
35
+ # Create .env with HF_TOKEN and HF_LOG_REPO_ID (optional, app works without)
36
+ uv run python app.py
37
+ # Serves at http://localhost:7860
38
+ ```
39
+
40
+ ## Key Patterns
41
+
42
+ - **ELO state** is thread-safe (`threading.Lock`) and saved to `state/elo_state.json` on every comparison, synced to HF Hub periodically
43
+ - **Pair selection** favors close-ELO matchups (70%) with random pairs (30%); supports "king of the hill" champion mode
44
+ - **Galaxy IDs** are numbered (`galaxy_01`, `galaxy_02`, ...) mapped from HF dataset `id_str` fields
45
+ - **Callbacks** use Dash `ctx.triggered_id` to determine which card was clicked; session state stored in `dcc.Store` components
46
+ - **Images** served via Flask route `/galaxy-images/<filename>` from the `images/` directory
47
+
48
+ ## Environment Variables
49
+
50
+ - `HF_TOKEN` - HuggingFace API token (read/write)
51
+ - `HF_LOG_REPO_ID` - Dataset repo for ELO state and logs (e.g. `username/gharmony-logs`)
52
+ - `HF_LOG_EVERY_MINUTES` - Sync interval (default: 10)