sba-scouting/rust/CLAUDE.md
Cal Corum 9863f89309 Implement Standings screen with DB-cached two-phase loading
Add league standings with Division and Wild Card tabs, fetched from API
with SQLite cache for instant display on screen open. Document 11 new
future features in project plan and add cargo check post-edit hook.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 18:31:55 -06:00

63 lines
2.7 KiB
Markdown

# CLAUDE.md — Rust Rewrite
## Session Start
Read the rewrite memory file before starting work:
`~/.claude/projects/-mnt-NV2-Development-sba-scouting/memory/rust-rewrite.md`
It has the phase plan, completion status, architecture decisions, and current file layout.
## Project Overview
Rust rewrite of the SBA Scout TUI. Uses ratatui + crossterm for the terminal UI, sqlx + SQLite for data, reqwest for API calls, and figment + TOML for configuration.
## Commands
```bash
cargo build # compile
cargo run # run TUI
cargo test # run tests
cargo clippy # lint
cargo fmt # format
```
## Architecture
Same layered structure as the Python version, ported to Rust idioms:
```
src/
├── main.rs # tokio runtime, event loop, file logging
├── app.rs # App struct, screen routing, nav/status bars
├── config.rs # figment-based TOML settings
├── lib.rs # module re-exports
├── api/ # reqwest HTTP client, sync pipeline, CSV importers
├── calc/ # league stats, matchup scoring, score cache, weights
├── db/ # sqlx models, queries, schema
├── screens/ # ratatui screen states (all 6 screens complete)
└── widgets/ # reusable UI components (selector)
```
### Key Patterns
- **Async throughout**: tokio runtime, sqlx async, reqwest async
- **Message passing**: `mpsc::UnboundedSender<AppMessage>` for async task → UI communication
- **No global state**: Settings and SqlitePool passed by reference, no singletons
- **TOML config** (not YAML): `data/settings.toml` with `SBA_SCOUT_` env var overrides
### Screens (all complete)
- `dashboard.rs` — Roster summary, sync trigger
- `gameday.rs` — Matchup table + lineup builder (opponent/pitcher context)
- `roster.rs` — Tabbed roster view (Majors/Minors/IL), batter/pitcher sub-tables
- `matchup.rs` — Standalone matchup analysis with sort modes, state cached on nav-away
- `lineup.rs` — Standalone lineup builder, save/load/delete with confirmation
- `settings.rs` — Config form with TOML save, live team validation, per-field change indicators
- `standings.rs` — League standings with Division and Wild Card tabs, fetched live from API
## Code Style
- Run `cargo fmt` and `cargo clippy` before committing
- A `cargo check` hook runs automatically after every `.rs` file edit (via `.claude/settings.json`). Run `cargo clippy` manually at logical checkpoints (before commits, after finishing a feature, after a batch of edits) to catch lint warnings beyond compile errors.
- Screen pattern: state struct → `new()``mount()``handle_key()``handle_message()``render()`