feat: add Doris Barbell v1 scaffold
This commit is contained in:
0
home/doris-barbell/app/__init__.py
Normal file
0
home/doris-barbell/app/__init__.py
Normal file
12
home/doris-barbell/app/config.py
Normal file
12
home/doris-barbell/app/config.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Settings:
|
||||
app_name: str = 'Doris Barbell'
|
||||
default_state_dir: Path = Path(os.environ.get('BARBELL_STATE_DIR', '/tmp/doris-barbell-state'))
|
||||
|
||||
28
home/doris-barbell/app/main.py
Normal file
28
home/doris-barbell/app/main.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from app.config import Settings
|
||||
from app.routes.api import router as api_router
|
||||
from app.routes.ui import router as ui_router
|
||||
from app.services.store import JSONStore
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def create_app(state_dir: Path | str | None = None) -> FastAPI:
|
||||
settings = Settings()
|
||||
app = FastAPI(title=settings.app_name)
|
||||
resolved_state_dir = Path(state_dir) if state_dir is not None else settings.default_state_dir
|
||||
app.state.store = JSONStore(resolved_state_dir)
|
||||
app.mount('/static', StaticFiles(directory=BASE_DIR / 'static'), name='static')
|
||||
app.include_router(ui_router)
|
||||
app.include_router(api_router)
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
84
home/doris-barbell/app/models.py
Normal file
84
home/doris-barbell/app/models.py
Normal file
@@ -0,0 +1,84 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal
|
||||
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
|
||||
|
||||
class ProfileUpdate(BaseModel):
|
||||
display_name: str | None = None
|
||||
height_inches: float | None = Field(default=None, gt=0)
|
||||
goal_weight_lbs: float | None = Field(default=None, gt=0)
|
||||
measurement_system: Literal['imperial'] | None = 'imperial'
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class WeightEntryCreate(BaseModel):
|
||||
recorded_at: str
|
||||
weight_lbs: float = Field(gt=0)
|
||||
body_fat_percent: float | None = Field(default=None, ge=0, le=100)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class MeasurementEntryCreate(BaseModel):
|
||||
recorded_at: str
|
||||
waist_inches: float | None = Field(default=None, gt=0)
|
||||
hip_inches: float | None = Field(default=None, gt=0)
|
||||
chest_inches: float | None = Field(default=None, gt=0)
|
||||
neck_inches: float | None = Field(default=None, gt=0)
|
||||
notes: str | None = None
|
||||
|
||||
@model_validator(mode='after')
|
||||
def validate_at_least_one_measurement(self) -> 'MeasurementEntryCreate':
|
||||
if not any(
|
||||
value is not None
|
||||
for value in [self.waist_inches, self.hip_inches, self.chest_inches, self.neck_inches]
|
||||
):
|
||||
raise ValueError('At least one body measurement is required.')
|
||||
return self
|
||||
|
||||
|
||||
class ExerciseTemplateCreate(BaseModel):
|
||||
name: str
|
||||
primary_muscle: str | None = None
|
||||
equipment: str | None = None
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class RoutineExerciseCreate(BaseModel):
|
||||
exercise_name: str
|
||||
target_sets: int = Field(ge=1)
|
||||
target_reps: str
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class RoutineCreate(BaseModel):
|
||||
user_id: str
|
||||
name: str
|
||||
notes: str | None = None
|
||||
exercises: list[RoutineExerciseCreate]
|
||||
|
||||
|
||||
class WorkoutSetCreate(BaseModel):
|
||||
reps: int = Field(ge=1)
|
||||
weight_lbs: float = Field(ge=0)
|
||||
rpe: float | None = Field(default=None, ge=0)
|
||||
rest_seconds: int | None = Field(default=None, ge=0)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class WorkoutExerciseCreate(BaseModel):
|
||||
exercise_name: str
|
||||
notes: str | None = None
|
||||
sets: list[WorkoutSetCreate]
|
||||
|
||||
|
||||
class WorkoutCreate(BaseModel):
|
||||
user_id: str
|
||||
performed_at: str
|
||||
routine_name: str
|
||||
notes: str | None = None
|
||||
exercises: list[WorkoutExerciseCreate]
|
||||
|
||||
|
||||
JSONDict = dict[str, Any]
|
||||
111
home/doris-barbell/app/routes/api.py
Normal file
111
home/doris-barbell/app/routes/api.py
Normal file
@@ -0,0 +1,111 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
|
||||
from app.models import (
|
||||
ExerciseTemplateCreate,
|
||||
MeasurementEntryCreate,
|
||||
ProfileUpdate,
|
||||
RoutineCreate,
|
||||
WeightEntryCreate,
|
||||
WorkoutCreate,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix='/api')
|
||||
|
||||
|
||||
@router.get('/health')
|
||||
def health() -> dict[str, str]:
|
||||
return {'status': 'ok'}
|
||||
|
||||
|
||||
@router.get('/dashboard/summary')
|
||||
def dashboard_summary(request: Request) -> dict:
|
||||
return request.app.state.store.dashboard_summary()
|
||||
|
||||
|
||||
@router.put('/profile/{user_id}')
|
||||
def update_profile(user_id: str, payload: ProfileUpdate, request: Request) -> dict:
|
||||
try:
|
||||
return request.app.state.store.update_profile(user_id, payload.model_dump())
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.post('/profile/{user_id}/weight', status_code=201)
|
||||
def add_weight_entry(user_id: str, payload: WeightEntryCreate, request: Request) -> dict:
|
||||
try:
|
||||
return request.app.state.store.add_weight_entry(user_id, payload.model_dump())
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.get('/history/{user_id}/weights')
|
||||
def weight_history(user_id: str, request: Request) -> list[dict]:
|
||||
try:
|
||||
return request.app.state.store.weight_history(user_id)
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.post('/profile/{user_id}/measurements', status_code=201)
|
||||
def add_measurement_entry(user_id: str, payload: MeasurementEntryCreate, request: Request) -> dict:
|
||||
try:
|
||||
return request.app.state.store.add_measurement_entry(user_id, payload.model_dump())
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.get('/history/{user_id}/measurements')
|
||||
def measurement_history(user_id: str, request: Request) -> list[dict]:
|
||||
try:
|
||||
return request.app.state.store.measurement_history(user_id)
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.post('/exercises/templates', status_code=201)
|
||||
def create_exercise_template(payload: ExerciseTemplateCreate, request: Request) -> dict:
|
||||
return request.app.state.store.add_exercise_template(payload.model_dump())
|
||||
|
||||
|
||||
@router.get('/exercises/templates')
|
||||
def list_exercise_templates(request: Request) -> list[dict]:
|
||||
return request.app.state.store.list_exercise_templates()
|
||||
|
||||
|
||||
@router.post('/routines', status_code=201)
|
||||
def create_routine(payload: RoutineCreate, request: Request) -> dict:
|
||||
try:
|
||||
return request.app.state.store.add_routine(payload.model_dump())
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.get('/routines')
|
||||
def list_routines(request: Request) -> list[dict]:
|
||||
return request.app.state.store.list_routines()
|
||||
|
||||
|
||||
@router.post('/workouts', status_code=201)
|
||||
def add_workout(payload: WorkoutCreate, request: Request) -> dict:
|
||||
try:
|
||||
return request.app.state.store.add_workout(payload.model_dump())
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.get('/history/{user_id}/workouts')
|
||||
def workout_history(user_id: str, request: Request) -> list[dict]:
|
||||
try:
|
||||
return request.app.state.store.workout_history(user_id)
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
|
||||
|
||||
@router.get('/progression/{user_id}/exercises')
|
||||
def exercise_progression(user_id: str, request: Request) -> list[dict]:
|
||||
try:
|
||||
return request.app.state.store.exercise_progression(user_id)
|
||||
except KeyError as exc:
|
||||
raise HTTPException(status_code=404, detail='Unknown user') from exc
|
||||
210
home/doris-barbell/app/routes/ui.py
Normal file
210
home/doris-barbell/app/routes/ui.py
Normal file
@@ -0,0 +1,210 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Form, HTTPException, Request, status
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
router = APIRouter()
|
||||
templates = Jinja2Templates(directory='app/templates')
|
||||
|
||||
|
||||
@router.get('/')
|
||||
def home(request: Request):
|
||||
return templates.TemplateResponse(
|
||||
request=request,
|
||||
name='dashboard.html',
|
||||
context=_dashboard_context(request),
|
||||
)
|
||||
|
||||
|
||||
@router.post('/log/weight', status_code=303)
|
||||
def log_weight(
|
||||
request: Request,
|
||||
user_id: str = Form(...),
|
||||
recorded_at: str = Form(...),
|
||||
weight_lbs: float = Form(...),
|
||||
body_fat_percent: str = Form(''),
|
||||
notes: str = Form(''),
|
||||
):
|
||||
payload = {
|
||||
'recorded_at': recorded_at,
|
||||
'weight_lbs': weight_lbs,
|
||||
'body_fat_percent': _optional_float(body_fat_percent),
|
||||
'notes': notes.strip() or None,
|
||||
}
|
||||
request.app.state.store.add_weight_entry(user_id, payload)
|
||||
return RedirectResponse(url='/', status_code=status.HTTP_303_SEE_OTHER)
|
||||
|
||||
|
||||
@router.post('/log/measurements', status_code=303)
|
||||
def log_measurements(
|
||||
request: Request,
|
||||
user_id: str = Form(...),
|
||||
recorded_at: str = Form(...),
|
||||
waist_inches: str = Form(''),
|
||||
hip_inches: str = Form(''),
|
||||
chest_inches: str = Form(''),
|
||||
neck_inches: str = Form(''),
|
||||
notes: str = Form(''),
|
||||
):
|
||||
payload = {
|
||||
'recorded_at': recorded_at,
|
||||
'waist_inches': _optional_float(waist_inches),
|
||||
'hip_inches': _optional_float(hip_inches),
|
||||
'chest_inches': _optional_float(chest_inches),
|
||||
'neck_inches': _optional_float(neck_inches),
|
||||
'notes': notes.strip() or None,
|
||||
}
|
||||
if not any(
|
||||
payload[key] is not None
|
||||
for key in ('waist_inches', 'hip_inches', 'chest_inches', 'neck_inches')
|
||||
):
|
||||
raise HTTPException(status_code=400, detail='At least one body measurement is required.')
|
||||
request.app.state.store.add_measurement_entry(user_id, payload)
|
||||
return RedirectResponse(url='/', status_code=status.HTTP_303_SEE_OTHER)
|
||||
|
||||
|
||||
@router.post('/templates', status_code=303)
|
||||
def create_template(
|
||||
request: Request,
|
||||
name: str = Form(...),
|
||||
primary_muscle: str = Form(''),
|
||||
equipment: str = Form(''),
|
||||
notes: str = Form(''),
|
||||
):
|
||||
request.app.state.store.add_exercise_template(
|
||||
{
|
||||
'name': name.strip(),
|
||||
'primary_muscle': primary_muscle.strip() or None,
|
||||
'equipment': equipment.strip() or None,
|
||||
'notes': notes.strip() or None,
|
||||
}
|
||||
)
|
||||
return RedirectResponse(url='/', status_code=status.HTTP_303_SEE_OTHER)
|
||||
|
||||
|
||||
@router.post('/routines', status_code=303)
|
||||
def create_routine(
|
||||
request: Request,
|
||||
user_id: str = Form(...),
|
||||
name: str = Form(...),
|
||||
exercise_lines: str = Form(...),
|
||||
notes: str = Form(''),
|
||||
):
|
||||
payload = {
|
||||
'user_id': user_id,
|
||||
'name': name.strip(),
|
||||
'notes': notes.strip() or None,
|
||||
'exercises': _parse_routine_exercises(exercise_lines),
|
||||
}
|
||||
request.app.state.store.add_routine(payload)
|
||||
return RedirectResponse(url='/', status_code=status.HTTP_303_SEE_OTHER)
|
||||
|
||||
|
||||
@router.post('/workouts/quick-log', status_code=303)
|
||||
def quick_log_workout(
|
||||
request: Request,
|
||||
user_id: str = Form(...),
|
||||
performed_at: str = Form(...),
|
||||
routine_name: str = Form(...),
|
||||
exercise_lines: str = Form(...),
|
||||
notes: str = Form(''),
|
||||
):
|
||||
payload = {
|
||||
'user_id': user_id,
|
||||
'performed_at': performed_at,
|
||||
'routine_name': routine_name.strip(),
|
||||
'notes': notes.strip() or None,
|
||||
'exercises': _parse_workout_exercises(exercise_lines),
|
||||
}
|
||||
request.app.state.store.add_workout(payload)
|
||||
return RedirectResponse(url='/', status_code=status.HTTP_303_SEE_OTHER)
|
||||
|
||||
|
||||
def _dashboard_context(request: Request) -> dict:
|
||||
store = request.app.state.store
|
||||
summary = store.dashboard_summary()
|
||||
return {
|
||||
'title': 'Doris Barbell',
|
||||
'summary': summary,
|
||||
'john_weight_history': store.weight_history('john')[:5],
|
||||
'john_measurement_history': store.measurement_history('john')[:5],
|
||||
'john_workout_history': store.workout_history('john')[:5],
|
||||
'john_progression': store.exercise_progression('john')[:5],
|
||||
}
|
||||
|
||||
|
||||
def _optional_float(value: str) -> float | None:
|
||||
cleaned = value.strip()
|
||||
if not cleaned:
|
||||
return None
|
||||
try:
|
||||
return float(cleaned)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=f'Invalid numeric value: {value}') from exc
|
||||
|
||||
|
||||
def _parse_routine_exercises(raw_lines: str) -> list[dict]:
|
||||
exercises = []
|
||||
for line in raw_lines.splitlines():
|
||||
cleaned = line.strip()
|
||||
if not cleaned:
|
||||
continue
|
||||
parts = [part.strip() for part in cleaned.split('|')]
|
||||
if len(parts) < 3:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail='Routine lines must use exercise|sets|reps|optional notes format.',
|
||||
)
|
||||
exercise_name, target_sets_raw, target_reps = parts[:3]
|
||||
try:
|
||||
target_sets = int(target_sets_raw)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=f'Invalid target sets: {target_sets_raw}') from exc
|
||||
exercises.append(
|
||||
{
|
||||
'exercise_name': exercise_name,
|
||||
'target_sets': target_sets,
|
||||
'target_reps': target_reps,
|
||||
'notes': parts[3] if len(parts) > 3 and parts[3] else None,
|
||||
}
|
||||
)
|
||||
if not exercises:
|
||||
raise HTTPException(status_code=400, detail='At least one routine exercise is required.')
|
||||
return exercises
|
||||
|
||||
|
||||
def _parse_workout_exercises(raw_lines: str) -> list[dict]:
|
||||
exercises = []
|
||||
for line in raw_lines.splitlines():
|
||||
cleaned = line.strip()
|
||||
if not cleaned:
|
||||
continue
|
||||
parts = [part.strip() for part in cleaned.split('|')]
|
||||
if len(parts) < 2:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail='Workout lines must use exercise|reps@weight, reps@weight|optional notes format.',
|
||||
)
|
||||
exercise_name = parts[0]
|
||||
notes = parts[2] if len(parts) > 2 and parts[2] else None
|
||||
sets = []
|
||||
for set_chunk in parts[1].split(','):
|
||||
token = set_chunk.strip()
|
||||
if not token:
|
||||
continue
|
||||
if '@' not in token:
|
||||
raise HTTPException(status_code=400, detail=f'Invalid set token: {token}')
|
||||
reps_raw, weight_raw = [value.strip() for value in token.split('@', 1)]
|
||||
try:
|
||||
reps = int(reps_raw)
|
||||
weight_lbs = float(weight_raw)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=f'Invalid set token: {token}') from exc
|
||||
sets.append({'reps': reps, 'weight_lbs': weight_lbs})
|
||||
if not sets:
|
||||
raise HTTPException(status_code=400, detail='Each workout exercise needs at least one set.')
|
||||
exercises.append({'exercise_name': exercise_name, 'notes': notes, 'sets': sets})
|
||||
if not exercises:
|
||||
raise HTTPException(status_code=400, detail='At least one workout exercise is required.')
|
||||
return exercises
|
||||
302
home/doris-barbell/app/services/store.py
Normal file
302
home/doris-barbell/app/services/store.py
Normal file
@@ -0,0 +1,302 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import uuid4
|
||||
|
||||
DEFAULT_STATE = {
|
||||
'users': {
|
||||
'john': {
|
||||
'id': 'john',
|
||||
'display_name': 'John',
|
||||
'is_stub': False,
|
||||
'measurement_system': 'imperial',
|
||||
'height_inches': 68.5,
|
||||
'goal_weight_lbs': None,
|
||||
'notes': 'Seeded with John default height assumption from current intake.',
|
||||
},
|
||||
'manndra': {
|
||||
'id': 'manndra',
|
||||
'display_name': 'Manndra',
|
||||
'is_stub': True,
|
||||
'measurement_system': 'imperial',
|
||||
'height_inches': None,
|
||||
'goal_weight_lbs': None,
|
||||
'notes': 'Stubbed for future shared use.',
|
||||
},
|
||||
},
|
||||
'exercise_templates': [],
|
||||
'routines': [],
|
||||
'weight_entries': [],
|
||||
'measurement_entries': [],
|
||||
'workout_sessions': [],
|
||||
}
|
||||
|
||||
|
||||
class JSONStore:
|
||||
def __init__(self, state_dir: Path) -> None:
|
||||
self.state_dir = Path(state_dir)
|
||||
self.state_path = self.state_dir / 'state.json'
|
||||
self.state_dir.mkdir(parents=True, exist_ok=True)
|
||||
if not self.state_path.exists():
|
||||
self._write(deepcopy(DEFAULT_STATE))
|
||||
|
||||
def _read(self) -> dict[str, Any]:
|
||||
return json.loads(self.state_path.read_text())
|
||||
|
||||
def _write(self, payload: dict[str, Any]) -> None:
|
||||
self.state_path.write_text(json.dumps(payload, indent=2, sort_keys=True))
|
||||
|
||||
def update_profile(self, user_id: str, changes: dict[str, Any]) -> dict[str, Any]:
|
||||
state = self._read()
|
||||
user = state['users'].get(user_id)
|
||||
if user is None:
|
||||
raise KeyError(user_id)
|
||||
for key, value in changes.items():
|
||||
if value is not None:
|
||||
user[key] = value
|
||||
state['users'][user_id] = user
|
||||
self._write(state)
|
||||
return user
|
||||
|
||||
def add_weight_entry(self, user_id: str, entry: dict[str, Any]) -> dict[str, Any]:
|
||||
state = self._read()
|
||||
user = self._user_or_raise(state, user_id)
|
||||
saved = {
|
||||
'id': uuid4().hex,
|
||||
'user_id': user_id,
|
||||
'recorded_at': entry['recorded_at'],
|
||||
'weight_lbs': entry['weight_lbs'],
|
||||
'body_fat_percent': entry.get('body_fat_percent'),
|
||||
'notes': entry.get('notes'),
|
||||
'bmi': _calculate_bmi(entry['weight_lbs'], user.get('height_inches')),
|
||||
}
|
||||
state['weight_entries'].append(saved)
|
||||
self._write(state)
|
||||
return saved
|
||||
|
||||
def weight_history(self, user_id: str) -> list[dict[str, Any]]:
|
||||
state = self._read()
|
||||
self._user_or_raise(state, user_id)
|
||||
return _history_for_user(state['weight_entries'], user_id, 'recorded_at')
|
||||
|
||||
def add_measurement_entry(self, user_id: str, entry: dict[str, Any]) -> dict[str, Any]:
|
||||
state = self._read()
|
||||
self._user_or_raise(state, user_id)
|
||||
saved = {
|
||||
'id': uuid4().hex,
|
||||
'user_id': user_id,
|
||||
'recorded_at': entry['recorded_at'],
|
||||
'waist_inches': entry.get('waist_inches'),
|
||||
'hip_inches': entry.get('hip_inches'),
|
||||
'chest_inches': entry.get('chest_inches'),
|
||||
'neck_inches': entry.get('neck_inches'),
|
||||
'notes': entry.get('notes'),
|
||||
}
|
||||
state['measurement_entries'].append(saved)
|
||||
self._write(state)
|
||||
return saved
|
||||
|
||||
def measurement_history(self, user_id: str) -> list[dict[str, Any]]:
|
||||
state = self._read()
|
||||
self._user_or_raise(state, user_id)
|
||||
return _history_for_user(state['measurement_entries'], user_id, 'recorded_at')
|
||||
|
||||
def add_exercise_template(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
state = self._read()
|
||||
saved = {
|
||||
'id': uuid4().hex,
|
||||
'name': payload['name'],
|
||||
'primary_muscle': payload.get('primary_muscle'),
|
||||
'equipment': payload.get('equipment'),
|
||||
'notes': payload.get('notes'),
|
||||
}
|
||||
state['exercise_templates'].append(saved)
|
||||
self._write(state)
|
||||
return saved
|
||||
|
||||
def list_exercise_templates(self) -> list[dict[str, Any]]:
|
||||
state = self._read()
|
||||
return sorted(state['exercise_templates'], key=lambda item: item['name'].lower())
|
||||
|
||||
def add_routine(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
state = self._read()
|
||||
self._user_or_raise(state, payload['user_id'])
|
||||
saved = {
|
||||
'id': uuid4().hex,
|
||||
'user_id': payload['user_id'],
|
||||
'name': payload['name'],
|
||||
'notes': payload.get('notes'),
|
||||
'exercises': [dict(exercise) for exercise in payload['exercises']],
|
||||
}
|
||||
state['routines'].append(saved)
|
||||
self._write(state)
|
||||
return saved
|
||||
|
||||
def list_routines(self) -> list[dict[str, Any]]:
|
||||
state = self._read()
|
||||
return sorted(state['routines'], key=lambda item: item['name'].lower())
|
||||
|
||||
def add_workout(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
state = self._read()
|
||||
self._user_or_raise(state, payload['user_id'])
|
||||
|
||||
set_count = 0
|
||||
total_volume_lbs = 0.0
|
||||
exercises: list[dict[str, Any]] = []
|
||||
for exercise in payload['exercises']:
|
||||
normalized_sets = []
|
||||
for item in exercise['sets']:
|
||||
set_count += 1
|
||||
total_volume_lbs += item['reps'] * item['weight_lbs']
|
||||
normalized_sets.append(dict(item))
|
||||
exercises.append({
|
||||
'exercise_name': exercise['exercise_name'],
|
||||
'notes': exercise.get('notes'),
|
||||
'sets': normalized_sets,
|
||||
})
|
||||
|
||||
saved = {
|
||||
'id': uuid4().hex,
|
||||
'user_id': payload['user_id'],
|
||||
'performed_at': payload['performed_at'],
|
||||
'routine_name': payload['routine_name'],
|
||||
'notes': payload.get('notes'),
|
||||
'exercise_count': len(exercises),
|
||||
'set_count': set_count,
|
||||
'total_volume_lbs': int(total_volume_lbs) if total_volume_lbs.is_integer() else total_volume_lbs,
|
||||
'exercises': exercises,
|
||||
}
|
||||
state['workout_sessions'].append(saved)
|
||||
self._write(state)
|
||||
return saved
|
||||
|
||||
def workout_history(self, user_id: str) -> list[dict[str, Any]]:
|
||||
state = self._read()
|
||||
self._user_or_raise(state, user_id)
|
||||
return _history_for_user(state['workout_sessions'], user_id, 'performed_at')
|
||||
|
||||
def exercise_progression(self, user_id: str) -> list[dict[str, Any]]:
|
||||
state = self._read()
|
||||
self._user_or_raise(state, user_id)
|
||||
progression: dict[str, dict[str, Any]] = {}
|
||||
for workout in _history_for_user(state['workout_sessions'], user_id, 'performed_at'):
|
||||
for exercise in workout['exercises']:
|
||||
name = exercise['exercise_name']
|
||||
stats = progression.setdefault(
|
||||
name,
|
||||
{
|
||||
'exercise_name': name,
|
||||
'sessions': 0,
|
||||
'set_count': 0,
|
||||
'max_weight_lbs': 0.0,
|
||||
'best_set_estimated_1rm': 0.0,
|
||||
'last_performed_at': workout['performed_at'],
|
||||
},
|
||||
)
|
||||
stats['sessions'] += 1
|
||||
if workout['performed_at'] > stats['last_performed_at']:
|
||||
stats['last_performed_at'] = workout['performed_at']
|
||||
for item in exercise['sets']:
|
||||
stats['set_count'] += 1
|
||||
stats['max_weight_lbs'] = max(stats['max_weight_lbs'], item['weight_lbs'])
|
||||
stats['best_set_estimated_1rm'] = max(
|
||||
stats['best_set_estimated_1rm'],
|
||||
_estimated_1rm(item['weight_lbs'], item['reps']),
|
||||
)
|
||||
results = []
|
||||
for item in progression.values():
|
||||
results.append(
|
||||
{
|
||||
**item,
|
||||
'max_weight_lbs': _normalize_number(item['max_weight_lbs']),
|
||||
'best_set_estimated_1rm': _normalize_number(item['best_set_estimated_1rm']),
|
||||
}
|
||||
)
|
||||
return sorted(results, key=lambda item: item['exercise_name'].lower())
|
||||
|
||||
def dashboard_summary(self) -> dict[str, Any]:
|
||||
state = self._read()
|
||||
users = []
|
||||
weight_entries = state['weight_entries']
|
||||
measurement_entries = state['measurement_entries']
|
||||
for user in state['users'].values():
|
||||
latest_weight = _latest_entry_for_user(weight_entries, user['id'])
|
||||
latest_measurements = _latest_entry_for_user(measurement_entries, user['id'])
|
||||
users.append({
|
||||
'id': user['id'],
|
||||
'display_name': user['display_name'],
|
||||
'is_stub': user['is_stub'],
|
||||
'measurement_system': user.get('measurement_system', 'imperial'),
|
||||
'height_inches': user['height_inches'],
|
||||
'goal_weight_lbs': user['goal_weight_lbs'],
|
||||
'current_weight_lbs': latest_weight['weight_lbs'] if latest_weight else None,
|
||||
'current_bmi': latest_weight['bmi'] if latest_weight else None,
|
||||
'last_weight_recorded_at': latest_weight['recorded_at'] if latest_weight else None,
|
||||
'latest_measurements': _trim_measurement_entry(latest_measurements),
|
||||
})
|
||||
|
||||
recent_workouts = sorted(
|
||||
state['workout_sessions'],
|
||||
key=lambda item: item['performed_at'],
|
||||
reverse=True,
|
||||
)[:5]
|
||||
return {
|
||||
'users': users,
|
||||
'recent_workouts': recent_workouts,
|
||||
'exercise_templates': self.list_exercise_templates()[:5],
|
||||
'routines': self.list_routines()[:5],
|
||||
'counts': {
|
||||
'exercise_templates': len(state['exercise_templates']),
|
||||
'measurement_entries': len(state['measurement_entries']),
|
||||
'routines': len(state['routines']),
|
||||
'weight_entries': len(state['weight_entries']),
|
||||
'workout_sessions': len(state['workout_sessions']),
|
||||
},
|
||||
}
|
||||
|
||||
def _user_or_raise(self, state: dict[str, Any], user_id: str) -> dict[str, Any]:
|
||||
user = state['users'].get(user_id)
|
||||
if user is None:
|
||||
raise KeyError(user_id)
|
||||
return user
|
||||
|
||||
|
||||
def _latest_entry_for_user(entries: list[dict[str, Any]], user_id: str) -> dict[str, Any] | None:
|
||||
matches = [entry for entry in entries if entry['user_id'] == user_id]
|
||||
if not matches:
|
||||
return None
|
||||
return max(matches, key=lambda item: item['recorded_at'])
|
||||
|
||||
|
||||
def _history_for_user(entries: list[dict[str, Any]], user_id: str, sort_key: str) -> list[dict[str, Any]]:
|
||||
matches = [entry for entry in entries if entry['user_id'] == user_id]
|
||||
return sorted(matches, key=lambda item: item[sort_key], reverse=True)
|
||||
|
||||
|
||||
def _trim_measurement_entry(entry: dict[str, Any] | None) -> dict[str, Any] | None:
|
||||
if entry is None:
|
||||
return None
|
||||
return {
|
||||
'recorded_at': entry['recorded_at'],
|
||||
'waist_inches': entry['waist_inches'],
|
||||
'hip_inches': entry['hip_inches'],
|
||||
'chest_inches': entry['chest_inches'],
|
||||
'neck_inches': entry['neck_inches'],
|
||||
}
|
||||
|
||||
|
||||
def _normalize_number(value: float) -> int | float:
|
||||
return int(value) if float(value).is_integer() else round(value, 1)
|
||||
|
||||
|
||||
def _estimated_1rm(weight_lbs: float, reps: int) -> float:
|
||||
return weight_lbs * (1 + reps / 30)
|
||||
|
||||
|
||||
def _calculate_bmi(weight_lbs: float, height_inches: float | None) -> float | None:
|
||||
if not height_inches:
|
||||
return None
|
||||
return 703 * weight_lbs / (height_inches * height_inches)
|
||||
266
home/doris-barbell/app/static/app.css
Normal file
266
home/doris-barbell/app/static/app.css
Normal file
@@ -0,0 +1,266 @@
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--hf-night: #090b10;
|
||||
--hf-panel: rgba(17, 21, 29, 0.94);
|
||||
--hf-panel-raise: rgba(25, 31, 43, 0.96);
|
||||
--hf-paper: #f2efdd;
|
||||
--hf-muted: #cbbda7;
|
||||
--hf-line: rgba(242, 239, 221, 0.12);
|
||||
--hf-shadow: 0 20px 48px rgba(0, 0, 0, 0.34);
|
||||
--hf-red: #d53600;
|
||||
--hf-red-deep: #910f3f;
|
||||
--hf-amber: #f2c14e;
|
||||
--hf-blue: #7b8fb2;
|
||||
--bg: #090b10;
|
||||
--panel: var(--hf-panel);
|
||||
--panel-border: var(--hf-line);
|
||||
--text: var(--hf-paper);
|
||||
--muted: var(--hf-muted);
|
||||
--accent: var(--hf-red);
|
||||
--accent-2: var(--hf-amber);
|
||||
--field: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: Inter, system-ui, sans-serif;
|
||||
background:
|
||||
radial-gradient(circle at top left, rgba(213, 54, 0, 0.22), transparent 22rem),
|
||||
radial-gradient(circle at top right, rgba(123, 143, 178, 0.16), transparent 20rem),
|
||||
linear-gradient(180deg, #07090d 0%, #0d1017 52%, #131824 100%);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.incident-tape {
|
||||
height: 14px;
|
||||
background: repeating-linear-gradient(135deg, var(--hf-amber) 0 18px, #111 18px 36px);
|
||||
box-shadow: 0 3px 14px rgba(0, 0, 0, 0.32);
|
||||
}
|
||||
|
||||
.page-header,
|
||||
.page-shell {
|
||||
width: min(1100px, calc(100% - 2rem));
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.casefile-header {
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
padding: 1.25rem 0 1rem;
|
||||
}
|
||||
|
||||
.brand-row,
|
||||
.casefile-title-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.nav-brand { display: grid; gap: 3px; }
|
||||
.nav-kicker,
|
||||
.eyebrow {
|
||||
margin: 0 0 0.45rem;
|
||||
color: var(--hf-amber);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.16em;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.nav-links { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
|
||||
.nav-link,
|
||||
.pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
padding: 0.55rem 0.85rem;
|
||||
border: 1px solid var(--panel-border);
|
||||
text-decoration: none;
|
||||
background: rgba(255,255,255,.04);
|
||||
color: var(--text);
|
||||
font-size: .88rem;
|
||||
}
|
||||
.nav-link:hover { border-color: rgba(242, 193, 78, 0.58); background: rgba(242, 193, 78, 0.12); }
|
||||
.brand-badges { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.hot-fuzz-art {
|
||||
position: relative;
|
||||
flex: 0 1 320px;
|
||||
min-width: min(100%, 280px);
|
||||
}
|
||||
.poster-illustration {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.35));
|
||||
}
|
||||
.poster-frame { fill: rgba(10, 12, 18, 0.88); stroke: rgba(242, 239, 221, 0.2); stroke-width: 2; }
|
||||
.poster-halo { fill: url(#barbell-sunset); opacity: 0.9; }
|
||||
.poster-tape { fill: rgba(242, 193, 78, 0.88); stroke: rgba(17, 17, 17, 0.8); stroke-width: 2; }
|
||||
.constable-silhouette { fill: rgba(8, 10, 15, 0.92); stroke: rgba(242, 239, 221, 0.12); stroke-width: 1.5; }
|
||||
.constable-silhouette.partner { fill: rgba(24, 30, 42, 0.94); }
|
||||
.swan-stamp { fill: rgba(123, 143, 178, 0.2); stroke: rgba(242, 239, 221, 0.42); stroke-width: 2; }
|
||||
.swan-mark { fill: rgba(242, 239, 221, 0.94); }
|
||||
.poster-callout { fill: rgba(242, 239, 221, 0.82); font-size: 18px; font-weight: 800; letter-spacing: 0.24em; text-anchor: middle; }
|
||||
.recipe-card,
|
||||
.folder-body,
|
||||
.folder-tab,
|
||||
.barbell-bar,
|
||||
.plate-outer,
|
||||
.plate-inner { fill: rgba(242, 239, 221, 0.9); }
|
||||
.plate-inner { fill: rgba(10, 12, 18, 0.72); }
|
||||
.film-grain,
|
||||
.cinematic-glow {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
border-radius: 28px;
|
||||
}
|
||||
.film-grain {
|
||||
background: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 5px), repeating-linear-gradient(90deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 4px);
|
||||
mix-blend-mode: soft-light;
|
||||
opacity: 0.35;
|
||||
}
|
||||
.cinematic-glow {
|
||||
background: radial-gradient(circle at 16% 18%, rgba(123, 143, 178, 0.22), transparent 24%), radial-gradient(circle at 84% 24%, rgba(213, 54, 0, 0.24), transparent 26%), linear-gradient(115deg, rgba(242, 193, 78, 0.05), transparent 40%, rgba(145, 15, 63, 0.1) 78%, transparent 100%);
|
||||
animation: emergencyPulse 8s ease-in-out infinite alternate;
|
||||
}
|
||||
.app-casefile { position: relative; overflow: hidden; isolation: isolate; }
|
||||
.casefile-stamp {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin: 0 0 0.85rem;
|
||||
padding: 0.35rem 0.7rem;
|
||||
border: 1px solid rgba(242, 193, 78, 0.45);
|
||||
border-radius: 999px;
|
||||
color: #ffe5b0;
|
||||
background: rgba(242, 193, 78, 0.1);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.16em;
|
||||
font-size: 0.72rem;
|
||||
}
|
||||
.app-casefile-barbell .casefile-stamp { box-shadow: 0 0 0 1px rgba(213, 54, 0, 0.12), 0 0 28px rgba(145, 15, 63, 0.2); }
|
||||
@keyframes emergencyPulse {
|
||||
0% { opacity: 0.72; transform: scale(1); }
|
||||
50% { opacity: 0.92; transform: scale(1.015); }
|
||||
100% { opacity: 0.78; transform: scale(1.03); }
|
||||
}
|
||||
.badge-hotfuzz { background: linear-gradient(135deg, var(--hf-red), var(--hf-red-deep)); color: #fff4ea; border-color: transparent; }
|
||||
|
||||
h1 { margin: 0; font-size: clamp(2.4rem, 5vw, 4rem); line-height: .94; letter-spacing: -.04em; }
|
||||
h2 { margin-bottom: 0.75rem; }
|
||||
h3 { margin-bottom: 0.5rem; }
|
||||
.lede,
|
||||
.muted,
|
||||
.hint { color: var(--muted); }
|
||||
|
||||
.grid { display: grid; gap: 1rem; }
|
||||
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
|
||||
.compact-grid { gap: 0.75rem; }
|
||||
|
||||
.card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--panel-border);
|
||||
border-radius: 20px;
|
||||
padding: 1rem;
|
||||
box-shadow: var(--hf-shadow);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.card::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0 auto auto 0;
|
||||
width: 100%;
|
||||
height: 4px;
|
||||
background: linear-gradient(90deg, var(--hf-red), var(--hf-amber), var(--hf-blue));
|
||||
}
|
||||
.card h2,
|
||||
.card h3,
|
||||
.card p { margin-top: 0; }
|
||||
.metric-value { font-size: 2rem; font-weight: 700; }
|
||||
.list { list-style: none; padding: 0; margin: 0; }
|
||||
.list li + li { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
|
||||
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; background: rgba(242, 193, 78, 0.18); color: var(--hf-amber); font-size: 0.8rem; }
|
||||
.stack-form { display: grid; gap: 0.75rem; }
|
||||
.stack-form label { display: grid; gap: 0.35rem; font-size: 0.95rem; }
|
||||
input, select, textarea, button {
|
||||
width: 100%;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: var(--field);
|
||||
color: var(--text);
|
||||
padding: 0.8rem 0.9rem;
|
||||
font: inherit;
|
||||
}
|
||||
textarea { resize: vertical; }
|
||||
button {
|
||||
background: linear-gradient(135deg, var(--hf-red) 0%, var(--hf-red-deep) 100%);
|
||||
color: #fff4ea;
|
||||
border: none;
|
||||
font-weight: 700;
|
||||
}
|
||||
button:hover { filter: brightness(1.05); cursor: pointer; }
|
||||
button:focus, input:focus, select:focus, textarea:focus { outline: 2px solid rgba(242, 193, 78, 0.45); outline-offset: 1px; }
|
||||
.history-block + .history-block { margin-top: 1.25rem; }
|
||||
.hint { margin: -0.35rem 0 0; font-size: 0.9rem; }
|
||||
.evidence-board,
|
||||
.evidence-card,
|
||||
.evidence-slab,
|
||||
.intake-docket { position: relative; }
|
||||
.dossier-grid { align-items: stretch; }
|
||||
.case-legend {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.case-legend::after {
|
||||
content: 'FOR THE GREATER GOOD';
|
||||
font-size: 0.67rem;
|
||||
letter-spacing: 0.16em;
|
||||
color: rgba(242, 193, 78, 0.7);
|
||||
}
|
||||
.evidence-board::after,
|
||||
.evidence-card::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 14px;
|
||||
border: 1px dashed rgba(242, 193, 78, 0.09);
|
||||
border-radius: 16px;
|
||||
pointer-events: none;
|
||||
}
|
||||
.case-list li { padding-left: 18px; position: relative; }
|
||||
.case-list li::before { content: '•'; position: absolute; left: 0; color: var(--hf-amber); }
|
||||
.intake-docket {
|
||||
background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
|
||||
border: 1px solid rgba(242, 239, 221, 0.06);
|
||||
border-radius: 18px;
|
||||
padding: 14px;
|
||||
}
|
||||
.evidence-slab {
|
||||
background: rgba(255, 255, 255, 0.035);
|
||||
border: 1px solid var(--panel-border);
|
||||
border-radius: 16px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.page-header,
|
||||
.page-shell {
|
||||
width: min(100% - 1rem, 1100px);
|
||||
}
|
||||
|
||||
.brand-row,
|
||||
.casefile-title-row {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.hot-fuzz-art {
|
||||
flex-basis: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
69
home/doris-barbell/app/templates/base.html
Normal file
69
home/doris-barbell/app/templates/base.html
Normal file
@@ -0,0 +1,69 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ title or 'Doris Barbell' }}</title>
|
||||
<link rel="stylesheet" href="/static/app.css?v=4">
|
||||
</head>
|
||||
<body class="doris-hot-fuzz app-barbell">
|
||||
<div class="incident-tape" aria-hidden="true"></div>
|
||||
<header class="page-header casefile-header app-casefile app-casefile-barbell">
|
||||
<div class="film-grain" aria-hidden="true"></div>
|
||||
<div class="cinematic-glow" aria-hidden="true"></div>
|
||||
<div class="brand-row">
|
||||
<div class="nav-brand">
|
||||
<span class="nav-kicker">N.W.A. Case File</span>
|
||||
<strong>Doris Constabulary</strong>
|
||||
</div>
|
||||
<nav class="nav-links" aria-label="Doris Barbell navigation">
|
||||
<a class="nav-link" href="http://10.5.1.16:8787/">Dashboard</a>
|
||||
<a class="nav-link" href="http://10.5.1.16:8092/">Kitchen</a>
|
||||
<a class="nav-link" href="https://schoolhouse.paccoco.com">Schoolhouse</a>
|
||||
<a class="nav-link" href="/">Barbell</a>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="casefile-title-row">
|
||||
<div>
|
||||
<p class="eyebrow">Station training desk</p>
|
||||
<div class="casefile-stamp barbell-evidence-tag">Training Dossier</div>
|
||||
<h1>Doris Barbell</h1>
|
||||
<p class="lede">Reps, weight, BMI, and body metrics now look like a proper performance dossier instead of generic gym CRUD.</p>
|
||||
<div class="brand-badges" aria-label="Theme badges">
|
||||
<span class="pill badge-hotfuzz">For the Greater Good</span>
|
||||
<span class="pill">Evidence locker: reps</span>
|
||||
<span class="pill">Case type: Training Dossier</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hot-fuzz-art" aria-hidden="true">
|
||||
<svg viewBox="0 0 320 220" class="poster-illustration" role="presentation">
|
||||
<defs>
|
||||
<linearGradient id="barbell-sunset" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#f2c14e"></stop>
|
||||
<stop offset="50%" stop-color="#d53600"></stop>
|
||||
<stop offset="100%" stop-color="#910f3f"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect x="8" y="8" width="304" height="204" rx="24" class="poster-frame"></rect>
|
||||
<circle cx="228" cy="72" r="58" class="poster-halo"></circle>
|
||||
<path d="M18 170 L112 100 L134 124 L40 198 Z" class="poster-tape tape-left"></path>
|
||||
<path d="M202 82 L302 32 L314 60 L214 112 Z" class="poster-tape tape-right"></path>
|
||||
<path d="M112 180 C110 150 116 126 132 110 C140 100 148 94 154 90 C160 94 168 100 176 110 C192 126 198 150 196 180 Z" class="constable-silhouette lead"></path>
|
||||
<path d="M174 184 C172 154 178 132 194 118 C202 110 210 104 218 100 C226 104 234 110 242 118 C258 132 264 154 262 184 Z" class="constable-silhouette partner"></path>
|
||||
<circle cx="84" cy="60" r="28" class="swan-stamp"></circle>
|
||||
<path d="M76 64 C80 54 91 48 101 53 C93 52 88 57 89 63 C90 69 101 68 103 76 C94 78 83 76 78 69 L71 76 L66 71 L74 64 Z" class="swan-mark"></path>
|
||||
<rect x="122" y="110" width="86" height="8" rx="4" class="barbell-bar"></rect>
|
||||
<circle cx="120" cy="114" r="16" class="plate-outer"></circle>
|
||||
<circle cx="120" cy="114" r="8" class="plate-inner"></circle>
|
||||
<circle cx="210" cy="114" r="16" class="plate-outer"></circle>
|
||||
<circle cx="210" cy="114" r="8" class="plate-inner"></circle>
|
||||
<text x="160" y="204" class="poster-callout">TRAINING DOSSIER</text>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main class="page-shell">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
290
home/doris-barbell/app/templates/dashboard.html
Normal file
290
home/doris-barbell/app/templates/dashboard.html
Normal file
@@ -0,0 +1,290 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<section class="grid cols-2 evidence-board dossier-grid">
|
||||
<article class="card evidence-card">
|
||||
<div class="case-legend">
|
||||
<span class="section-label">Training floor board</span>
|
||||
<span class="pill">Training Dossier</span>
|
||||
</div>
|
||||
<h2>Current body metrics</h2>
|
||||
<div class="grid dossier-grid">
|
||||
{% for user in summary.users %}
|
||||
<section class="evidence-slab">
|
||||
<h3>{{ user.display_name }} {% if user.is_stub %}<span class="badge">stub</span>{% endif %}</h3>
|
||||
<p class="metric-value">{{ user.current_weight_lbs if user.current_weight_lbs is not none else '—' }}{% if user.current_weight_lbs is not none %} lb{% endif %}</p>
|
||||
<p class="muted">BMI: {{ '%.1f'|format(user.current_bmi) if user.current_bmi is not none else 'Not set yet' }}</p>
|
||||
<p class="muted">System: {{ user.measurement_system }}</p>
|
||||
{% if user.latest_measurements %}
|
||||
<p class="muted">
|
||||
Waist {{ user.latest_measurements.waist_inches or '—' }} in ·
|
||||
Hips {{ user.latest_measurements.hip_inches or '—' }} in ·
|
||||
Chest {{ user.latest_measurements.chest_inches or '—' }} in ·
|
||||
Neck {{ user.latest_measurements.neck_inches or '—' }} in
|
||||
</p>
|
||||
{% else %}
|
||||
<p class="muted">No body measurements logged yet.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="card evidence-card">
|
||||
<div class="case-legend">
|
||||
<span class="section-label">Case priorities</span>
|
||||
<span class="pill">Operator notes</span>
|
||||
</div>
|
||||
<h2>V1 focus</h2>
|
||||
<ul class="list case-list">
|
||||
<li>Structured workout logging with routines and exercises.</li>
|
||||
<li>Body-weight, BMI, waist/hip/chest/neck history in imperial units.</li>
|
||||
<li>Recent workouts, volume trends, and simple PR tracking.</li>
|
||||
</ul>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="grid cols-2 dossier-grid">
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Intake docket</span><span class="pill">Weight log</span></div>
|
||||
<h2>Log weight</h2>
|
||||
<form class="stack-form intake-docket" method="post" action="/log/weight">
|
||||
<label>User
|
||||
<select name="user_id">
|
||||
{% for user in summary.users %}
|
||||
<option value="{{ user.id }}" {% if user.id == 'john' %}selected{% endif %}>{{ user.display_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>Recorded at
|
||||
<input type="datetime-local" name="recorded_at" required>
|
||||
</label>
|
||||
<div class="grid cols-2 compact-grid">
|
||||
<label>Weight (lb)
|
||||
<input type="number" name="weight_lbs" min="0" step="0.1" required>
|
||||
</label>
|
||||
<label>Body fat %
|
||||
<input type="number" name="body_fat_percent" min="0" max="100" step="0.1">
|
||||
</label>
|
||||
</div>
|
||||
<label>Notes
|
||||
<textarea name="notes" rows="2" placeholder="Morning weigh-in, post-workout, etc."></textarea>
|
||||
</label>
|
||||
<button type="submit">Save weight entry</button>
|
||||
</form>
|
||||
</article>
|
||||
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Intake docket</span><span class="pill">Measurements</span></div>
|
||||
<h2>Log body measurements</h2>
|
||||
<form class="stack-form intake-docket" method="post" action="/log/measurements">
|
||||
<input type="hidden" name="user_id" value="john">
|
||||
<label>Recorded at
|
||||
<input type="datetime-local" name="recorded_at" required>
|
||||
</label>
|
||||
<div class="grid cols-2 compact-grid">
|
||||
<label>Waist (in)
|
||||
<input type="number" name="waist_inches" min="0" step="0.1">
|
||||
</label>
|
||||
<label>Hips (in)
|
||||
<input type="number" name="hip_inches" min="0" step="0.1">
|
||||
</label>
|
||||
<label>Chest (in)
|
||||
<input type="number" name="chest_inches" min="0" step="0.1">
|
||||
</label>
|
||||
<label>Neck (in)
|
||||
<input type="number" name="neck_inches" min="0" step="0.1">
|
||||
</label>
|
||||
</div>
|
||||
<label>Notes
|
||||
<textarea name="notes" rows="2" placeholder="Flexed, relaxed, baseline, etc."></textarea>
|
||||
</label>
|
||||
<button type="submit">Save measurement entry</button>
|
||||
</form>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="grid cols-2 dossier-grid">
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Exercise library</span><span class="pill">Template intake</span></div>
|
||||
<h2>Add exercise template</h2>
|
||||
<form class="stack-form intake-docket" method="post" action="/templates">
|
||||
<label>Name
|
||||
<input type="text" name="name" placeholder="Bench Press" required>
|
||||
</label>
|
||||
<div class="grid cols-2 compact-grid">
|
||||
<label>Primary muscle
|
||||
<input type="text" name="primary_muscle" placeholder="Chest">
|
||||
</label>
|
||||
<label>Equipment
|
||||
<input type="text" name="equipment" placeholder="Barbell">
|
||||
</label>
|
||||
</div>
|
||||
<label>Notes
|
||||
<textarea name="notes" rows="3" placeholder="Technique cue, setup reminder, variation notes."></textarea>
|
||||
</label>
|
||||
<button type="submit">Add template</button>
|
||||
</form>
|
||||
</article>
|
||||
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Routine intake</span><span class="pill">Draft split</span></div>
|
||||
<h2>Build routine draft</h2>
|
||||
<form class="stack-form intake-docket" method="post" action="/routines">
|
||||
<input type="hidden" name="user_id" value="john">
|
||||
<label>Routine name
|
||||
<input type="text" name="name" placeholder="Push Day Draft" required>
|
||||
</label>
|
||||
<label>Exercise lines
|
||||
<textarea name="exercise_lines" rows="6" placeholder="Bench Press|4|6-8 Incline Dumbbell Press|3|8-10 Triceps Pushdown|3|12-15" required></textarea>
|
||||
</label>
|
||||
<p class="hint">Format: exercise | target sets | target reps | optional notes</p>
|
||||
<label>Notes
|
||||
<textarea name="notes" rows="2" placeholder="Temporary until the real split gets entered."></textarea>
|
||||
</label>
|
||||
<button type="submit">Save routine draft</button>
|
||||
</form>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="grid cols-2 dossier-grid">
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Workout report</span><span class="pill">Quick log</span></div>
|
||||
<h2>Quick log workout</h2>
|
||||
<form class="stack-form intake-docket" method="post" action="/workouts/quick-log">
|
||||
<input type="hidden" name="user_id" value="john">
|
||||
<label>Workout name
|
||||
<input type="text" name="routine_name" placeholder="Push Day" required>
|
||||
</label>
|
||||
<label>Performed at
|
||||
<input type="datetime-local" name="performed_at" required>
|
||||
</label>
|
||||
<label>Exercise lines
|
||||
<textarea name="exercise_lines" rows="6" placeholder="Bench Press|8@135, 8@145 Incline Dumbbell Press|10@50, 8@55|Last set close to failure" required></textarea>
|
||||
</label>
|
||||
<p class="hint">Format: exercise | reps@weight, reps@weight | optional notes</p>
|
||||
<label>Notes
|
||||
<textarea name="notes" rows="2" placeholder="Energy, pain, wins, misses."></textarea>
|
||||
</label>
|
||||
<button type="submit">Save workout</button>
|
||||
</form>
|
||||
</article>
|
||||
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Library snapshot</span><span class="pill">Scaffold</span></div>
|
||||
<h2>Template and routine scaffold</h2>
|
||||
<p class="muted">You can start building the library now, even before the real split lands tomorrow.</p>
|
||||
<ul class="list case-list">
|
||||
<li>Exercise templates: {{ summary.counts.exercise_templates }}</li>
|
||||
<li>Routines: {{ summary.counts.routines }}</li>
|
||||
</ul>
|
||||
{% if summary.exercise_templates %}
|
||||
<p><strong>Templates</strong></p>
|
||||
<ul class="list">
|
||||
{% for template in summary.exercise_templates %}
|
||||
<li>{{ template.name }}{% if template.equipment %} · {{ template.equipment }}{% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if summary.routines %}
|
||||
<p><strong>Routines</strong></p>
|
||||
<ul class="list">
|
||||
{% for routine in summary.routines %}
|
||||
<li>{{ routine.name }} · {{ routine.exercises|length }} exercises</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="grid cols-2 dossier-grid">
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Recent logs</span><span class="pill">Session reports</span></div>
|
||||
<h2>Recent workouts</h2>
|
||||
{% if john_workout_history %}
|
||||
<ul class="list">
|
||||
{% for workout in john_workout_history %}
|
||||
<li>
|
||||
<strong>{{ workout.routine_name }}</strong>
|
||||
<p class="muted">{{ workout.performed_at }} · {{ workout.set_count }} sets · {{ workout.total_volume_lbs }} lb volume</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="muted">No workouts logged yet.</p>
|
||||
{% endif %}
|
||||
</article>
|
||||
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">History snapshot</span><span class="pill">John file</span></div>
|
||||
<h2>John history snapshot</h2>
|
||||
<div class="history-block">
|
||||
<h3>Recent weights</h3>
|
||||
{% if john_weight_history %}
|
||||
<ul class="list">
|
||||
{% for entry in john_weight_history %}
|
||||
<li>{{ entry.recorded_at }} · {{ entry.weight_lbs }} lb{% if entry.bmi is not none %} · BMI {{ '%.1f'|format(entry.bmi) }}{% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="muted">No weight entries yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="history-block">
|
||||
<h3>Recent measurements</h3>
|
||||
{% if john_measurement_history %}
|
||||
<ul class="list">
|
||||
{% for entry in john_measurement_history %}
|
||||
<li>{{ entry.recorded_at }} · Waist {{ entry.waist_inches or '—' }} · Chest {{ entry.chest_inches or '—' }} · Hips {{ entry.hip_inches or '—' }} · Neck {{ entry.neck_inches or '—' }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="muted">No measurement entries yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="grid cols-2 dossier-grid">
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Current counts</span><span class="pill">Inventory</span></div>
|
||||
<h2>Current counts</h2>
|
||||
<ul class="list case-list">
|
||||
<li>Workout sessions: {{ summary.counts.workout_sessions }}</li>
|
||||
<li>Weight entries: {{ summary.counts.weight_entries }}</li>
|
||||
<li>Measurement entries: {{ summary.counts.measurement_entries }}</li>
|
||||
<li>Exercise templates: {{ summary.counts.exercise_templates }}</li>
|
||||
<li>Routines: {{ summary.counts.routines }}</li>
|
||||
</ul>
|
||||
</article>
|
||||
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Exercise bests</span><span class="pill">PR board</span></div>
|
||||
<h2>Exercise bests</h2>
|
||||
{% if john_progression %}
|
||||
<ul class="list">
|
||||
{% for entry in john_progression %}
|
||||
<li>
|
||||
<strong>{{ entry.exercise_name }}</strong>
|
||||
<p class="muted">{{ entry.sessions }} sessions · max {{ entry.max_weight_lbs }} lb · est 1RM {{ entry.best_set_estimated_1rm }} lb</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="muted">No exercise progression data yet.</p>
|
||||
{% endif %}
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="grid cols-2 dossier-grid">
|
||||
<article class="card evidence-board">
|
||||
<div class="case-legend"><span class="section-label">Next likely build</span><span class="pill">Open casework</span></div>
|
||||
<h2>Next likely build</h2>
|
||||
<ul class="list case-list">
|
||||
<li>Replace placeholder routines with John’s real day-by-day program tomorrow.</li>
|
||||
<li>Routine-specific workout entry flow driven directly from the saved split.</li>
|
||||
<li>Exercise progression and PR views.</li>
|
||||
</ul>
|
||||
</article>
|
||||
</section>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user