feat/ui-theme-settings-champion #34

Merged
jason merged 2 commits from feat/ui-theme-settings-champion into master 2026-03-09 22:48:05 -05:00
Showing only changes of commit eda59b7a02 - Show all commits

180
README.md
View File

@@ -15,16 +15,31 @@ A reactive, interactive dog breeding genealogy mapping system for professional k
- **✅ Branded Navigation** - Custom logo (br-logo.png) with gold-to-rusty-red gradient title
- **✅ Trial Pairing Simulator** - COI calculator with common ancestors table and risk badge
- **✅ Heat Cycle Calendar** - Month grid calendar with cycle windows, breeding date suggestions, and **projected whelping identifiers**
- **✅ Champion Bloodline Tracking** - Mark dogs as titled champions; offspring display a Champion Bloodline badge
- **✅ Kennel Settings** - Configurable kennel name, tagline, address, AKC ID, breed, owner info
- **✅ UI Theme** - CSS custom property theming with `--champion-gold` and dark-mode variables
### Database Architecture
- **✅ Clean Schema** - No migrations, fresh installs create correct structure
- **✅ Clean Schema** - No migrations needed; fresh installs create correct structure; existing DBs auto-migrate via safe `ALTER TABLE` guards
- **✅ Normalized Design** - `parents` table for relationships (sire/dam)
- **✅ Litter Linking** - Dogs linked to litters via `litter_id`
- **✅ Health Records** - Medical history and genetic testing
- **✅ Heat Cycles** - Breeding cycle tracking
- **✅ Genetic Traits** - Inherited trait mapping
- **✅ Settings Table** - Single-row kennel configuration with all contact/identity fields
### Recently Added (March 9, 2026 — v0.5.1)
### Recently Added (March 9, 2026 — v0.6.0)
- **✅ Champion Flag** — `is_champion INTEGER DEFAULT 0` on `dogs` table; safe `ALTER TABLE` migration guard for existing DBs
- **✅ Champion Toggle in DogForm** — amber-gold highlighted checkbox row with `Award` icon; marks dog as titled champion
- **✅ Champion ✪ in Parent Dropdowns** — sire/dam selects append `✪` to champion names for at-a-glance visibility
- **✅ Champion Bloodline Badge** — offspring of champion parents display a badge on dog cards and detail pages
- **✅ Kennel Settings API** — `GET/PUT /api/settings` with single-row column schema and ALLOWED_KEYS whitelist
- **✅ Settings Table Migration** — all kennel fields added with safe `ALTER TABLE` guards on existing DBs; default seed row auto-created
- **✅ SettingsProvider / useSettings** — React context hook renamed `useSettings.jsx` (was `.js`; contained JSX causing Vite build failure)
- **✅ `server/index.js` Fix** — `initDatabase()` called with no args to match updated `db/init.js`; removed duplicate `/api/health` route
- **✅ `settings.js` Route Fix** — rewrote from double-encoded base64 + old key/value schema to correct single-row column schema
### Previously Added (March 9, 2026 — v0.5.1)
- **✅ Projected Whelp Window on Calendar** - Indigo/purple day cells (days 5865 from breeding date) visible directly on the month grid
- **✅ Expected Whelp Day Marker** - Indigo dot on the exact expected whelp day (day 63) alongside the green breeding dot
- **✅ "[Name] due" Cell Label** - Baby 🍼 icon + dog name label inside the whelp day cell
@@ -57,9 +72,9 @@ A reactive, interactive dog breeding genealogy mapping system for professional k
- **Frontend**: React 18 with modern component design
- **Visualization**: React-D3-Tree for pedigree charts
- **Backend**: Node.js/Express API
- **Database**: SQLite (embedded, zero-config) with clean normalized schema
- **Database**: SQLite (embedded, zero-config) with clean normalized schema + safe `ALTER TABLE` migration guards
- **Container**: Single Docker image with multi-stage build
- **Styling**: CSS custom properties with dark theme + gradient branding
- **Styling**: CSS custom properties with dark theme + `--champion-gold` + gradient branding
## Quick Start
@@ -79,30 +94,21 @@ docker-compose up -d
Access at: `http://localhost:3000`
### Fresh Install Database Setup
### Upgrading an Existing Installation
For a **fresh install**, the database will automatically initialize with the correct schema.
For an **existing installation upgrade**:
The database now uses safe `ALTER TABLE` guards — **you do not need to delete your database to upgrade**. Just pull and rebuild:
```bash
# Stop the application
docker-compose down
# Backup your data
cp data/breedr.db data/breedr.db.backup
# Delete old database (it will be recreated)
rm data/breedr.db
# Pull latest code
git pull origin master
# Rebuild and restart
docker-compose up -d --build
```
The app will create a fresh database with the clean schema automatically.
New columns (`is_champion`, all `settings` kennel fields) are added automatically on first boot. Your existing dog data is preserved.
### Fresh Install Database Setup
For a **fresh install**, the database will automatically initialize with the correct schema and seed a default settings row.
## Database Schema
@@ -111,15 +117,17 @@ The app will create a fresh database with the clean schema automatically.
1. **No sire/dam columns in `dogs` table** - Parent relationships stored in `parents` table
2. **Normalized structure** - Reduces redundancy, improves data integrity
3. **Litter linking** - Dogs reference litters via `litter_id` foreign key
4. **Safe migrations** - `ALTER TABLE ... ADD COLUMN` guards allow zero-downtime upgrades
### Core Tables
- **dogs** - Core dog registry (NO sire_id/dam_id columns)
- **dogs** - Core dog registry; includes `is_champion`, `litter_id`, `photo_urls`
- **parents** - Sire/dam relationships (dog_id, parent_id, parent_type)
- **litters** - Breeding records with sire/dam references
- **health_records** - Medical and genetic testing
- **heat_cycles** - Breeding cycle tracking
- **traits** - Genetic trait mapping
- **settings** - Single-row kennel configuration (kennel_name, tagline, address, phone, email, website, akc_id, breed, owner_name)
**Full schema documentation:** [DATABASE.md](DATABASE.md)
@@ -127,8 +135,9 @@ The app will create a fresh database with the clean schema automatically.
- `NODE_ENV` - production/development (default: production)
- `PORT` - Server port (default: 3000)
- `DB_PATH` - SQLite database path (default: /app/data/breedr.db)
- `DATA_DIR` - Data directory for SQLite file (default: /app/data)
- `UPLOAD_PATH` - Upload directory (default: /app/uploads)
- `STATIC_PATH` - Static assets directory (default: /app/static)
## Development
@@ -149,32 +158,39 @@ npm run build
```
breedr/
├── client/ # React frontend
├── client/ # React frontend
│ ├── src/
│ │ ├── pages/
│ │ │ ├── BreedingCalendar.jsx # Heat cycle calendar + whelping identifiers
│ │ │ ├── PairingSimulator.jsx # Trial pairing + COI
│ │ │ ├── SettingsPage.jsx # Kennel settings form
│ │ │ ├── Dashboard.jsx
│ │ │ ├── DogList.jsx
│ │ │ ├── DogDetail.jsx
│ │ │ ├── PedigreeView.jsx
│ │ │ └── LitterList.jsx
│ ├── public/
│ ├── components/
│ │ │ └── DogForm.jsx # Champion toggle + parent selects
│ │ ├── hooks/
│ │ │ └── useSettings.jsx # SettingsProvider + useSettings context
│ │ └── App.jsx
│ └── package.json
├── server/ # Node.js backend
├── server/ # Node.js backend
│ ├── routes/
│ │ ├── breeding.js # Heat cycles, whelping, suggestions
│ │ ├── pedigree.js # COI, trial pairing
│ │ ├── dogs.js
│ │ ── litters.js
│ │ ├── dogs.js # is_champion in all queries
│ │ ├── settings.js # GET/PUT kennel settings (single-row schema)
│ │ ├── breeding.js # Heat cycles, whelping, suggestions
│ │ ── pedigree.js # COI, trial pairing
│ │ ├── litters.js
│ │ └── health.js
│ ├── db/
│ │ └── init.js # Clean schema (NO migrations)
│ │ └── init.js # Schema + ALTER TABLE migration guards
│ └── index.js
├── static/ # Branding assets (br-logo.png, etc.)
├── docs/ # Documentation
├── DATABASE.md # Schema documentation
├── ROADMAP.md # Development roadmap
├── Dockerfile # Multi-stage Docker build
├── static/ # Branding assets (br-logo.png, etc.)
├── docs/ # Documentation
├── ROADMAP.md
├── DATABASE.md
├── Dockerfile
├── docker-compose.yml
└── README.md
```
@@ -183,9 +199,14 @@ breedr/
### Dogs
- `GET/POST /api/dogs` - Dog CRUD operations
- `GET /api/dogs/:id` - Get dog with parents and offspring
- `GET /api/dogs/:id` - Get dog with parents (incl. is_champion), offspring, and health summary
- `PUT /api/dogs/:id` - Update dog (incl. is_champion)
- `POST /api/dogs/:id/photos` - Upload photos
### Settings
- `GET /api/settings` - Get kennel settings
- `PUT /api/settings` - Update kennel settings (partial update supported)
### Pedigree & Genetics
- `GET /api/pedigree/:id` - Generate pedigree tree
- `POST /api/pedigree/trial-pairing` - COI + common ancestors + risk recommendation
@@ -207,68 +228,37 @@ breedr/
- `GET /static/*` - Branding and static assets
- `GET /uploads/*` - Dog photos
## Upgrading
### From Earlier Versions
If you have an **old database with sire/dam columns** or missing litter_id:
```bash
# Backup your data
cp data/breedr.db data/breedr.db.backup
# Delete old database
rm data/breedr.db
# Pull latest code
git pull
# Restart (will create clean schema)
docker-compose restart
```
**Important:** The new schema uses a `parents` table instead of sire/dam columns. Parent data cannot be automatically migrated - you'll need to re-enter parent relationships.
## Troubleshooting
### Server crashes with `SyntaxError: Unexpected end of input` on `settings.js`
The settings route file may have been corrupted (double-encoded base64). Pull the latest code and rebuild.
### "no such column: kennel_name" or "no such column: is_champion"
Your database predates the `ALTER TABLE` migration guards. Pull the latest code and restart — columns are added automatically. No data loss.
### "no such column: weight" or "no such column: sire_id"
Your database has an old schema. Delete and recreate:
Your database has a very old schema. Delete and recreate:
```bash
cp data/breedr.db data/breedr.db.backup
rm data/breedr.db
docker-compose restart
```
### Parent relationships not saving
Check server logs for:
```
✔ Dog inserted with ID: 123
Adding sire relationship: dog 123 -> sire 5
✔ Sire relationship added
```
If you don't see these logs, ensure `sire_id` and `dam_id` are being sent in the API request.
### Logo not appearing in navbar
Ensure `br-logo.png` is placed in the `static/` directory at the project root. The file is served at `/static/br-logo.png`.
### Heat cycles not showing on calendar
Ensure dogs are registered with `sex: 'female'` before creating heat cycles. The API validates this and will return a 400 error for male dogs.
### Whelping window not appearing on calendar
A breeding date must be logged on the cycle for whelp window cells to appear. Use the Cycle Detail modal → "Log Breeding Date" field. The whelp preview appears client-side instantly; the calendar cells populate after save.
A breeding date must be logged on the cycle for whelp window cells to appear. Use the Cycle Detail modal → "Log Breeding Date" field.
## Roadmap
### ✅ Completed
- [x] Docker containerization
- [x] SQLite database with clean schema
- [x] Dog management (CRUD)
- [x] SQLite database with clean schema + ALTER TABLE migration guards
- [x] Dog management (CRUD) with champion flag
- [x] Photo management
- [x] Interactive pedigree visualization
- [x] Litter management
@@ -280,8 +270,10 @@ A breeding date must be logged on the cycle for whelp window cells to appear. Us
- [x] Trial Pairing Simulator (COI + common ancestors + risk badge)
- [x] Heat Cycle Calendar (month grid + windows + breeding suggestions + whelping estimate)
- [x] **Projected Whelping Calendar Identifier** (whelp window cells, due label, active card range, live modal preview, whelping banner)
- [x] **Champion Bloodline Tracking** (is_champion flag, DogForm toggle, offspring badge)
- [x] **Kennel Settings** (GET/PUT /api/settings, SettingsProvider, kennel name in navbar)
### 🔧 In Progress / Up Next
### 🔜 In Progress / Up Next
- [ ] Health Records System
- [ ] Genetic trait tracking
@@ -295,6 +287,19 @@ A breeding date must be logged on the cycle for whelp window cells to appear. Us
## Recent Updates
### March 9, 2026 - Champion Bloodline, Settings, Build Fixes (v0.6.0)
- **Added:** `is_champion` column to `dogs` table with safe `ALTER TABLE` migration guard
- **Added:** Champion toggle checkbox in DogForm with amber-gold highlight and `Award` icon
- **Added:** `✪` suffix on champion sire/dam in parent dropdowns
- **Added:** Champion Bloodline badge on offspring cards/detail pages
- **Added:** `GET/PUT /api/settings` route — single-row column schema with `ALLOWED_KEYS` whitelist
- **Added:** Full kennel settings columns in `settings` table with migration guards
- **Added:** `SettingsProvider` / `useSettings` React context for kennel name in navbar
- **Fixed:** `useSettings.js``useSettings.jsx` (Vite build failure — JSX in `.js` file)
- **Fixed:** `server/index.js``initDatabase()` called with no args; removed duplicate `/api/health` route
- **Fixed:** `server/routes/settings.js` — rewrote from double-encoded base64 + old key/value schema
- **Fixed:** `DB_PATH` arg removed from `initDatabase()` call; `DATA_DIR` env var now controls directory
### March 9, 2026 - Projected Whelping Calendar Identifier (v0.5.1)
- **Added:** Indigo whelp window (days 5865) on calendar grid cells when a breeding date is logged
- **Added:** Indigo dot marker on exact expected whelp day (day 63)
@@ -323,23 +328,6 @@ A breeding date must be logged on the cycle for whelp window cells to appear. Us
- **Fixed:** `/static` and `/uploads` paths no longer fall through to React router
- **Fixed:** Brand logo sized as fixed 1:1 square for proper aspect ratio
### March 9, 2026 - Clean Database Schema (v0.4.0)
- **Fixed:** Database schema cleaned up - no migrations
- **Fixed:** Removed weight/height columns (never implemented)
- **Fixed:** Proper parent handling via parents table
- **Added:** litter_id column for linking puppies to litters
- **Added:** Comprehensive DATABASE.md documentation
- **Improved:** Server startup with clean initialization
### March 8, 2026 - UI Redesign & Bug Fixes
- **Fixed:** Microchip field UNIQUE constraint (now properly optional)
- **Redesigned:** Modern dark theme with sleek aesthetics
- **Redesigned:** Compact horizontal info cards (80x80 avatars)
- **Improved:** Dashboard with gradient stats cards
- **Improved:** Navigation bar with glass morphism
- **Added:** Sex-colored icons (blue ♂, pink ♀)
- **Added:** Registration number badges
## Documentation
- [DATABASE.md](DATABASE.md) - Complete schema documentation