Spaces:
Running on T4
Running on T4
File size: 153,848 Bytes
fe40b87 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 | # Cognivision Baseball — Backend Implementation Specification
## New APIs and changes only
**Prepared:** 30 October 2026
**Audience:** Backend engineers, frontend engineers, QA, product owner
**Basis:** Repository commit `38e9bba6dfdca35053e4377dffedc2434a330c72`, inspected working tree; supplied incomplete draft.
**Status:** Evidence-based implementation proposal. Proposed contracts are not deployed API guarantees. Decisions explicitly marked **Requires Clarification** must be resolved before the affected behavior is released.
## Contents
1. Scope, evidence and corrections
2. Application structure and affected journeys
3. Frontend-to-API mapping
4. Contract conventions and authorization
5. Changes to existing APIs and backend behavior
6. Detailed new endpoint specifications
7. Suggested data model and relationships
8. Integration workflows and background processing
9. Frontend integration work
10. Clarification register
11. Implementation order and acceptance criteria
12. Consolidated API inventory
## 1. Scope, evidence and corrections
This document completes and corrects the supplied “Backend Spec for New APIs.” It covers backend gaps exposed by the current frontend: settings and consent, notifications, conversations, goals, assigned drills, arm care, staff access, academy organization, library content and academy reporting. It does not repeat documentation for unchanged, already-integrated APIs. Existing endpoints appear only when their contract or enforcement must change.
The application is a React Native baseball training app. The affected features extend individual analysis into a player–coach workflow: review a rep, discuss it, prescribe practice, record progress and manage an academy. Player tabs are Home, Progress, Messages and Profile. Coach tabs are Roster, Queue (displayed as Review), Messages and Team. Academy screens are reached through Team.
### 1.1 What the evidence establishes
| Evidence | What it establishes | What it does not establish |
| --- | --- | --- |
| `src/api/endpoints.ts`, `src/api/types.ts`, `backend-docs/openapi.json` | Integrated client operations and checked-in wire schemas | Production deployment status or server internals |
| `src/mock/types.ts`, `endpoints.ts`, `store.ts`, `seed.ts` | Local feature shapes, mutations, example content and missing server integration | Approved business rules, shared persistence, authorization or production data |
| `src/screens/player`, `coach`, `admin` | Visible controls, navigation, data consumers and placeholders | Backend enforcement merely promised in UI copy |
| `src/state/AppContext.tsx`, `useLoad.ts`, `src/mock/useMock.ts` | Account lifecycle, review bridge, screen reload and local mutation subscriptions | Cross-device synchronization |
| `src/navigation/types.ts`, navigators, `src/push/index.ts` | Actual destinations and current notification routing | Generalized routing for new notification types |
Inspection was static. No production requests, device walkthrough or backend database inspection was performed. “Integrated” means wired in this repository, not independently verified live. Source paths in this document are repository-relative identifiers for portability.
### 1.2 Status definitions
- **Mocked:** UI reads/writes local per-account AsyncStorage data. Separate player and coach accounts do not share those changes.
- **Partial:** Some underlying operation is integrated, but the new extension remains mocked or simulated.
- **Placeholder:** A control displays a toast or local UI state without the promised operation.
- **Derived:** The frontend computes a view from available records; a separate endpoint is not automatically necessary.
- **Proposed:** A recommended backend contract, including URL, HTTP method, validation and transaction behavior. These details are explicitly proposals unless described as observed.
- **Requires Clarification:** Product or implementation evidence does not define the behavior sufficiently.
### 1.3 Corrections to the incomplete draft
| Draft assumption | Verified correction and implementation consequence |
| --- | --- |
| Exactly 51 new endpoints are mandatory | This specification proposes **49 primary endpoints**, retains the draft numbers for traceability, and separately describes draft #34 as conditional. Draft #51 duplicates coach-detail activity. Endpoint count is a design proposal, not a fact derived from mock function count. |
| Swapping each mock function body completes integration | Several call signatures lack identity, media and scope information. Screens, models, permissions and reload logic also need changes; see §9. |
| Request client works unchanged | `request()` accepts GET, POST, PATCH and DELETE only. The PUT operations below require adding PUT to its method union. |
| All mock screens are functional | Voice capture/playback, member addition, CSV export, library upload, video export and several sharing choices are simulated or placeholders. |
| Coach assignments are player-specific | `AssignedDrill` contains no player ID; `AssignDrillSheet` receives only a player's first name. Coach list/history/queue queries use the same unscoped assignment list. |
| Current goals automatically produce history and notifications | `goals.save` only replaces the current local entry. Past goals and extra milestones are seeded/static. |
| Academy permissions already work | The live app role is only `player` or `coach`. Team displays “Admin” based on team presence; this is not verified membership authorization. |
| Coach removal reassigns players | A replacement is selected in the sheet, but `removeMember` receives only coach ID and marks that mock member removed. |
| Arm-care rules are age-aware and coaches are alerted | Mock rest thresholds ignore age; limits/innings are seeded. Alert and automatic bullpen-counting claims are not implemented by these mock functions. |
| Report-card recipients and private links work | Every choice calls the same native text share sheet; the selected choice is not used. No private URL is created or email sent by that code. |
| A separate activity endpoint is required | `academy.member` already returns the activity rendered by CoachManage. Keep activity in detail unless independent filtering is later requested. |
| All coaches' data should transfer to the admin on account deletion | This is not an established rule. Team deletion copy says the team is removed and players retain sessions; transfer policy needs a decision. |
| Push registration needs a new target object | New delivery payloads and routing are needed; no new device-registration operation is evidenced. The current router recognizes only a review event and session ID. |
## 2. Application structure and affected journeys
### 2.1 Data architecture
```mermaid
flowchart LR
Screens[Player, coach and academy screens] --> App[AppContext and useLoad]
Screens --> Mock[Current mockApi adapters]
Mock --> Local[Per-user AsyncStorage demo document]
Screens -. proposed replacement .-> API[Authenticated API]
API --> DB[Shared relational data]
API --> Media[Private media storage]
API --> Jobs[Outbox and background workers]
Jobs --> Delivery[Push and email delivery]
DB --> API
API --> Screens
```
The local mock document is initialized during account loading and unloaded on sign-out. It is reset on deletion. It must not become production data: it contains fabricated players, pre-filled notifications, assumed sharing opt-ins and invented financial values. Start new production features from real records or empty states.
`useLoad` generally fetches on mount and focus, but many new screens explicitly set `focus: false`. Local mutations currently trigger `useMockVersion`; a real API call will not trigger that mechanism. No continuous notification polling or websocket subscription was found for these features. Home refreshes its badge as part of loading.
### 2.2 Player journey
1. On account load, obtain authoritative settings, consent and effective academy capabilities. Home reads its current goal, latest thread, unread notification count and, in pitching mode, arm-care data. Existing report-derived sections remain derived.
2. From the bell, list notifications, mark the selected item read and route to its thread, session, month, Drills or ArmCare. Mark-all-read changes only the current user's records.
3. Before choosing/recording a clip, Guide checks consent. Acceptance must succeed before continuing. Withdrawal blocks new analysis server-side; a local timestamp check alone is insufficient.
4. From Progress, display the current goal, genuine historical goal results and supplemental milestones. Calendar/day statistics remain client-derived. Opening ReportCard combines month data with new settings, goals and arm-care reads.
5. From Messages, filter conversations by unread/mode, open a thread and mark viewed messages read. Send text, upload recorded audio or attach an authorized session. A player reply sets the conversation to waiting for the coach.
6. From Drills, open an assignment, increment/decrement the local rep counter, and persist a completed set. Rep-counter taps do not each need an API. The authoritative result updates assignment progress and coach views.
7. From ArmCare, log today's game pitches and report arm feel. Display server-calculated rest state after the domain policy is approved; do not derive a clearance claim from demo text.
8. From Profile, request coach access with a staff code. Show pending, approved or declined/retry state, while preserving player functionality if dual-role access is chosen.
9. From Settings, update sharing and notification choices, withdraw consent, request a video export or delete the account. Native support/legal navigation needs no new API.
### 2.3 Coach and academy journey
1. Roster lists accessible players and available groups. A selected group must actually filter players using stable group IDs.
2. On CoachPlayer, load that player's goal, assignments and the current coach's private note. Message creates/reuses the appropriate conversation. Drill opens the assignment sheet with an actual player ID; Goal opens GoalEdit.
3. Review adds its new conversation/media behavior to the existing review submission. Save review, thread update and notification intent consistently. Navigating to Thread must not depend on a best-effort local write.
4. Queue's Sent section combines review conversation state and assignment progress. Match the exact player/assignment, not just drill name. CoachHistory scopes historical goals and drills to the selected player and mode.
5. AddPlayers searches real academy members and adds selected IDs to the coach's roster, optionally to a group. CreateGroup stores coach and player relationships, not names and a count.
6. Team exposes academy tools only if the membership permits them. StaffCodes creates, copies/shares or revokes a code; copy/share are native actions after the code exists.
7. CoachRequests approves/declines a pending request. Approval creates membership and assigns capability/visibility defaults. CoachManage edits roles/groups/permissions, pauses/resumes access or removes a coach with an explicit replacement.
8. DrillLib reads library metadata; its upload button needs a real picker, upload and metadata form. Consent lists actual consent events and exports a scoped CSV. Dashboard, Earnings and Corporate views require real aggregate definitions rather than seeded numbers.
## 3. Frontend-to-API mapping
`Nxx` refers to §6 endpoint contracts. `Cxx` refers to §5 changes. No new endpoint is proposed merely for rendering a chart, switching tabs, opening a sheet or changing a local filter.
| Screen/component | Action or data requirement | Status now | Required delta |
| --- | --- | --- | --- |
| Home | Goal/weekly targets; unread bell; latest conversation; pitching rest banner | Mocked plus derived | N16, N07, N10, N23; stop duplicating rest rules |
| Notifications | List, select, mark all | Mocked | N06, N08, N09; C05 routing |
| Settings | Sharing/privacy/reminder toggles | Mocked | N01–N02; C07 enforcement |
| Settings | Withdraw consent; download all videos; account deletion | Mocked / placeholder / partial | N04, N05, C06–C07 |
| Guide | Consent check and acceptance before camera/library | Mocked, fails open on errors | N01, N03, C07; fail closed on consent failure |
| Progress (`HistoryScreen`) | Goal, past goals, extra milestones | Mocked | N16, N18, N19; existing charts remain derived |
| Day | Save video to phone | Placeholder | Native file-download/media-save work; no distinct new endpoint established |
| ReportCard | Goals, arm state, sharing settings | Mocked dependencies | N16, N23, N01; month-specific goal lookup needs Q07 decision |
| ReportCard | Parent/coach/other/private-link Send options | Partial: text Share only | Q03; optional delivery/link contracts are not silently included |
| Messages | Threads, unread/mode filters, open assignments | Mocked | N10, N13, N20 |
| Thread | Load/read, text send, voice send/play, share/open session, open drill | Mocked; audio simulated | N11, N13–N14, N20, C02; media URLs and identity-safe drill links |
| Result | Open coach review conversation | Partial | N12, C01 |
| Result | Save video to phone; share card | Placeholder / native text share | Native save implementation; no new API for existing text sharing |
| Drills | Assigned/open/completed list | Mocked | N20 |
| Drill, assigned mode | Find assignment, rep +/-; log set | Mocked | N20, N22; +/- stay local; C08 unifies progress |
| ArmCare | Rest state, outings, feel | Mocked / seeded | N23–N25; Q08 policy and data source |
| Profile | Request/pending/approved coaching access | Mocked | N26–N27, C03 |
| CoachRequest / CoachPending | Submit code; show latest decision | Mocked | N27, N26; add error/declined/approved handling |
| Roster | Group selector | Visual only | N28, C04; apply selected group |
| CoachPlayer | Goal, assignments, note; Message / Drill / Goal buttons | Mocked | N16, N20, N30–N31, N15, N21; pass player ID |
| GoalEdit | Type/metric/target/due/weekly/note; save and history | Mocked | N16–N18 |
| AssignDrillSheet | Catalog/library option; due; assign | Mocked, recipient missing | N35, N21; add player ID and stable source |
| Review | Record/redo/play voice; send review; open thread | Partial | C01–C02, N12; stop fabricated 12-second sends |
| Queue, Sent | Read/replied/drill-done filters | Mocked | N10, N20; assignment identity and server read state |
| CoachThreads | List/open conversations | Mocked | N10, N13 |
| CoachHistory | Goal history, goals, threads, drill totals | Mocked dependencies | N16, N18, N10, N20 scoped to player/mode |
| AddPlayers | Search/select/add/group | Hardcoded / toast | N32–N33, N28 |
| AddPlayers | Invite | Native team-code sharing when team exists; otherwise toast | Q11; conditional N34 only if direct invitations are required |
| CreateGroup | Name/focus, coach/player selections, create | Mocked; sends names/count only | N40, N29; selected IDs required |
| Team | Admin badge/tools; pending request count | Mocked role assumption | C03, N44; capability-based navigation |
| OwnerDash | KPIs, earnings bars, pending requests, inactive players | Mostly constants | N37; links navigate to existing screens |
| Earnings | Month, YTD, projected, payout history | Constants | N38; Q10 blocks accounting interpretation |
| CorpDash | Locations, activity, improving %, common fixes | Constants | N39; Q01/Q10 cross-location scope |
| CoachRequests | List requests/members/codes; approve/decline/manage | Mocked | N44, N40, N46, N45 |
| StaffCodes | Generate/list/revoke; copy/share | Mocked persistence, native sharing | N46–N48; copy/share require no extra endpoint |
| CoachManage | Detail/activity; role/permissions/groups; pause/resume; remove/reassign | Mocked; selected replacement ignored | N41–N43, N28; activity included in N41 |
| DrillLib | Filter library; upload video | Mocked / toast | N35–N36, C02 |
| Groups | List and open creation | Mocked | N28–N29; no edit/delete controls evidenced |
| Consent | Counts, records and CSV export | Mocked / toast | N49–N50 |
**Scope audit:** Auth/onboarding, EditProfile, Membership, Subject, ContactFrame, Analyzing, Recap, Phase, Metrics, Compare and CardInfo did not establish additional new standalone APIs for this delta. Their unchanged contracts are deliberately omitted. Consent, sharing authorization, deletion and membership changes still affect any existing operation that accesses the newly governed data. Pitching analysis remains gated; branding and multi-video analysis queues are not added to this specification. `skipFilmingGuide` exists in the mock schema but has no consuming screen found; it is not a separately justified API requirement.
## 4. Contract conventions and authorization
### 4.1 Shared request and response rules
All §6 URLs, wrappers, bounds not explicitly observed, and storage choices are **proposed**. This section is part of every endpoint contract.
| Concern | Contract |
| --- | --- |
| Authentication | `Authorization: Bearer <access_token>` for every primary endpoint. Derive actor from token; never accept author, owner or actor role as write authority. |
| JSON | `Accept: application/json`; writes with bodies use `Content-Type: application/json`. snake_case wire keys, mapped explicitly to camelCase screen types. |
| IDs | Existing entity UUIDs; examples use valid illustrative UUIDs. Never use seeded IDs or display names as production keys. Resolve academy scope from validated active membership (Q01). |
| Body fields | Only fields explicitly listed as writable are accepted. Other model fields are read-only; reject unknown fields. PATCH changes specified fields only; omitted is not null. |
| Dates | UTC RFC3339 instants; date-only `YYYY-MM-DD`; months `YYYY-MM`. Resolve calendar-day boundaries using a persisted user/academy IANA timezone after Q06. |
| List pagination | Proposed `limit` integer 1–100, default 50; optional opaque `cursor`; response `{items: [...], next_cursor: null or string}`. Stable order with ID tie-breaker. Screens must follow cursors or implement pagination. |
| GET bodies | None. Only documented queries accepted. All path IDs are required, validated and authorization-scoped. |
| Read operations | No domain writes except optional internal access logs. Reads must not automatically mark content read. |
| Empty data | List: 200 with empty items. Optional current goal: 200 with `goal:null`. No note: 200 with `text:""`. Missing/deleted thread: 404. Unavailable aggregate: null with reason, never fabricated zero. |
| Idempotency | Required proposal for POST mutations N03, N05, N14–N15, N21–N22, N24, N27, N29, N33, N36, N45, N47, N50. Persist actor + operation + key + payload hash and response transactionally. Same key/body replays result; different body gives 409. Proposed retention 24 hours, confirm operational policy. |
| Read markers | Naturally idempotent. N13 uses last-seen message ID to avoid clearing a concurrently arriving message. N09 uses a read-through timestamp. |
| Successful deletion/read mark | 204 with no body. POST creation generally 201, queued work 202, mutation returning an existing resource 200. Endpoint-specific exceptions follow. |
| Errors | JSON error envelope below; client also accepts FastAPI `detail` validation errors. Include safe message and `X-Request-ID`. |
| Common failures | 401 `UNAUTHENTICATED`; 403 `FORBIDDEN` for a forbidden capability; 404 `NOT_FOUND` for absent/inaccessible resource IDs; 422 `VALIDATION`; 429 `RATE_LIMITED`; 500/503 operational failure. These apply to every endpoint as relevant, in addition to listed domain errors. |
| Concurrency | Lock rows for bounded counters, code redemption, decisions and reassignment. Proposed `expected_version` on editable resources prevents silent lost updates; mismatch 409 `STALE_VERSION`. |
| Media | Return short-lived authorized read URLs, not object keys or public bucket URLs. Bind uploads to actor, purpose, size and validated content. Attaching an upload requires verification that bytes exist. |
```json
{
"error": {
"code": "VALIDATION",
"message": "Some fields are not valid.",
"fields": {"text": "Must contain 1 to 500 characters."}
}
}
```
```json
{
"error": {
"code": "STALE_VERSION",
"message": "This item changed. Refresh and try again."
}
}
```
### 4.2 Effective authorization model — proposed, Q01/Q02 required
| Actor | Allowed scope |
| --- | --- |
| Player | Own settings, consent, notifications, authorized conversations, goals, assignments and arm-care records. Cannot set coach goals or manufacture reviews. |
| Active coach | Only academy players granted through roster/groups or `sees_all`; operation also needs its permission. Session sharing consent remains applicable. |
| Assistant coach | Same scoped visibility; review/message allowed by effective permissions. Mock rules force drill and goal writes off. |
| Academy admin | Academy management and academy reports; no automatic access to other academies or other coaches' private notes. |
| Corporate viewer | Explicit approved organization/location grant; not implied by ordinary academy admin. Existing role representation is undefined. |
| Paused/removed member | No academy-derived access, including with an older unexpired token. Personal player access is a separate capability decision. |
Mock permission rules are inconsistent with the UI's phrase “Full access”: updating to Admin forces only earnings and sees-all true; Assistant forces goals/drills false. **Recommendation:** define one server-owned role/capability policy and return effective permissions; do not infer every checkbox default from the label. Last-admin removal/demotion and self-removal safeguards require Q12.
Every resource query and nested attachment lookup must enforce tenant and player scope. A valid UUID, client-selected group, client-supplied `from`, or visible menu is not authorization. Private notes should be keyed by coach and player, not merely by player as in the mock.
## 5. Changes to existing APIs and backend behavior
These are delta specifications, not documentation of unchanged operations. All new fields below are proposed additions. Additive response fields are backwards-compatible; newly enforced consent and visibility rules are behavior changes requiring rollout coordination.
### C01 — Review submission and review representation — Critical
**Affected:** `POST /v1/sessions/{session_id}/review`; review objects returned in session responses.
Add optional `voice_note_upload_id: UUID|null`, `voice_note_seconds: positive number|null`. If an attachment is supplied, validate its uploader, purpose, actual media metadata and allowed duration. Prefer returning verified duration rather than trusting the client. Proposed response addition: `thread_id: UUID`; review addition: nullable `voice_note: {upload_id, seconds, url, expires_at}`. Omitted voice fields preserve the prior attachment on review update; explicit null removes it. This distinction must be reflected in schemas.
```json
{
"cue": "Keep the hands back as the front foot lands.",
"drill_id": "hit_13",
"verdicts": {"stride_relative_length": "agree"},
"voice_note_upload_id": "70000000-0000-4000-8000-000000000001",
"voice_note_seconds": 12
}
```
Example additive success response (200; media URL illustrative):
```json
{
"review": {
"coach_id": "80000000-0000-4000-8000-000000000001",
"coach_name": "Jamie K.",
"cue": "Keep the hands back as the front foot lands.",
"drill_id": "hit_13",
"verdicts": {"stride_relative_length": "agree"},
"at": "2026-10-30T09:00:00Z",
"voice_note": {
"upload_id": "70000000-0000-4000-8000-000000000001",
"seconds": 12,
"url": "https://media.example.com/audio/read?token=temporary",
"expires_at": "2026-10-30T09:15:00Z"
}
},
"thread_id": "30000000-0000-4000-8000-000000000001"
}
```
The metric ID above is illustrative; actual verdict keys must exist in the session's report. Preserve established verdict validation. In one transaction: authorize review/visibility, save review, create or update the session conversation, upsert its review message, advance activity/unread state, and append a unique notification/outbox event. Return the committed thread ID. A retry must not create another thread or duplicate notification. Proposed unique session thread policy awaits Q04. Review updates preserve ordinary replies. The review card is a representation of the stored review, not a client-postable `kind:review` message.
The client currently posts the review, then locally calls `upsertReview`, then may send a fake voice message. Replace this chain with the authoritative response. Do not create both an attached voice note and a duplicate voice bubble. A review's drill reference is not currently a persisted drill assignment; whether review submission creates one requires Q05.
**Errors:** Common errors; 409 media not ready/concurrent version; 422 invalid attachment or verdict. **Acceptance:** reviewing from one coach account produces one corresponding thread visible in the player's account, including genuine playable audio if attached.
### C02 — Upload purposes and media read data — Critical
**Affected:** `POST /v1/uploads`; new audio/library consumers.
Extend `kind` from the checked-in video/thumbnail options to proposed `audio` and `drill_video`. Preserve `content_type`, `size_bytes`, optional `duration_sec`, and the complete existing upload response including **`expires_at`**. Do not omit that field as the earlier draft did.
```json
{"kind":"audio","content_type":"audio/mp4","size_bytes":184320,"duration_sec":12}
```
Response retains the existing upload envelope; example URL is illustrative:
```json
{
"upload_id": "70000000-0000-4000-8000-000000000001",
"url": "https://media.example.com/audio/upload?token=temporary",
"headers": {"Content-Type": "audio/mp4"},
"expires_at": "2026-10-30T09:15:00Z"
}
```
Audio recording formats, allowed MIME/container pairs, byte cap and duration cap are **Requires Clarification Q13**. A 5 MB/120-second audio cap is a possible recommendation, not a current limit. Drill-video length need not equal analysis-clip length; teaching content may differ. Validate bytes after PUT, prevent attaching another account's upload, and clean up unattached objects after a documented retention window. Library uploads require academy library-write authority; audio requires a valid messaging/review capability.
Return authorized media playback metadata through N11/N14 and N35/N36. Refresh expired read URLs by refetching the authorized resource; no separate media endpoint is required by this proposal. Incomplete upload: 409 `UPLOAD_NOT_READY`; wrong MIME/size/purpose: 422 (or 413 for excessive bytes under agreed transport policy).
### C03 — Account capability/membership projection — Critical
**Affected:** `GET /v1/me` response.
Proposed additions:
```json
{
"academy": {
"id":"20000000-0000-4000-8000-000000000001",
"name":"Northside Baseball",
"role":"coach",
"status":"active",
"sees_all":false,
"group_ids":["60000000-0000-4000-8000-000000000001"],
"permissions":{"review":true,"drills":true,"goals":true,"library":false,"earnings":false}
},
"coach_access":{"status":"approved","code":null,"sent_at":"2026-10-30T09:00:00Z"},
"capabilities":{"player":true,"coach":true,"academy_admin":false,"corporate_view":false}
}
```
`academy` may be null. Enum mapping from API `admin|coach|assistant` to current display labels is explicit. Preserve existing account fields; never derive membership from team presence. A single `academy` assumes one active academy context; multi-academy selection requires Q01. Dual-role navigation needs frontend work because root navigation and thread authorship currently use one role. Do not silently convert a player account and lose its personal workflow.
### C04 — Roster group membership and scoped views — High
**Affected:** `GET /v1/coach/roster` items; existing coach data authorization.
Add `group_ids: UUID[]`, empty when none. Return IDs that correspond to N28. Enforce effective membership visibility and consent on coach reads and writes. The UI currently changes its group selector but never applies that selection; implement filtering. Preserve the existing exclusion of body data from roster objects. The demo member list contains age; that is not evidence to weaken the roster privacy rule.
### C05 — New notification production, payload and routing — High
**Affected:** backend notification delivery and `src/push/index.ts`; device registration itself has no demonstrated schema change.
New in-app kinds already modeled: `review`, `drill`, `armcare`, `result`, `report`. Use one domain event to create a notification and schedule delivery; honor relevant preferences at dispatch. FCM data values need a transport representation; proposed string fields are `notification_id`, `kind`, and `target_json` containing serialized N06 target. Preserve old review/session routing during rollout.
```json
{"notification_id":"50000000-0000-4000-8000-000000000001","kind":"review","target_json":"{\"thread_id\":\"30000000-0000-4000-8000-000000000001\"}"}
```
Parse/validate allowed target keys, queue a tap until authenticated navigation is ready, and reauthorize the destination on fetch. Push may arrive after deletion, sign-out, consent change or membership revocation. Handle inaccessible targets with a safe unavailable view. Goal updates, staff decisions, generic messages and weekly reminders do not have complete kind/target definitions; Q09 must resolve them rather than mislabeling everything as a review.
### C06 — Account/session deletion and membership cleanup — High
**Affected:** `DELETE /v1/me`, `DELETE /v1/sessions/{session_id}` and new related tables/media.
Account deletion must remove or anonymize associated settings, personal notifications, personal consent projections, goals/assignments owned by the player, arm-care records, access requests and personal attachments according to an agreed retention policy. Revoke export/share artifacts and cancel unsent deliveries. Joint conversation/history and consent-audit retention require Q12; do not blindly delete a whole shared conversation or transfer private notes.
Deleting a session must also remove access to its media and handle thread/session-card references consistently (recommended tombstone with no remaining media link, or cascade after product approval). Coach account deletion and academy coach removal are different actions. Existing Team copy promises removal of the team while players retain their sessions; resolve this against academy succession before shipping. Do not automatically hand private notes to an admin as the draft proposed.
### C07 — Enforce settings and consent beyond preference storage — Critical
**Affected:** existing analysis admission, media authorization and coach access checks; new background jobs.
N04 withdrawal promises no new analysis while retaining saved data. Check effective consent at analysis admission and define in-flight-job handling. Guide currently catches consent-read/write errors and proceeds; change that behavior. Consent for filming another person/younger athletes and whose acceptance applies is Q14, not implicitly solved by a signed-in account's timestamp.
`coach_can_see_sessions=false` must affect server reads, media URLs and review access, not just hiding links. Define precedence with the existing privacy flag and access to historical messages in Q03. `clips_as_examples` and `help_improve_ai` require independent recorded opt-ins and downstream data-use enforcement. This document does not assert the deployment's encryption/storage geography simply because Settings copy does.
### C08 — Assigned-set contribution to progress — High
**Affected:** existing drill-log schema/reads and N22 transaction.
Home/Progress/ReportCard derive practice totals from existing drill logs, whereas mock assignment completion only increments `done`. Recommended change: add nullable `assignment_id` to drill-log records and produce one compatible log per completed assignment set in the same transaction as N22. Alternatively change every aggregate consumer to combine event sources exactly once; do not do both. Confirm library drill-ID support in the existing log schema. Keep report-drill logs and assignment sets distinguishable. Q05 covers review-generated assignments and partial-set semantics.
## 6. Detailed new endpoint specifications
Every endpoint below inherits §4 headers, common errors, pagination, ownership validation and casing rules. Explicit body fields are required unless labeled optional. Response examples show the full proposed resource shape for that endpoint; list examples use one item and `next_cursor:null` for brevity. Values are illustrative, not production records or approved financial/health rules.
The IDs retain the incomplete draft's numbering so teams can reconcile tickets. N34 and N51 are not primary endpoints; they are discussed after the primary contracts.
### Settings and consent
#### N01 — Read effective settings
`GET /v1/me/settings`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Settings, Guide, ReportCard; settings.get
**Authorization:** Signed-in account; own record
**Parameters and writable fields:** No query or body.
**Success:** 200.
```json
{
"settings": {
"coach_can_see_sessions": true,
"share_with_parent": false,
"parent_email": null,
"auto_monthly_report": false,
"private_links": false,
"clips_as_examples": false,
"help_improve_ai": false,
"notify_results": true,
"notify_coach": true,
"notify_drills": true,
"notify_weekly": true,
"consented_at": null,
"consent_version": null,
"skip_filming_guide": false,
"version": 1
}
}
```
**Backend processing / persistence:** Read settings plus effective consent projection. For an unconfigured account return agreed safe defaults; do not copy demo parent details. Read-only projection may use defaults without creating rows.
**Validation and additional errors:** Response booleans are non-null. parent_email and consented_at/version are nullable strings; version is integer. Q03 decides sharing defaults and parent setup.
**Frontend success/failure integration:** Unwrap settings, map case, show retry on failure; Guide must not bypass failed consent reads.
**Dependencies / unresolved decisions:** C07; Q03/Q14
#### N02 — Update preferences
`PATCH /v1/me/settings`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Settings toggle; settings.update
**Authorization:** Signed-in account; own record
**Parameters and writable fields:** Body: one or more writable booleans from N01; optional expected_version integer. parent_email optional string/null only after recipient policy is approved. consented_at, consent_version, version are read-only.
**Request example:**
```json
{
"share_with_parent": false,
"auto_monthly_report": false,
"expected_version": 1
}
```
**Success:** 200.
```json
{
"settings": {
"coach_can_see_sessions": true,
"share_with_parent": false,
"parent_email": null,
"auto_monthly_report": false,
"private_links": false,
"clips_as_examples": false,
"help_improve_ai": false,
"notify_results": true,
"notify_coach": true,
"notify_drills": true,
"notify_weekly": true,
"consented_at": null,
"consent_version": null,
"skip_filming_guide": false,
"version": 2
}
}
```
**Backend processing / persistence:** Upsert preferences atomically; turning parent sharing off also clears automatic reporting. Record AI/example opt-in changes as auditable events. Re-evaluate future deliveries and relevant access.
**Validation and additional errors:** Strict booleans; email format if supplied. Reject auto_monthly_report=true without enabled sharing and an approved recipient (422). 409 version conflict. Proposed default all optional external sharing off; Q03 required.
**Frontend success/failure integration:** Use returned canonical values; rollback optimistic toggle on failure. Current local draft can hide the server-reset auto-report toggle.
**Dependencies / unresolved decisions:** N01; C07; Q03
#### N03 — Record consent acceptance
`POST /v1/me/consent`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Guide agreement; settings.consent
**Authorization:** Signed-in consenting account; subject/guardian policy Q14
**Parameters and writable fields:** Body: version string and accepted boolean literal true. Server timestamps and binds actor; no client consent timestamp.
**Request example:**
```json
{
"version": "1.0",
"accepted": true
}
```
**Success:** 201; replay returns original result.
```json
{
"consent": {
"version": "1.0",
"accepted_at": "2026-10-30T09:00:00Z",
"withdrawn_at": null
}
}
```
**Backend processing / persistence:** Append consent event and update effective projection atomically. Keep AI training and example-use opt-ins separate. Duplicate idempotent attempts create one event.
**Validation and additional errors:** Version must be a supported policy version, not arbitrary text. 409 TERMS_CHANGED for obsolete version; 422 accepted=false. Current UI hardcodes version 1.0; version distribution needs Q14.
**Frontend success/failure integration:** Wait for confirmed acceptance before opening camera/library. Do not swallow errors.
**Dependencies / unresolved decisions:** N01; C07; Q14
#### N04 — Withdraw analysis consent
`DELETE /v1/me/consent`
**Priority / current status:** High / Mocked
**Frontend trigger:** Settings confirmation; settings.withdrawConsent
**Authorization:** Signed-in account; own consent
**Parameters and writable fields:** No body/query.
**Success:** 204, including repeated withdrawal.
No response body.
**Backend processing / persistence:** Append withdrawal event once for current acceptance, clear effective consent, block future analysis admission. Retain saved sessions per UI promise. Cancel or gate queued work according to Q14.
**Validation and additional errors:** No active acceptance is a successful no-op. Common errors apply. Do not delete all history when withdrawing.
**Frontend success/failure integration:** Clear local effective consent only after success; show error/retry otherwise.
**Dependencies / unresolved decisions:** N03; C07; Q14
#### N05 — Request all-video export
`POST /v1/me/exports`
**Priority / current status:** Low / Placeholder
**Frontend trigger:** Settings Download all my videos; no mock function
**Authorization:** Signed-in account; export only owned media
**Parameters and writable fields:** Body: scope literal videos. Recipient is verified account email; not client-selected.
**Request example:**
```json
{
"scope": "videos"
}
```
**Success:** 202.
```json
{
"export": {
"id": "60000000-0000-4000-8000-000000000001",
"status": "queued",
"requested_at": "2026-10-30T09:00:00Z",
"delivery": "account_email"
}
}
```
**Backend processing / persistence:** Create export job/outbox record. Worker snapshots eligible objects, builds archive, creates expiring authorized download and emails account. Track failure/retry internally. Deletion cancels job and invalidates output.
**Validation and additional errors:** 409 EXPORT_IN_PROGRESS for another active export unless returning that job; 422 EMAIL_UNAVAILABLE. Rate-limit expensive work. Q15 fixes expiry, delivery, scale and retention.
**Frontend success/failure integration:** Toast only after 202. No progress UI is currently present, so a polling endpoint is not required; failure communication still needs definition.
**Dependencies / unresolved decisions:** C06; Q15; media storage and email worker
### Notifications
#### N06 — List in-app notifications
`GET /v1/notifications`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Notifications; notifications.list
**Authorization:** Signed-in user; own notifications
**Parameters and writable fields:** Optional limit/cursor; newest at then ID descending.
**Success:** 200.
```json
{
"items": [
{
"id": "50000000-0000-4000-8000-000000000001",
"kind": "review",
"title": "Coach Jamie reviewed your swing",
"body": "Open the conversation for your cue.",
"at": "2026-10-30T09:00:00Z",
"read": false,
"target": {
"thread_id": "30000000-0000-4000-8000-000000000001"
}
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Read recipient-scoped notifications; keep invalidated target safe. Derive read from read_at, do not mark read during list.
**Validation and additional errors:** kind enum review/drill/armcare/result/report. target keys thread_id UUID, session_id UUID or month YYYY-MM; proposed at most one destination. Empty target allowed for drill/armcare fallback. Title/body strings, at timestamp, read boolean.
**Frontend success/failure integration:** Map keys; follow pagination; provide empty/error states.
**Dependencies / unresolved decisions:** C05; Q09
#### N07 — Read notification badge
`GET /v1/notifications/unread-count`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Home load; notifications.unreadCount
**Authorization:** Signed-in user; own notifications
**Parameters and writable fields:** No body/query.
**Success:** 200.
```json
{
"count": 2
}
```
**Backend processing / persistence:** Count visible notifications with read_at null using recipient/read index; maintain consistency with list/read operations.
**Validation and additional errors:** count integer >=0. No seeded fallback on error.
**Frontend success/failure integration:** Refresh after reads and on Home focus. Current code is load-based, not a scheduled polling service.
**Dependencies / unresolved decisions:** N06/N08/N09
#### N08 — Mark one notification read
`POST /v1/notifications/{id}/read`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Notification tap; notifications.markRead
**Authorization:** Notification recipient only
**Parameters and writable fields:** Required id UUID; no body.
**Success:** 204.
No response body.
**Backend processing / persistence:** Set read_at if null. Repeat is a no-op. Notification-read state does not implicitly mark the associated conversation read.
**Validation and additional errors:** 404 inaccessible/missing notification; common errors.
**Frontend success/failure integration:** Update badge/list after success; route to target with its own authorization and missing-target handling.
**Dependencies / unresolved decisions:** N06; C05
#### N09 — Mark viewed notification batch read
`POST /v1/notifications/read-all`
**Priority / current status:** High / Mocked
**Frontend trigger:** Notifications Mark all read; notifications.markAllRead
**Authorization:** Signed-in user; own notifications
**Parameters and writable fields:** Body: optional through timestamp. Omitted uses server request-start time.
**Request example:**
```json
{
"through": "2026-10-30T09:00:00Z"
}
```
**Success:** 204.
No response body.
**Backend processing / persistence:** Update unread recipient records with at <= boundary. Records arriving after boundary remain unread. Index recipient/read/created_at.
**Validation and additional errors:** Timestamp must be parseable; future time clamped to server request-start or rejected consistently.
**Frontend success/failure integration:** Pass latest loaded boundary; reload list/count. Current mock call needs a body-aware signature.
**Dependencies / unresolved decisions:** N06/N07
### Conversations
#### N10 — List authorized conversations
`GET /v1/threads`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Messages, Home, CoachThreads, Queue Sent, CoachHistory; threads.list
**Authorization:** Player participant or currently authorized scoped coach
**Parameters and writable fields:** Optional mode h/p, player_id UUID (coach-scoped), unread boolean, limit/cursor. Newest updated_at and ID descending.
**Success:** 200.
```json
{
"items": [
{
"id": "30000000-0000-4000-8000-000000000001",
"mode": "h",
"session_id": "90000000-0000-4000-8000-000000000001",
"session_label": "Swing 12",
"score": 74,
"tone": "y",
"coach_id": "80000000-0000-4000-8000-000000000001",
"coach_name": "Jamie",
"player_id": "10000000-0000-4000-8000-000000000001",
"player_name": "Alex R.",
"status": "reviewed",
"unread_for_player": true,
"unread_for_coach": false,
"updated_at": "2026-10-30T09:00:00Z",
"messages": [
{
"id": "40000000-0000-4000-8000-000000000001",
"author_id": "80000000-0000-4000-8000-000000000001",
"from": "coach",
"kind": "text",
"text": "Try the drill before hitting.",
"at": "2026-10-30T09:00:00Z"
}
],
"next_message_cursor": null
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Join visible conversation/participant state and bounded messages. Initial compatibility response contains messages because Home/Queue/History use them, not only a summary. See Q04 for multi-coach identity and pagination strategy.
**Validation and additional errors:** Do not allow a player to change scope through player_id. Response fields match Thread plus coach_id and message cursor. Null session_id/score supported.
**Frontend success/failure integration:** Case adapter; filter server-side where possible. Queue and CoachHistory need complete review/reply summaries if message pages are bounded; never assume first page is full history.
**Dependencies / unresolved decisions:** C03/C04; Q04
#### N11 — Read conversation and messages
`GET /v1/threads/{id}`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Thread; threads.get
**Authorization:** Authorized participant or scoped coach
**Parameters and writable fields:** Required id; optional message_cursor and message_limit 1–100 (default 50). Proposed latest page returned chronologically; cursor retrieves older page.
**Success:** 200.
```json
{
"thread": {
"id": "30000000-0000-4000-8000-000000000001",
"mode": "h",
"session_id": "90000000-0000-4000-8000-000000000001",
"session_label": "Swing 12",
"score": 74,
"tone": "y",
"coach_id": "80000000-0000-4000-8000-000000000001",
"coach_name": "Jamie",
"player_id": "10000000-0000-4000-8000-000000000001",
"player_name": "Alex R.",
"status": "reviewed",
"unread_for_player": true,
"unread_for_coach": false,
"updated_at": "2026-10-30T09:00:00Z",
"messages": [
{
"id": "40000000-0000-4000-8000-000000000001",
"author_id": "80000000-0000-4000-8000-000000000001",
"from": "coach",
"kind": "text",
"text": "Try the drill before hitting.",
"at": "2026-10-30T09:00:00Z"
}
],
"next_message_cursor": null
}
}
```
**Backend processing / persistence:** Read thread, per-user read state and visible messages; generate authorized URLs for voice content. Return next_message_cursor in thread. Do not clear read state here.
**Validation and additional errors:** 404 missing/inaccessible conversation. Message union defined below N14; mixed ordering stable by server sequence.
**Frontend success/failure integration:** Load older messages explicitly; refresh expired audio URLs through this read; wire actual playback.
**Dependencies / unresolved decisions:** N10; C02; Q04
#### N12 — Resolve session conversation
`GET /v1/sessions/{session_id}/thread`
**Priority / current status:** Critical / Partial
**Frontend trigger:** Result, Review; threads.forSession
**Authorization:** Authorized session viewer and thread participant/scoped coach
**Parameters and writable fields:** Required session_id; no body/query.
**Success:** 200; 404 when no accessible thread.
```json
{
"thread": {
"id": "30000000-0000-4000-8000-000000000001",
"mode": "h",
"session_id": "90000000-0000-4000-8000-000000000001",
"session_label": "Swing 12",
"score": 74,
"tone": "y",
"coach_id": "80000000-0000-4000-8000-000000000001",
"coach_name": "Jamie",
"player_id": "10000000-0000-4000-8000-000000000001",
"player_name": "Alex R.",
"status": "reviewed",
"unread_for_player": true,
"unread_for_coach": false,
"updated_at": "2026-10-30T09:00:00Z",
"messages": [
{
"id": "40000000-0000-4000-8000-000000000001",
"author_id": "80000000-0000-4000-8000-000000000001",
"from": "coach",
"kind": "text",
"text": "Try the drill before hitting.",
"at": "2026-10-30T09:00:00Z"
}
],
"next_message_cursor": null
}
}
```
**Backend processing / persistence:** Resolve unique session conversation under agreed policy. Existence does not grant session access. No implicit creation on GET.
**Validation and additional errors:** 404 THREAD_NOT_FOUND may be mapped to no review card; do not convert network/500 failures to absence.
**Frontend success/failure integration:** Result conditionally renders thread card. C01 returns thread_id directly after successful review.
**Dependencies / unresolved decisions:** C01; N11; Q04
#### N13 — Advance participant read watermark
`POST /v1/threads/{id}/read`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Open Thread/Messages/CoachThreads; threads.markRead
**Authorization:** Authorized participant; viewer derived from identity
**Parameters and writable fields:** Required id; body last_message_id UUID, nullable for empty thread.
**Request example:**
```json
{
"last_message_id": "40000000-0000-4000-8000-000000000001"
}
```
**Success:** 204.
No response body.
**Backend processing / persistence:** Advance only current participant read sequence monotonically. Do not clear unread for another coach by trusting from/viewer. A message arriving after the supplied ID remains unread.
**Validation and additional errors:** 422 if last_message_id does not belong to thread; 404 inaccessible thread.
**Frontend success/failure integration:** Replace viewer argument with last rendered message ID; update after newly received visible messages.
**Dependencies / unresolved decisions:** N11; Q04
#### N14 — Send text, audio or session attachment
`POST /v1/threads/{id}/messages`
**Priority / current status:** Critical / Mocked; audio simulated
**Frontend trigger:** Thread composer; threads.send
**Authorization:** Player participant or active scoped coach with messaging capability
**Parameters and writable fields:** Required id. Discriminated body: text {kind,text}; voice {kind,upload_id,seconds}; session {kind,session_id}. No client from, score, label or author fields.
**Request example:**
```json
{
"kind": "text",
"text": "Try the drill before hitting."
}
```
**Success:** 201.
```json
{
"message": {
"id": "40000000-0000-4000-8000-000000000001",
"author_id": "80000000-0000-4000-8000-000000000001",
"from": "coach",
"kind": "text",
"text": "Try the drill before hitting.",
"at": "2026-10-30T09:00:00Z"
},
"thread_status": "reviewed",
"updated_at": "2026-10-30T09:00:00Z"
}
```
**Backend processing / persistence:** Insert message, update activity and recipient unread state and notification intent in one transaction. Player send -> waiting_for_coach; coach send -> reviewed as observed (this does not itself create a formal review). Resolve session title/score server-side.
**Validation and additional errors:** Text trimmed length 1–500 observed in Composer. Voice positive seconds + verified owned audio. Session must be visible to all intended recipients and have compatible player/mode; 409 UPLOAD_NOT_READY, 422 invalid variant, 403/404 unauthorized session. kind review forbidden.
**Frontend success/failure integration:** Retain/recover draft on failed send; Composer currently clears early. Record actual audio, upload, attach and play returned media. Attachment picker must scope to thread player, not coach own sessions.
**Dependencies / unresolved decisions:** N11/N13; C02/C05; Q04/Q13
**Additional request/response variants** (same endpoint and success code):
```json
{"kind":"voice","upload_id":"70000000-0000-4000-8000-000000000001","seconds":12}
```
```json
{"message":{"id":"40000000-0000-4000-8000-000000000002","author_id":"10000000-0000-4000-8000-000000000001","from":"player","kind":"voice","seconds":12,"audio":{"upload_id":"70000000-0000-4000-8000-000000000001","seconds":12,"url":"https://media.example.com/audio/read?token=temporary","expires_at":"2026-10-30T09:15:00Z"},"at":"2026-10-30T09:00:00Z"},"thread_status":"waiting_for_coach","updated_at":"2026-10-30T09:00:00Z"}
```
```json
{"kind":"session","session_id":"90000000-0000-4000-8000-000000000001"}
```
```json
{"message":{"id":"40000000-0000-4000-8000-000000000003","author_id":"10000000-0000-4000-8000-000000000001","from":"player","kind":"session","session_id":"90000000-0000-4000-8000-000000000001","label":"Swing 12","score":74,"at":"2026-10-30T09:00:00Z"},"thread_status":"waiting_for_coach","updated_at":"2026-10-30T09:00:00Z"}
```
**Server-produced review message** in N10–N12: common id/author_id/from/at plus `kind:"review"`, cue string, voice_seconds nullable number, audio nullable media object, findings array `{metric_id,name,verdict}`, drill_id/name nullable strings and assignment_id nullable UUID. Verdict enum is agree/change/later. An assignment reference must identify the exact player assignment; it is not inferred from drill name. Review message update semantics follow C01. All messages carry server-authored identity and timestamps.
#### N15 — Resolve or start player conversation
`POST /v1/coach/players/{player_id}/thread`
**Priority / current status:** High / Mocked
**Frontend trigger:** CoachPlayer Message; threads.ensureForPlayer
**Authorization:** Active coach with access to player
**Parameters and writable fields:** Required player_id; body mode h/p.
**Request example:**
```json
{
"mode": "h"
}
```
**Success:** 201 created; 200 existing.
```json
{
"thread": {
"id": "30000000-0000-4000-8000-000000000001",
"mode": "h",
"session_id": null,
"session_label": "Latest session",
"score": null,
"tone": "y",
"coach_id": "80000000-0000-4000-8000-000000000001",
"coach_name": "Jamie",
"player_id": "10000000-0000-4000-8000-000000000001",
"player_name": "Alex R.",
"status": "reviewed",
"unread_for_player": false,
"unread_for_coach": false,
"updated_at": "2026-10-30T09:00:00Z",
"messages": [],
"next_message_cursor": null
}
}
```
**Backend processing / persistence:** Resolve agreed general conversation key transactionally; avoid concurrent duplicates. Mock returns first player/mode match even if session-linked, an ambiguous behavior requiring Q04.
**Validation and additional errors:** 404 inaccessible player; 409 unsupported context if Q04 not configured. Do not use playerName/coachName as identity.
**Frontend success/failure integration:** Navigate to returned thread ID; no fabricated names supplied in write.
**Dependencies / unresolved decisions:** C03/C04; Q04
### Goals and milestones
#### N16 — Read current goal
`GET /v1/players/{player_id}/goals`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** Home, Progress, ReportCard, CoachPlayer, GoalEdit, CoachHistory; goals.get
**Authorization:** Own player or scoped coach
**Parameters and writable fields:** Required player_id and query mode h/p. Optional as_of YYYY-MM-DD is a proposal only after Q07 historical reporting decision.
**Success:** 200; goal null if absent.
```json
{
"goal": {
"id": "60000000-0000-4000-8000-000000000001",
"player_id": "10000000-0000-4000-8000-000000000001",
"mode": "h",
"type": "groups",
"target": 3,
"metric_id": null,
"metric_name": null,
"due": "2 weeks",
"due_at": "2026-11-13T23:59:59Z",
"set_at": "2026-10-30T09:00:00Z",
"set_by": "Jamie",
"set_by_id": "80000000-0000-4000-8000-000000000001",
"note": "Keep the back hip loaded.",
"weekly": {
"practice_days": 4,
"drill_sets": 9
},
"version": 1
}
}
```
**Backend processing / persistence:** Read active goal for player/mode; server resolves author/metric labels. Goal is not fabricated for new users.
**Validation and additional errors:** player_id and mode required. Response numeric target, nullable metric fields, due label and absolute due_at; weekly integers; version integer.
**Frontend success/failure integration:** Map shape; handle absent goal. ReportCard currently asks for current hitting goal even on historical months; fix after Q07.
**Dependencies / unresolved decisions:** C03/C04; Q07
#### N17 — Set or replace goal and weekly targets
`PUT /v1/players/{player_id}/goals/{mode}`
**Priority / current status:** Critical / Mocked
**Frontend trigger:** GoalEdit Save and send; goals.save
**Authorization:** Scoped coach with goals permission; not player
**Parameters and writable fields:** Required player_id/mode. Body type, target, due, weekly; optional metric_id/null, note (default empty), expected_version. Server supplies set_at/set_by.
**Request example:**
```json
{
"type": "groups",
"target": 3,
"metric_id": null,
"due": "2 weeks",
"weekly": {
"practice_days": 4,
"drill_sets": 9
},
"note": "Keep the back hip loaded."
}
```
**Success:** 200 for replacement/upsert.
```json
{
"goal": {
"id": "60000000-0000-4000-8000-000000000001",
"player_id": "10000000-0000-4000-8000-000000000001",
"mode": "h",
"type": "groups",
"target": 3,
"metric_id": null,
"metric_name": null,
"due": "2 weeks",
"due_at": "2026-11-13T23:59:59Z",
"set_at": "2026-10-30T09:00:00Z",
"set_by": "Jamie",
"set_by_id": "80000000-0000-4000-8000-000000000001",
"note": "Keep the back hip loaded.",
"weekly": {
"practice_days": 4,
"drill_sets": 9
},
"version": 1
}
}
```
**Backend processing / persistence:** Lock current player/mode goal, create revision/history when meaningfully changed, resolve due_at using approved timezone, set author and stage delivery intent. Identical payload retry must not create another history entry/notification.
**Validation and additional errors:** Observed types groups/param/score; groups integer 1..actual report group count; score integer 50..100 in UI; param finite -50..500 UI range but metric units/range validation needs Q07. param requires metric_id; other types null. due 1 week/2 weeks/End of month. weekly practice_days 1..7, drill_sets 1..30. note <=160. 409 stale version.
**Frontend success/failure integration:** Add PUT client support; handle backend error before success toast; do not send client author/timestamp.
**Dependencies / unresolved decisions:** N16/N18; C05; Q07/Q09
#### N18 — Read scoped historical goals
`GET /v1/players/{player_id}/goals/history`
**Priority / current status:** High / Mocked seeded history
**Frontend trigger:** Progress, GoalEdit, CoachHistory; goals.past
**Authorization:** Own player or scoped coach
**Parameters and writable fields:** Required player_id; query mode h/p required; optional limit/cursor.
**Success:** 200.
```json
{
"items": [
{
"id": "60000000-0000-4000-8000-000000000001",
"text": "Get 2 of 4 groups on target",
"range": "Oct 1 to Oct 14, 2026",
"met": true,
"outcome": "met",
"start_at": "2026-10-01T09:00:00Z",
"end_at": "2026-10-14T23:59:59Z",
"evaluated_session_id": "90000000-0000-4000-8000-000000000001"
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Read goal revisions and stored evaluation evidence newest first. Replacement alone does not prove success/failure. Need approved evaluation comparator/time-window.
**Validation and additional errors:** Proposed outcome met/not_met/superseded/unknown; met nullable boolean to avoid treating unassessed as failure. Q07 defines history evaluation.
**Frontend success/failure integration:** Change goals.past() to pass player/mode; render unknown/superseded distinctly.
**Dependencies / unresolved decisions:** N17; Q07
#### N19 — Read supplemental progress milestones
`GET /v1/me/milestones`
**Priority / current status:** Medium / Static mock output
**Frontend trigger:** Progress; milestones(mode)
**Authorization:** Signed-in player; own records
**Parameters and writable fields:** Required mode h/p; optional limit/cursor.
**Success:** 200.
```json
{
"items": [
{
"id": "60000000-0000-4000-8000-000000000001",
"icon": "flag",
"tone": "b",
"title": "Goal met: 2 groups on target",
"when": "Oct 14, 2026",
"occurred_at": "2026-10-14T17:00:00Z",
"source_goal_id": "60000000-0000-4000-8000-000000000001"
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Read derived/persisted events with source identity. Deduplicate by milestone rule + source + player. Do not duplicate frontend-derived best score/group improvements.
**Validation and additional errors:** icon trend/check/flag/bolt/heart; tone g/y/r/b; timestamps authoritative, when is display convenience. Rules for goal/streak/rest milestones require Q07/Q08; empty list until evidence exists.
**Frontend success/failure integration:** Remove canned achievements; preserve locally derived real ones; handle no milestones.
**Dependencies / unresolved decisions:** N18/N22; Q07/Q08
### Drill assignments
#### N20 — Read authorized assignments
`GET /v1/drill-assignments`
**Priority / current status:** Critical / Mocked without player identity
**Frontend trigger:** Drills, Drill, Messages, Thread, CoachPlayer, CoachHistory, Queue; assignedDrills.list
**Authorization:** Player own; coach only authorized roster/group scope
**Parameters and writable fields:** Query mode h/p required; optional player_id (coach), status open/completed/all, limit/cursor. Coach absence of player_id means all accessible players, never all academy by default.
**Success:** 200.
```json
{
"items": [
{
"id": "60000000-0000-4000-8000-000000000001",
"player_id": "10000000-0000-4000-8000-000000000001",
"mode": "h",
"drill_id": "hit_13",
"drill_source": "catalog",
"name": "Back-pocket load",
"fixes": "Hip–shoulder separation",
"sets": 3,
"reps": 8,
"due": "Tomorrow",
"due_date": "2026-10-31",
"assigned_by": "Jamie",
"assigned_by_id": "80000000-0000-4000-8000-000000000001",
"done": 0,
"session_id": null,
"assigned_at": "2026-10-30T09:00:00Z",
"media": null
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Read assignments with progress from completed-set events, join source drill content. Include stable player and assignment IDs. Player may not request someone else.
**Validation and additional errors:** sets/reps positive integers; done 0..sets; source catalog/library; due_date absolute. Missing media nullable; deleted source retains agreed snapshot without leaking removed media.
**Frontend success/failure integration:** Change mock signature and all coach consumers to scope by player. Drill lookup must traverse pages or use an agreed ID filter; do not mistake first-page absence for deletion.
**Dependencies / unresolved decisions:** C03/C04/C08; N35; Q05
#### N21 — Assign catalog/library drill
`POST /v1/coach/players/{player_id}/drill-assignments`
**Priority / current status:** Critical / Mocked; recipient not persisted
**Frontend trigger:** AssignDrillSheet from CoachPlayer; assignedDrills.assign
**Authorization:** Active scoped coach with drills permission
**Parameters and writable fields:** Required player_id; body mode, drill_source catalog/library, drill_id, due_date. Optional source_session_id/null. Default sets=3, reps=8 follows mock assign, pending Q05.
**Request example:**
```json
{
"mode": "h",
"drill_source": "catalog",
"drill_id": "hit_13",
"due_date": "2026-10-31"
}
```
**Success:** 201.
```json
{
"assignment": {
"id": "60000000-0000-4000-8000-000000000001",
"player_id": "10000000-0000-4000-8000-000000000001",
"mode": "h",
"drill_id": "hit_13",
"drill_source": "catalog",
"name": "Back-pocket load",
"fixes": "Hip–shoulder separation",
"sets": 3,
"reps": 8,
"due": "Tomorrow",
"due_date": "2026-10-31",
"assigned_by": "Jamie",
"assigned_by_id": "80000000-0000-4000-8000-000000000001",
"done": 0,
"session_id": null,
"assigned_at": "2026-10-30T09:00:00Z",
"media": null
}
}
```
**Backend processing / persistence:** Authorize player and source; snapshot name/fixes, bind actor, insert assignment, notification and outbox. Validate source_session_id belongs to same player. A reused drill assigned twice remains two distinct assignments.
**Validation and additional errors:** Valid mode/source ID; date valid and not before local today (proposed). Source library UUID or catalog ID. 422 mode mismatch; 404 inaccessible drill/player. Client display names and assigned_by are not accepted.
**Frontend success/failure integration:** Pass playerId into sheet; preserve source kind and selected actual due date. Current relative Tomorrow/Saturday/Next week labels need Q06 conversion.
**Dependencies / unresolved decisions:** N20/N35; C05; Q05/Q06
#### N22 — Log assignment set completion
`POST /v1/drill-assignments/{id}/sets`
**Priority / current status:** Critical / Mocked counter only
**Frontend trigger:** Assigned Drill Mark set done; assignedDrills.logSet
**Authorization:** Player owning assignment; coach logging on behalf not evidenced
**Parameters and writable fields:** Required id; body set_number positive integer, reps_done positive integer, day YYYY-MM-DD. Stable Idempotency-Key per tap attempt.
**Request example:**
```json
{
"set_number": 1,
"reps_done": 8,
"day": "2026-10-30"
}
```
**Success:** 201; replay returns original completion.
```json
{
"assignment": {
"id": "60000000-0000-4000-8000-000000000001",
"player_id": "10000000-0000-4000-8000-000000000001",
"mode": "h",
"drill_id": "hit_13",
"drill_source": "catalog",
"name": "Back-pocket load",
"fixes": "Hip–shoulder separation",
"sets": 3,
"reps": 8,
"due": "Tomorrow",
"due_date": "2026-10-31",
"assigned_by": "Jamie",
"assigned_by_id": "80000000-0000-4000-8000-000000000001",
"done": 1,
"session_id": null,
"assigned_at": "2026-10-30T09:00:00Z",
"media": null
},
"set_log": {
"id": "40000000-0000-4000-8000-000000000001",
"set_number": 1,
"reps_done": 8,
"day": "2026-10-30"
}
}
```
**Backend processing / persistence:** Lock assignment; insert unique (assignment,set_number) event and compatible drill log once, update bounded progress, return authoritative assignment. Distinct idempotency keys cannot double-complete same ordinal.
**Validation and additional errors:** 422 set ordinal outside 1..sets, invalid day/reps. 409 already completed ordinal with conflicting values. Current UI allows marking done after one rep; Q05 must decide partial-set policy instead of assuming full target reps.
**Frontend success/failure integration:** Send actual rep count and current ordinal; reset only after success; retain retry key after timeout.
**Dependencies / unresolved decisions:** N20/N21; C08; Q05/Q06
### Arm care
#### N23 — Read outings and rest assessment
`GET /v1/me/arm-care`
**Priority / current status:** High / Mocked seeded limits
**Frontend trigger:** ArmCare, pitching Home, ReportCard; armCare.get
**Authorization:** Signed-in player; own record
**Parameters and writable fields:** No required query. Optional from/to dates for history (proposed; default recent window must be agreed Q08).
**Success:** 200.
```json
{
"arm_care": {
"outings": [],
"feel": "good",
"feel_recorded_at": "2026-10-30T09:00:00Z",
"daily_max": null,
"innings_last_12_months": null,
"innings_limit": null,
"rest_status": "unknown",
"next_eligible_date": null,
"rule_version": null,
"unavailable_reason": "Age-specific policy and innings source not configured"
}
}
```
**Backend processing / persistence:** Read player outings/feel and calculate policy-based assessment only from verified inputs. Unknown age/innings/policy produces unknown, not a zero-risk result.
**Validation and additional errors:** feel sore/tight/good or null for unreported (new nullable state). Counts nullable nonnegative integers where unavailable. rest_status unknown/rest_required/no_rest_due; next_eligible_date nullable. Rule version required when assessment known.
**Frontend success/failure integration:** Replace parsing rest text and duplicate hardcoded thresholds with structured state. Support nullable limits and missing history.
**Dependencies / unresolved decisions:** Q08; N24/N25
#### N24 — Log game pitch count
`POST /v1/me/arm-care/outings`
**Priority / current status:** High / Mocked; coach-alert copy only
**Frontend trigger:** ArmCare Add outing; armCare.addOuting
**Authorization:** Signed-in player; own outing
**Parameters and writable fields:** Body pitches positive integer; optional local_date YYYY-MM-DD defaults today in agreed timezone. Source fixed game for this UI.
**Request example:**
```json
{
"pitches": 45,
"local_date": "2026-10-30"
}
```
**Success:** 201.
```json
{
"outing": {
"id": "60000000-0000-4000-8000-000000000001",
"date": "2026-10-30T09:00:00Z",
"local_date": "2026-10-30",
"label": "Game, logged by you",
"pitches": 45,
"rest": null,
"rest_days": null
},
"arm_care": {
"outings": [
{
"id": "60000000-0000-4000-8000-000000000001",
"date": "2026-10-30T09:00:00Z",
"local_date": "2026-10-30",
"label": "Game, logged by you",
"pitches": 45,
"rest": null,
"rest_days": null
}
],
"feel": "good",
"feel_recorded_at": "2026-10-30T09:00:00Z",
"daily_max": null,
"innings_last_12_months": null,
"innings_limit": null,
"rest_status": "unknown",
"next_eligible_date": null,
"rule_version": null,
"unavailable_reason": "Age-specific policy and innings source not configured"
}
}
```
**Backend processing / persistence:** Insert once; aggregate same-day outings before policy evaluation; recompute rest and violations, stage coach alert only where visibility and approved policy allow. Over-limit observations should be recordable rather than discarded.
**Validation and additional errors:** Strict integer (frontend parseInt is insufficient); sensible technical max requires Q08. Future dates rejected by proposal; date editing not exposed. Do not hardcode age-independent rest thresholds from mock.
**Frontend success/failure integration:** Use returned assessment, not restFor(n), and do not claim alert delivery before it is actually queued.
**Dependencies / unresolved decisions:** N23; C05; Q08/Q09
#### N25 — Record current arm feel
`PUT /v1/me/arm-care/feel`
**Priority / current status:** Medium / Mocked
**Frontend trigger:** ArmCare picker; armCare.setFeel
**Authorization:** Signed-in player; own state
**Parameters and writable fields:** Body feel enum sore/tight/good.
**Request example:**
```json
{
"feel": "tight"
}
```
**Success:** 200.
```json
{
"feel": "tight",
"recorded_at": "2026-10-30T09:00:00Z"
}
```
**Backend processing / persistence:** Upsert current feel, optionally append event history; alert behavior on soreness/repeated updates needs approved policy. Do not report medical clearance from feel alone.
**Validation and additional errors:** 422 invalid enum. Identical retries should not create duplicate alerts.
**Frontend success/failure integration:** Add PUT; update after success and surface error; coach visibility requires scoped delivery/read design Q08.
**Dependencies / unresolved decisions:** N23; C05; Q08
### Coach access
#### N26 — Read coaching-access application
`GET /v1/me/coach-access`
**Priority / current status:** High / Mocked
**Frontend trigger:** Profile, CoachPending; coachAccess.get
**Authorization:** Signed-in applicant; own application
**Parameters and writable fields:** No body/query.
**Success:** 200.
```json
{
"coach_access": {
"status": "pending",
"code": "CV-7K4Q-2M",
"sent_at": "2026-10-30T09:00:00Z"
}
}
```
**Backend processing / persistence:** Read current/most-recent application and effective decision. none returns code/sent_at null. Preserve approved state from actual membership, not local simulation.
**Validation and additional errors:** Proposed status none/pending/approved/declined (declined is missing from current player type). Removal/paused state comes from membership; define reapplication in Q02.
**Frontend success/failure integration:** Add declined/approved branches and refresh account capabilities on approval. CoachPending currently remains a pending-oriented view.
**Dependencies / unresolved decisions:** N27/N45; C03; Q02
#### N27 — Apply using staff code
`POST /v1/me/coach-access`
**Priority / current status:** High / Mocked; no actual validation
**Frontend trigger:** CoachRequest Send; coachAccess.request
**Authorization:** Signed-in applicant; not arbitrary user ID
**Parameters and writable fields:** Body code string; trim/uppercase.
**Request example:**
```json
{
"code": "CV-7K4Q-2M"
}
```
**Success:** 201; 200 if reusing identical pending request.
```json
{
"coach_access": {
"status": "pending",
"code": "CV-7K4Q-2M",
"sent_at": "2026-10-30T09:00:00Z"
}
}
```
**Backend processing / persistence:** Validate code scope/status/expiry/capacity, reserve or consume use per Q02 in transaction, insert request. Auto-approval creates membership immediately with code-controlled role; manual approval stays pending. Never identify applicant by name.
**Validation and additional errors:** Minimum 6 characters observed; proposed max 64. 422 CODE_INVALID; 409 CODE_UNAVAILABLE or REQUEST_PENDING. Avoid exposing other academy data. Rate-limit code guesses.
**Frontend success/failure integration:** Display server error; handle immediate approved result rather than always navigating to pending.
**Dependencies / unresolved decisions:** N46/N47/N45; C03; Q02
### Groups, roster and notes
#### N28 — List visible player groups
`GET /v1/academy/groups`
**Priority / current status:** High / Mocked
**Frontend trigger:** Roster, Groups, AddPlayers, CreateGroup, proposed CoachManage replacement for hardcoded groups; academy.groups
**Authorization:** Active academy membership; visibility-limited for non-admin
**Parameters and writable fields:** Optional limit/cursor.
**Success:** 200.
```json
{
"items": [
{
"id": "60000000-0000-4000-8000-000000000001",
"name": "14U",
"focus": "Both",
"players": 1,
"player_ids": [
"10000000-0000-4000-8000-000000000001"
],
"coaches": [
"Jamie"
],
"coach_ids": [
"80000000-0000-4000-8000-000000000001"
]
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Return real group membership counts and stable IDs. Limit player ID disclosure to caller scope; detailed player_ids may be omitted for count-only consumers, but define projection consistently.
**Validation and additional errors:** focus Hitting/Pitching/Both is observed display enum; explicit mapping to mode/focus. players nonnegative derived count, coaches labels plus coach_ids.
**Frontend success/failure integration:** Use IDs for selection/filtering; do not assume 12U/14U/16U/Varsity fixed groups.
**Dependencies / unresolved decisions:** C03/C04; Q01
#### N29 — Create group and membership
`POST /v1/academy/groups`
**Priority / current status:** High / Mocked names/count only
**Frontend trigger:** CreateGroup Create; academy.createGroup
**Authorization:** Academy admin by conservative proposal; coach creation permission Q01
**Parameters and writable fields:** Body name, focus, coach_ids array, player_ids array.
**Request example:**
```json
{
"name": "14U",
"focus": "Both",
"coach_ids": [
"80000000-0000-4000-8000-000000000001"
],
"player_ids": [
"10000000-0000-4000-8000-000000000001"
]
}
```
**Success:** 201.
```json
{
"group": {
"id": "60000000-0000-4000-8000-000000000001",
"name": "14U",
"focus": "Both",
"players": 1,
"player_ids": [
"10000000-0000-4000-8000-000000000001"
],
"coaches": [
"Jamie"
],
"coach_ids": [
"80000000-0000-4000-8000-000000000001"
]
}
}
```
**Backend processing / persistence:** Insert group and coach/player join rows in one transaction after checking every member belongs to academy and is eligible. Count is derived. Empty selection may mean empty group; never infer members from count.
**Validation and additional errors:** Proposed name trimmed 1–80; enum as N28; deduplicate arrays; UUIDs. 409 duplicate normalized name if academy chooses unique names. Unknown/cross-tenant IDs reject whole request.
**Frontend success/failure integration:** Pass selected IDs; if current coach is preselected, send its ID explicitly. Name/count mock signature must change.
**Dependencies / unresolved decisions:** N28/N40; Q01
#### N30 — Read private coaching note
`GET /v1/coach/players/{player_id}/note`
**Priority / current status:** High / Mocked keyed only by player
**Frontend trigger:** CoachPlayer; academy.note
**Authorization:** Active coach with player access; own note only
**Parameters and writable fields:** Required player_id; no query/body.
**Success:** 200; empty text, null updated_at and version 0 when absent.
```json
{
"note": {
"player_id": "10000000-0000-4000-8000-000000000001",
"text": "Focus on balance before adding speed.",
"updated_at": "2026-10-30T09:00:00Z",
"version": 1
}
}
```
**Backend processing / persistence:** Read by academy + actor coach + player, never by player alone. Admin status does not automatically reveal private notes.
**Validation and additional errors:** 404 inaccessible player; text string, timestamp nullable, version integer.
**Frontend success/failure integration:** Keep unsaved text on read failure; show retry.
**Dependencies / unresolved decisions:** C03/C04; Q12 note ownership
#### N31 — Save private coaching note
`PUT /v1/coach/players/{player_id}/note`
**Priority / current status:** High / Mocked
**Frontend trigger:** CoachPlayer Save note; academy.saveNote
**Authorization:** Same as N30
**Parameters and writable fields:** Required player_id; body text string; optional expected_version.
**Request example:**
```json
{
"text": "Focus on balance before adding speed.",
"expected_version": 0
}
```
**Success:** 200.
```json
{
"note": {
"player_id": "10000000-0000-4000-8000-000000000001",
"text": "Focus on balance before adding speed.",
"updated_at": "2026-10-30T09:00:00Z",
"version": 1
}
}
```
**Backend processing / persistence:** Upsert own scoped note; empty text clears content without deleting player. Server timestamps. Avoid copying private notes during reassignment unless explicitly agreed.
**Validation and additional errors:** Proposed max 4000 chars (not established UI limit); 409 stale version. No client coach ID.
**Frontend success/failure integration:** Add PUT and try/finally/error handling; retain draft on failure.
**Dependencies / unresolved decisions:** N30; Q12
#### N32 — Search players available for roster addition
`GET /v1/academy/members`
**Priority / current status:** Medium / Hardcoded member list
**Frontend trigger:** AddPlayers search; no mock
**Authorization:** Active coach with approved roster-management scope (Q01)
**Parameters and writable fields:** Optional q string 0–100, limit/cursor; excludes players already on caller roster.
**Success:** 200.
```json
{
"items": [
{
"id": "10000000-0000-4000-8000-000000000001",
"name": "Alex R.",
"focus": "h",
"level": "high_school",
"group_ids": [
"60000000-0000-4000-8000-000000000001"
]
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Search academy player membership with visibility rules and existing-roster anti-join. Expose only necessary player identity; do not copy demo ages into this response.
**Validation and additional errors:** Escape/parameterize search; empty query returns scoped first page; no cross-academy global directory.
**Frontend success/failure integration:** Replace MEMBERS constants, debounce search, reset stale selection and handle no results.
**Dependencies / unresolved decisions:** N28; C03/C04; Q01
#### N33 — Add selected academy players
`POST /v1/coach/roster/players`
**Priority / current status:** Medium / Toast only
**Frontend trigger:** AddPlayers Add
**Authorization:** Active authorized coach; own roster or agreed admin workflow
**Parameters and writable fields:** Body player_ids nonempty UUID array; optional group_id/null.
**Request example:**
```json
{
"player_ids": [
"10000000-0000-4000-8000-000000000001"
],
"group_id": "60000000-0000-4000-8000-000000000001"
}
```
**Success:** 200.
```json
{
"added_player_ids": [
"10000000-0000-4000-8000-000000000001"
],
"already_present_player_ids": []
}
```
**Backend processing / persistence:** Validate entire selection first; transactionally insert unique coach/player assignments and optional group membership. Already-present entries are no-ops. Roll back all if any input is unauthorized.
**Validation and additional errors:** Proposed max 100 IDs, no duplicates after normalization; group must be same academy and writable. 404 inaccessible member/group.
**Frontend success/failure integration:** Wait for completion before navigating; reload roster/group counts.
**Dependencies / unresolved decisions:** N32/N28; C04; Q01
### Academy library
#### N35 — Read academy drill library
`GET /v1/academy/library`
**Priority / current status:** High / Mocked metadata
**Frontend trigger:** DrillLib and useDrillOptions; academy.library
**Authorization:** Active academy member with library-read access; write permission separate
**Parameters and writable fields:** Optional mode h/p, fault_tag string, limit/cursor.
**Success:** 200.
```json
{
"items": [
{
"id": "60000000-0000-4000-8000-000000000001",
"name": "Posture wall drill",
"fixes": "Posture",
"fault_tags": [
"posture"
],
"by": "Jamie",
"author_id": "80000000-0000-4000-8000-000000000001",
"mode": "h",
"media": {
"upload_id": "70000000-0000-4000-8000-000000000001",
"url": "https://media.example.com/drill/read?token=temporary",
"expires_at": "2026-10-30T09:15:00Z"
},
"created_at": "2026-10-30T09:00:00Z"
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Read published authorized library metadata and fresh media URLs. Snapshot author display; do not use names as keys. Assigned players may receive allowed content through N20 without broad academy-library browsing.
**Validation and additional errors:** mode enum; tags from approved vocabulary Q13. Missing video nullable for legacy metadata-only content; no fake playback.
**Frontend success/failure integration:** Replace regex-only filters if server filters used; map author/media; assigned Drill needs real video player for library media.
**Dependencies / unresolved decisions:** C02; Q13
#### N36 — Publish uploaded library drill
`POST /v1/academy/library`
**Priority / current status:** Low / Upload toast only
**Frontend trigger:** DrillLib Upload a drill video; no mock
**Authorization:** Active member with library-write permission
**Parameters and writable fields:** Body upload_id UUID, name string, mode h/p, fault_tags string array; optional fixes description.
**Request example:**
```json
{
"upload_id": "70000000-0000-4000-8000-000000000001",
"name": "Posture wall drill",
"mode": "h",
"fault_tags": [
"posture"
],
"fixes": "Posture"
}
```
**Success:** 201 when validated media ready.
```json
{
"drill": {
"id": "60000000-0000-4000-8000-000000000001",
"name": "Posture wall drill",
"fixes": "Posture",
"fault_tags": [
"posture"
],
"by": "Jamie",
"author_id": "80000000-0000-4000-8000-000000000001",
"mode": "h",
"media": {
"upload_id": "70000000-0000-4000-8000-000000000001",
"url": "https://media.example.com/drill/read?token=temporary",
"expires_at": "2026-10-30T09:15:00Z"
},
"created_at": "2026-10-30T09:00:00Z"
}
}
```
**Backend processing / persistence:** Verify uploaded bytes and ownership/purpose, insert academy drill + tags and media reference. Processing must complete before claiming playable publication; if asynchronous processing is needed define status contract first.
**Validation and additional errors:** Proposed name 1–120, fixes <=500, 1–10 tags each <=64; these are design bounds, Q13 required. 409 UPLOAD_NOT_READY; 422 invalid media/tag.
**Frontend success/failure integration:** Implement video picker/title/tag form/upload/publish/retry; button currently has none.
**Dependencies / unresolved decisions:** C02/N35; Q13
### Academy reporting
#### N37 — Read academy dashboard aggregates
`GET /v1/academy/dashboard`
**Priority / current status:** Medium / Mostly fixed constants
**Frontend trigger:** OwnerDash; academy.dashboard
**Authorization:** Active academy admin; financial values require earnings capability
**Parameters and writable fields:** Optional month YYYY-MM (default current academy month).
**Success:** 200.
```json
{
"dashboard": {
"month": "2026-10",
"currency": "USD",
"earnings_minor": 67200,
"paying_players": 112,
"per_player_minor": 600,
"active_players": 112,
"new_this_month": 14,
"improving_pct": 71,
"analyses_this_week": 486,
"avg_review_hours": 9,
"cards": {
"g": 41,
"y": 52,
"r": 19
},
"coaches": [
{
"id": "80000000-0000-4000-8000-000000000001",
"name": "Jamie",
"coaches": "Hitting",
"reviews": 12
}
],
"pending_requests": 1,
"not_filmed_7d": 9,
"earnings_bars": [
{
"month": "2026-09",
"amount_minor": 61800
},
{
"month": "2026-10",
"amount_minor": 67200
}
],
"as_of": "2026-10-30T09:00:00Z"
}
}
```
**Backend processing / persistence:** Aggregate authorized academy membership, activity, review timestamps and approved revenue ledger; snapshot/cache with as_of. Financial source and every denominator/window need Q10; sample numbers mirror scale of demo, not a pricing promise.
**Validation and additional errors:** Counts integer >=0; percentages number 0..100 or null for no denominator; averages nullable. Missing source returns null plus unavailable_reason, not seeded values. Bars are dated amounts, not mock normalized heights.
**Frontend success/failure integration:** Map money units to display, compute bar heights; handle empty bars/null metrics; UI currently assumes nonempty bars.
**Dependencies / unresolved decisions:** N40/N44; Q01/Q10
#### N38 — Read revenue share and payout history
`GET /v1/academy/earnings`
**Priority / current status:** Medium / Fixed constants
**Frontend trigger:** Earnings; academy.earnings
**Authorization:** Active admin with earnings permission
**Parameters and writable fields:** Optional month YYYY-MM; optional limit/cursor for payouts.
**Success:** 200.
```json
{
"earnings": {
"month": "2026-10",
"currency": "USD",
"month_minor": 67200,
"players": 112,
"per_player_minor": 600,
"ytd_minor": 498000,
"projected_minor": 806400,
"as_of": "2026-10-30T09:00:00Z",
"payouts": [
{
"id": "60000000-0000-4000-8000-000000000001",
"scheduled_for": "2026-11-01",
"amount_minor": 67200,
"status": "scheduled",
"paid_at": null
}
],
"next_cursor": null
}
}
```
**Backend processing / persistence:** Read settled/estimated ledger projections, not client subscription counts multiplied by an assumed fixed share. Explain estimate vs booked amount after Q10. No payout-creation endpoint is requested.
**Validation and additional errors:** ISO currency code; integer minor monetary units; status scheduled/paid/failed/cancelled (proposed); null projection when unavailable. Refund/chargeback/tax rules unknown.
**Frontend success/failure integration:** Convert minor units; render estimates/unavailable states; stop hardcoded dollars where currency differs.
**Dependencies / unresolved decisions:** Q10; finance data integration
#### N39 — Read permitted cross-location reporting
`GET /v1/academy/corp`
**Priority / current status:** Low / Fixed constants
**Frontend trigger:** CorpDash; academy.corp
**Authorization:** Explicit corporate/location grant; academy admin alone insufficient
**Parameters and writable fields:** Optional month YYYY-MM; permitted organization inferred from grant Q01.
**Success:** 200.
```json
{
"corporate": {
"month": "2026-10",
"as_of": "2026-10-30T09:00:00Z",
"kpis": {
"locations_live": 1,
"active_players": 112,
"analyses": 486,
"improving_pct": 71
},
"locations": [
{
"id": "20000000-0000-4000-8000-000000000001",
"name": "Northside Baseball",
"active_players": 112,
"improving_pct": 71
}
],
"fixes": [
{
"metric_id": "stride_relative_length",
"label": "Stride relative length",
"mode": "h",
"affected_pct": 29
}
]
}
}
```
**Backend processing / persistence:** Aggregate only granted locations using consistent definitions with N37. Distinct-player counting across locations and fault denominators require Q10.
**Validation and additional errors:** No client-submitted arbitrary academy list. Unknown/absent corporate grant ->403. Metric IDs must come from actual report/catalog data.
**Frontend success/failure integration:** Replace string tuple mock with typed response adapter; hide view without grant.
**Dependencies / unresolved decisions:** N37; C03; Q01/Q10
### Academy staff
#### N40 — List academy coaching members
`GET /v1/academy/coaches`
**Priority / current status:** Medium / Mocked
**Frontend trigger:** CoachRequests, CoachManage, CreateGroup; academy.members
**Authorization:** Active academy member; sensitive fields admin-only by proposal
**Parameters and writable fields:** Optional status active/paused/removed/all; default active and paused; limit/cursor.
**Success:** 200.
```json
{
"items": [
{
"id": "80000000-0000-4000-8000-000000000001",
"name": "Jamie K.",
"coaches": "Hitting",
"joined": "2026-10-30T09:00:00Z",
"joined_with": "CV-7K4Q-2M",
"role": "coach",
"is_me": false,
"sees_all": false,
"group_ids": [
"60000000-0000-4000-8000-000000000001"
],
"permissions": {
"review": true,
"drills": true,
"goals": true,
"library": false,
"earnings": false
},
"activity": {
"reviews": 12,
"avg_reply_hours": 9,
"players": 6,
"drills_set": 8,
"period_start": "2026-10-01",
"period_end": "2026-10-31"
},
"status": "active",
"version": 1
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Read membership and effective permissions; return an allowed projection for group-selection use. is_me derived from current user. Avoid exposing administrative audit fields to ordinary members.
**Validation and additional errors:** Role admin/coach/assistant; status enum. Response maps group_ids to UI selections, not fixed group-name dictionary. activity nullable if unavailable.
**Frontend success/failure integration:** Filter eligible replacement coaches; do not offer paused/removed replacements. Name duplicate is valid; identity UUID unique.
**Dependencies / unresolved decisions:** C03; N28; Q01/Q02
#### N41 — Read coach management detail and activity
`GET /v1/academy/coaches/{id}`
**Priority / current status:** Medium / Mocked, seeded activity
**Frontend trigger:** CoachManage; academy.member
**Authorization:** Academy admin; own limited projection if separately approved
**Parameters and writable fields:** Required membership/coach id as agreed Q01; optional activity_from/activity_to date window, proposed default current month.
**Success:** 200.
```json
{
"coach": {
"id": "80000000-0000-4000-8000-000000000001",
"name": "Jamie K.",
"coaches": "Hitting",
"joined": "2026-10-30T09:00:00Z",
"joined_with": "CV-7K4Q-2M",
"role": "coach",
"is_me": false,
"sees_all": false,
"group_ids": [
"60000000-0000-4000-8000-000000000001"
],
"permissions": {
"review": true,
"drills": true,
"goals": true,
"library": false,
"earnings": false
},
"activity": {
"reviews": 12,
"avg_reply_hours": 9,
"players": 6,
"drills_set": 8,
"period_start": "2026-10-01",
"period_end": "2026-10-31"
},
"status": "active",
"version": 1
}
}
```
**Backend processing / persistence:** Read membership/groups/effective permissions plus activity aggregates for explicit period. Reviews/reply-time/players/drill-set definitions require Q10. This includes draft N51 activity.
**Validation and additional errors:** 404 missing member; 422 reversed dates. Activity fields reviews, players, drills_set integers; avg_reply_hours nullable number.
**Frontend success/failure integration:** Map numeric hours to label and role enum to display label; error/removed state.
**Dependencies / unresolved decisions:** N40/N28; Q10
#### N42 — Edit permissions, groups or pause state
`PATCH /v1/academy/coaches/{id}`
**Priority / current status:** Medium / Mocked
**Frontend trigger:** CoachManage Save, Pause, Resume; academy.updateMember
**Authorization:** Active academy admin; last-admin/self restrictions Q12
**Parameters and writable fields:** Required id. Optional role, sees_all boolean, group_ids UUID array, permissions object of listed booleans, status active/paused, expected_version; at least one change.
**Request example:**
```json
{
"role": "assistant",
"sees_all": false,
"group_ids": [
"60000000-0000-4000-8000-000000000001"
],
"permissions": {
"review": true,
"drills": false,
"goals": false,
"library": false,
"earnings": false
},
"expected_version": 1
}
```
**Success:** 200.
```json
{
"coach": {
"id": "80000000-0000-4000-8000-000000000001",
"name": "Jamie K.",
"coaches": "Hitting",
"joined": "2026-10-30T09:00:00Z",
"joined_with": "CV-7K4Q-2M",
"role": "assistant",
"is_me": false,
"sees_all": false,
"group_ids": [
"60000000-0000-4000-8000-000000000001"
],
"permissions": {
"review": true,
"drills": false,
"goals": false,
"library": false,
"earnings": false
},
"activity": {
"reviews": 12,
"avg_reply_hours": 9,
"players": 6,
"drills_set": 8,
"period_start": "2026-10-01",
"period_end": "2026-10-31"
},
"status": "active",
"version": 2
}
}
```
**Backend processing / persistence:** Lock membership, validate groups, normalize effective capabilities using approved role rules; persist audit event and invalidate permission caches. Pause immediately blocks future academy requests.
**Validation and additional errors:** 422 contradictory permissions unless canonical normalization explicitly documented; 409 LAST_ADMIN or STALE_VERSION. Reject status removed here; use reassignment operation.
**Frontend success/failure integration:** Load actual groups; use returned effective permissions; handle failed save/pause without success toast.
**Dependencies / unresolved decisions:** N41; C03; Q02/Q12
#### N43 — Remove coach and reassign roster
`DELETE /v1/academy/coaches/{id}`
**Priority / current status:** Medium / Mocked removal only
**Frontend trigger:** CoachManage remove sheet; academy.removeMember
**Authorization:** Academy admin; Q12 self/last-admin protection
**Parameters and writable fields:** Required id; required query reassign_to UUID for selected eligible replacement. Query avoids DELETE body ambiguity; frontend must pass selected ID.
**Success:** 204; retry same completed removal is a no-op.
No response body.
**Backend processing / persistence:** Transactionally verify replacement active/same academy, transfer defined roster responsibilities, revoke membership and invalidate access. Preserve player-owned sessions. Historical author IDs remain auditable. Assignments/threads/private notes transfer rules require Q12.
**Validation and additional errors:** 409 LAST_ADMIN, INVALID_REPLACEMENT or unresolved ownership; 404 inaccessible member. Never select a replacement silently.
**Frontend success/failure integration:** Wire moveTo selection into request; disable if no eligible replacement; show real errors.
**Dependencies / unresolved decisions:** N40/N41; C06; Q12
#### N44 — List coaching access requests
`GET /v1/academy/coach-requests`
**Priority / current status:** High / Mocked
**Frontend trigger:** CoachRequests, Team badge; academy.requests
**Authorization:** Academy admin; badge must not query this for ordinary coaches
**Parameters and writable fields:** Optional status pending/approved/declined/all, limit/cursor; newest at then ID descending.
**Success:** 200.
```json
{
"items": [
{
"id": "60000000-0000-4000-8000-000000000001",
"user_id": "10000000-0000-4000-8000-000000000001",
"name": "Alex R.",
"code": "CV-7K4Q-2M",
"at": "2026-10-30T09:00:00Z",
"also_player": true,
"status": "pending"
}
],
"next_cursor": null,
"total_pending": 1
}
```
**Backend processing / persistence:** Read academy-scoped requests linked to user ID and staff-code record. Include requested identity plus current decision. Pending badge counts must include all pages or use response total_pending.
**Validation and additional errors:** Add total_pending integer to list envelope for badge (shown below in implementation extension); code disclosure only to authorized admins.
**Frontend success/failure integration:** Use status filter for badge; handle server pagination. Current name-based mock approval must be removed.
**Dependencies / unresolved decisions:** N27; C03
**Envelope extension:** Return `total_pending` alongside `items` and `next_cursor`, e.g. `"total_pending":1`, so Team does not count only one page.
#### N45 — Approve or decline access request
`POST /v1/academy/coach-requests/{id}/decision`
**Priority / current status:** High / Mocked; creates member by name
**Frontend trigger:** CoachRequests approval sheet/decline; academy.decide
**Authorization:** Active academy admin
**Parameters and writable fields:** Required id; body decision approve/decline; approve also role coach/assistant, sees_all boolean, optional group_ids array. No role admin via this flow.
**Request example:**
```json
{
"decision": "approve",
"role": "assistant",
"sees_all": false,
"group_ids": [
"60000000-0000-4000-8000-000000000001"
]
}
```
**Success:** 200.
```json
{
"request": {
"id": "60000000-0000-4000-8000-000000000001",
"user_id": "10000000-0000-4000-8000-000000000001",
"name": "Alex R.",
"code": "CV-7K4Q-2M",
"at": "2026-10-30T09:00:00Z",
"also_player": true,
"status": "approved"
},
"coach": {
"id": "10000000-0000-4000-8000-000000000001",
"name": "Alex R.",
"coaches": "Hitting",
"joined": "2026-10-30T09:00:00Z",
"joined_with": "CV-7K4Q-2M",
"role": "assistant",
"is_me": false,
"sees_all": false,
"group_ids": [
"60000000-0000-4000-8000-000000000001"
],
"permissions": {
"review": true,
"drills": false,
"goals": false,
"library": false,
"earnings": false
},
"activity": {
"reviews": 12,
"avg_reply_hours": 9,
"players": 6,
"drills_set": 8,
"period_start": "2026-10-01",
"period_end": "2026-10-31"
},
"status": "active",
"version": 1
}
}
```
**Backend processing / persistence:** Lock pending request and membership; transition exactly once, create/upsert member by user ID, apply visibility and code-capacity policy, append audit/outbox. Decline returns coach null and permits future valid application per UI.
**Validation and additional errors:** 409 REQUEST_ALREADY_DECIDED for conflicting decision; same decision retry safe. Groups must belong to academy. Q02 resolves pending requests after code revocation/expiry and assigned-groups default.
**Frontend success/failure integration:** Add group selection or approve with explicit empty visibility; remove hardcoded 12U default. Refresh requester capabilities and admin lists.
**Dependencies / unresolved decisions:** N27/N40/N46; C03/C05; Q02
#### N46 — List staff access codes
`GET /v1/academy/staff-codes`
**Priority / current status:** High / Mocked
**Frontend trigger:** StaffCodes, CoachRequests; academy.codes
**Authorization:** Academy admin
**Parameters and writable fields:** Optional status active/expired/revoked/all, limit/cursor.
**Success:** 200.
```json
{
"items": [
{
"code": "CV-7K4Q-2M",
"role": "coach",
"expires": "2026-11-06T09:00:00Z",
"uses": 0,
"max_uses": 5,
"approval": "admin",
"status": "active"
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Read code metadata and computed expiry/capacity. Expose full code only because existing UI supports copying from list; choose protected storage accordingly. Never log bearer-like codes.
**Validation and additional errors:** uses integer >=0 <=max_uses under agreed consumption policy; expiry timestamp; exhausted may use active + uses=max or add status after Q02.
**Frontend success/failure integration:** Compute expiry display from actual expires; full capacity must not appear usable.
**Dependencies / unresolved decisions:** N47; Q02
#### N47 — Generate controlled staff code
`POST /v1/academy/staff-codes`
**Priority / current status:** High / Mocked random generator
**Frontend trigger:** StaffCodes Generate; academy.generateCode
**Authorization:** Academy admin
**Parameters and writable fields:** Body role coach/assistant, expires_days 1/7/30, max_uses 1/5/20, approval admin/auto.
**Request example:**
```json
{
"role": "coach",
"expires_days": 7,
"max_uses": 5,
"approval": "admin"
}
```
**Success:** 201.
```json
{
"staff_code": {
"code": "CV-7K4Q-2M",
"role": "coach",
"expires": "2026-11-06T09:00:00Z",
"uses": 0,
"max_uses": 5,
"approval": "admin",
"status": "active"
}
}
```
**Backend processing / persistence:** Use cryptographically secure unpredictable code, unique constraint and collision retry; persist role/expiry/capacity/creator/audit. Server expiry based on creation instant. Idempotency replay must return same code.
**Validation and additional errors:** Enums match creation UI options (seeded legacy values may differ). No admin role grant. Max active-code/rate policy proposed, not current behavior.
**Frontend success/failure integration:** Copy/share actual returned code; list refresh after success.
**Dependencies / unresolved decisions:** N46; Q02
#### N48 — Revoke future code use
`DELETE /v1/academy/staff-codes/{code}`
**Priority / current status:** High / Mocked
**Frontend trigger:** StaffCodes Revoke; academy.revokeCode
**Authorization:** Academy admin owning code
**Parameters and writable fields:** Required normalized URL-encoded code; no body.
**Success:** 204; repeat same revocation no-op.
No response body.
**Backend processing / persistence:** Mark revoked and append audit. Stop future redemption immediately. Existing approved membership remains; effect on pending reservations is Q02. Race with redemption must serialize on code.
**Validation and additional errors:** 404 inaccessible/unknown code; common errors. Redact code from request logs.
**Frontend success/failure integration:** Confirm destructive intent in UI already present; update list only on success.
**Dependencies / unresolved decisions:** N46/N27; Q02
### Consent administration
#### N49 — Read academy consent records
`GET /v1/academy/consent`
**Priority / current status:** Medium / Seeded counts/records
**Frontend trigger:** Consent; academy.consent
**Authorization:** Active academy admin with permitted compliance access
**Parameters and writable fields:** Optional limit/cursor; proposed group_id filter, absent in current UI.
**Success:** 200.
```json
{
"accepted": 1,
"ai_opt_in": 0,
"items": [
{
"player_id": "10000000-0000-4000-8000-000000000001",
"name": "Alex R.",
"group": "14U",
"group_ids": [
"60000000-0000-4000-8000-000000000001"
],
"note": "Accepted 30 Oct 2026",
"version": "1.0",
"accepted_at": "2026-10-30T09:00:00Z",
"withdrawn_at": null,
"help_improve_ai": false
}
],
"next_cursor": null
}
```
**Backend processing / persistence:** Join actual academy players to current consent projection and opt-ins; totals apply to full authorized scope, not current page. Preserve audit events separately.
**Validation and additional errors:** Counts nonnegative; nullable version/timestamps for never accepted. No fabricated household names from seed. Guardian identity fields require Q14.
**Frontend success/failure integration:** Map items to records; show no consent/unavailable honestly; paginate.
**Dependencies / unresolved decisions:** N03/N04/N02; Q14
#### N50 — Export scoped consent CSV
`POST /v1/academy/consent/export`
**Priority / current status:** Low / Toast only
**Frontend trigger:** Consent Export records; no mock
**Authorization:** Same scoped admin as N49; audit export
**Parameters and writable fields:** Body optional group_id and format literal csv. Proposed immediate artifact for bounded records; large asynchronous export needs explicit follow-up contract.
**Request example:**
```json
{
"format": "csv"
}
```
**Success:** 201.
```json
{
"export": {
"id": "60000000-0000-4000-8000-000000000001",
"status": "ready",
"url": "https://exports.example.com/consent/read?token=temporary",
"expires_at": "2026-10-30T09:15:00Z",
"filename": "consent-2026-10-30.csv"
}
}
```
**Backend processing / persistence:** Build CSV using same scope/fields as N49; quote cells and neutralize spreadsheet formula injection; store private expiring artifact; append audit record. Recheck membership at download or use suitably short signed access.
**Validation and additional errors:** 422 unsupported format/filter; 409 EXPORT_TOO_LARGE if synchronous bound exceeded until async design agreed Q15. No raw CSV response through JSON-only request client.
**Frontend success/failure integration:** Download/share returned artifact with native file handling; do not claim export succeeded on a toast alone.
**Dependencies / unresolved decisions:** N49; C06; Q15
### Conditional and consolidated items from the earlier draft
#### N34 — Direct email/phone invitation — conditional, not in primary count
**Evidence:** AddPlayers has an email/phone field, but when a team exists its handler shares the team code through the native share sheet; it does not use the entered recipient. Without a team it shows a success toast. Therefore, direct outbound invitation delivery is **Requires Clarification Q11**.
**Recommendation only if direct invitations are confirmed:** `POST /v1/coach/invites`, authenticated active coach with roster-management permission; `Idempotency-Key` required. Body: `channel: email|sms`, `recipient: string`, optional `group_id: UUID`. Example:
```json
{"channel":"email","recipient":"player@example.com","group_id":"60000000-0000-4000-8000-000000000001"}
```
Proposed 202 response:
```json
{"invite":{"id":"60000000-0000-4000-8000-000000000002","status":"queued","expires_at":"2026-11-06T09:00:00Z"}}
```
Normalize/validate email or phone format, check same-academy group, rate-limit, store hashed redemption token and invite state, enqueue delivery once. Do not add someone to a roster merely because a message was sent. 422 invalid recipient, 409 conflicting active invitation, common auth/scope/rate errors. Expiry above is illustrative. Provider, recipient verification, redemption/deep-link path, consent to association, duplicate-account handling and no-team behavior are not defined. Specify those before adopting this endpoint; they may require additional delta work. Native code sharing needs no new endpoint.
#### N51 — Separate coach activity endpoint — consolidated into N41
The earlier draft proposes `GET /v1/academy/coaches/{id}/activity`. The current management screen receives all four activity values from `academy.member`. N41 includes activity and its period, so a separate operation would duplicate the read. Do not build it unless independent pagination, windows or refresh behavior justify separation. This item is excluded from primary and conditional endpoint totals.
### Shared validation details not encoded by examples
JSON examples establish field names and example types; they are not full schema validators. Use these rules with each contract when publishing OpenAPI:
| Model | Required output / invariants |
| --- | --- |
| Settings | All documented booleans returned; parent_email/consent dates/version nullable; version integer. Optional defaults must be approved, not copied from seed. skip_filming_guide may be omitted from production scope because no consumer was found. |
| Thread | id, player_id, mode, status, display labels, read booleans, messages and updated_at present; session_id/score nullable. Author ID separates distinct coaches even when `from` is coach. `reviewed` describes last-response status, not proof of formal review. |
| Message | id, author_id, from, kind, at always present. Only fields of selected variant accepted. `session_id:null` is allowed only in a read tombstone for deleted historical content, not for a newly shared session. |
| Goal | Player/mode identity, type, target, due label/instant, author, weekly targets and note. metric_id required only for param. Unit/comparator/evaluation fields must be added after Q07; do not claim param goals can be objectively evaluated yet. |
| Assignment | Player, source and exact assignment identity; author and timestamps; positive sets/reps; done cannot exceed sets. Snapshot name/fixes does not override current media authorization. |
| ArmCare | Unknown assessment distinct from zero rest; no default “good” for a user who never reported feel. Outings ordered newest first, unique IDs and integer pitches. Date/label/rest display strings are not authoritative arithmetic inputs. |
| Group | Membership counts computed from ID relationships, not client-supplied counts. IDs and labels must refer to the same records. |
| CoachMember | Membership identity distinct from display name; effective role/permissions/status; group IDs; activity period explicit. Decide whether route id is membership ID or user ID once and use consistently (Q01). |
| StaffCode | Expiry and usage enforcement at redemption/decision, not just display. Generation options constrain new codes but should not make historical codes unreadable. |
| Reporting | Exact temporal scope and as_of timestamp; null for unavailable metrics; named, typed values rather than formatted tuples. Money minor units plus currency; percentages have documented denominator. |
## 7. Suggested data model and relationships
These are proposed logical tables for the delta, not a claim about an existing backend database. Reuse compatible tables where the backend already has them. References to users, sessions, media and existing practice logs are dependencies; their unchanged schemas are not restated.
### 7.1 Entities and constraints
| Entity | Suggested key fields | Relationships and constraints |
| --- | --- | --- |
| `user_settings` | user_id PK/FK; documented preference booleans; parent recipient reference; version; updated_at | One per user. Effective consent is projected from events, not arbitrarily PATCHable. |
| `consent_events` | id PK; user_id; subject/guardian reference if approved; policy_version; action accepted/withdrawn; recorded_at; actor_id | Append-only history. Effective acceptance derived from ordered events. Separate event category for training/example opt-ins. Retention Q14. |
| `notifications` | id; recipient_id; academy_id nullable; kind; title; body; target; event_key; created_at; read_at nullable | Unique recipient/event_key. Index (recipient_id, read_at), (recipient_id, created_at DESC, id). |
| `threads` | id; academy_id; player_id; coach/context identity; mode; session_id nullable; status; updated_at | Uniqueness depends on Q04; recommended one session thread per approved context, plus separate general context. Do not use nullable uniqueness alone to deduplicate general threads. |
| `thread_participants` | thread_id + user_id PK; participant_role; last_read_sequence | Read state per actual person; message sequence monotonic. Membership visibility evaluated on every access. |
| `messages` | id; thread_id; sequence; author_id; kind; text/media/session/review reference; created_at; updated_at | Unique (thread_id, sequence). CHECK constraints on kind-specific fields. Unique review representation per thread/review under C01. |
| `goals` / `goal_revisions` | id; player_id; academy_id; mode; type; target; metric_id; due_at; weekly targets; author_id; start/end; outcome; evidence_session_id; version | One active goal per agreed player/mode/academy scope. Preserve revisions and outcome evidence. Coach overlap policy Q07. |
| `milestone_events` | id; player_id; mode; rule_id/version; source_id; occurred_at | Unique player/rule/source. Can be a derived view where inexpensive. |
| `drill_assignments` | id; academy_id; player_id; assigned_by; source kind/id; session_id nullable; mode; sets; reps; due_date; created_at | FK validation for both catalog and library sources; model polymorphic references explicitly. Counters derived from set events. |
| `assignment_sets` | id; assignment_id; set_number; reps_done; day; actor_id; created_at; practice_log_id | Unique (assignment_id, set_number); one linked practice log. Atomic insert/progress update. |
| `arm_outings` | id; user_id; local_date; recorded_at; timezone; pitches; source; source_session_id nullable | Unique source session when automatic ingestion is approved; distinguish game manual log from filmed activity. |
| `arm_feel_events` | id; user_id; feel; recorded_at | Latest is current; optional history retention. |
| `arm_rule_versions` | id/version; applicable age group; effective dates; validated rules/source metadata | Rules not derived from arbitrary mock thresholds. Evaluation stores chosen version and input snapshot. |
| `academies` | id; name; existing_team_id if mapping approved; organization_id nullable; timezone | Team/academy/location equivalence unresolved Q01. Avoid migrating all teams to assumed identical structures without review. |
| `academy_memberships` | id; academy_id; user_id; membership_type; role; status; sees_all; effective permissions; version | Unique active membership per intended scope; no name-based uniqueness. Preserve player/coaching capabilities independently if approved. |
| `coach_player_assignments` | academy_id; coach_id; player_id; assigned_at | Unique relationship; validate both memberships in same academy. Distinct from player-owned sessions. |
| `player_groups` | id; academy_id; name; focus | Group-name uniqueness is proposed. |
| `group_players`, `group_coaches` | group_id + membership/user ID composite PK | Stable IDs, validated same academy. Index reverse lookups for visibility. |
| `coach_private_notes` | academy_id + coach_id + player_id unique; text; version; updated_at | Own-coach access; transfer/retention Q12. |
| `staff_codes` | id; academy_id; protected code representation; role; expires_at; max_uses; uses/reservations; approval; revoked_at; creator_id | Unique code representation, atomic capacity checks. If codes are re-displayable, hashing alone cannot support UI; use encryption or change display policy. |
| `coach_access_requests` | id; applicant_user_id; academy_id; staff_code_id; status; sent_at; decided_by/at; selected role/scope | Unique active pending applicant/context policy; lock decision. No duplicate memberships when same name appears. |
| `library_drills` / `library_drill_tags` | id; academy_id; name; mode; media_id; author_id; status; tags | Media ownership and tag vocabulary enforced; immutable reference/snapshot strategy for prior assignments. |
| `export_jobs` | id; requester_id; scope/academy_id; state; result_object; expiry; error_code; requested_at | Export artifacts private, expiring and revocable. |
| `notification_outbox` | id; event_key; recipient; channel; payload; state; attempts; next_attempt_at | Unique event/recipient/channel. Insert with domain mutation; delivery outside transaction. |
| `idempotency_records` | actor + operation + key; request_hash; response_status/body; expires_at | Unique composite key, protected from conflicting concurrent requests. |
| `academy_revenue_ledger` / reporting views | source event; academy; currency; amount_minor; effective/posted dates; status | Conditional on approved earnings model, reuse finance source of truth. Read-only dashboards must not invent transactions. |
| `audit_events` | actor; academy; action; resource; timestamp; safe before/after delta | Role changes, decisions, code lifecycle, exports and reassignment; redact secrets and unnecessary private content. |
### 7.2 Relationship diagram
```mermaid
erDiagram
USER ||--o| USER_SETTINGS : has
USER ||--o{ CONSENT_EVENT : records
USER ||--o{ NOTIFICATION : receives
ACADEMY ||--o{ MEMBERSHIP : contains
USER ||--o{ MEMBERSHIP : holds
ACADEMY ||--o{ PLAYER_GROUP : organizes
PLAYER_GROUP ||--o{ GROUP_PLAYER : includes
PLAYER_GROUP ||--o{ GROUP_COACH : assigns
MEMBERSHIP ||--o{ GROUP_PLAYER : belongs
MEMBERSHIP ||--o{ GROUP_COACH : coaches
USER ||--o{ GOAL_REVISION : pursues
USER ||--o{ DRILL_ASSIGNMENT : receives
DRILL_ASSIGNMENT ||--o{ ASSIGNMENT_SET : records
ACADEMY ||--o{ LIBRARY_DRILL : owns
USER ||--o{ ARM_OUTING : logs
THREAD ||--o{ MESSAGE : contains
THREAD ||--o{ THREAD_PARTICIPANT : has
USER ||--o{ THREAD_PARTICIPANT : participates
ACADEMY ||--o{ STAFF_CODE : issues
STAFF_CODE ||--o{ COACH_ACCESS_REQUEST : admits
USER ||--o{ COACH_ACCESS_REQUEST : submits
```
Sessions may be referenced by threads, messages, assignment sources and evaluation evidence. Existing session ownership remains authoritative; those links do not grant new visibility. All joins crossing academy boundaries must validate the shared academy, not just individual foreign-key existence.
### 7.3 Transaction boundaries and lifecycle
- **Review:** Review + thread/review-message + read/activity state + notification/outbox. Do not roll back a successful review because a push provider is unavailable; retry the outbox.
- **Assignment:** Assignment + event + outbox. Set logging: set event + bounded progress + linked practice log. Unique ordinal prevents overcount across retries/devices.
- **Staff application:** Code reservation/use + request + optional auto-approved membership. Manual decision locks request and relevant membership/code policy state.
- **Coach removal:** Verify replacement and last-admin condition, reassign permitted responsibilities, revoke access and write audit in one transaction.
- **Consent:** Append event and update projection transactionally; admission checks read authoritative state. Background jobs recheck relevant permission before use/delivery.
- **Exports/media:** Create private artifact only for authorized scope. Deletion/revocation needs a defined strategy for already-issued URLs; short expiry bounds exposure but does not retroactively erase a downloaded copy.
## 8. Integration workflows and background processing
### 8.1 Review to conversation
```mermaid
sequenceDiagram
participant C as Coach app
participant API as Backend
participant DB as Database
participant W as Delivery worker
participant P as Player app
C->>API: Review with optional verified audio upload
API->>API: Validate membership, player scope and sharing
API->>DB: Transaction: review, thread, message, unread, outbox
DB-->>API: Commit
API-->>C: Review and thread_id
C->>API: Read thread
W->>DB: Claim pending delivery event
W->>W: Recheck preference and send push
P->>API: Load notifications or threads
API-->>P: Authorized persisted data
P->>API: Mark read through rendered message ID
```
If upload fails, preserve the recording and allow retry. If review succeeds but response is lost, resolve via idempotency/authoritative session-thread lookup; never fabricate another local conversation. Decide whether an existing review keeps one edited card or appends revision history in Q04; proposed behavior matches the mock's single upserted card.
### 8.2 Staff code to dual-role access
```mermaid
sequenceDiagram
participant P as Applicant
participant API as Backend
participant DB as Database
participant A as Academy admin
P->>API: N27 submit code
API->>DB: Lock code; check expiry, capacity and applicant
alt Manual approval
API->>DB: Create pending request and capacity record
API-->>P: Pending
A->>API: N45 approve with role and scope
API->>DB: Lock request; create membership; audit; outbox
else Auto approval
API->>DB: Create approved request and membership atomically
API-->>P: Approved
end
P->>API: N26 status and refreshed account capabilities
API-->>P: Effective membership and allowed modes
```
Code validity at submission versus decision, capacity reservations on decline, and retry/reapply behavior are Q02. Application approval must not depend on matching the applicant's display name. Role/capability changes are checked server-side on subsequent requests even before token expiry.
### 8.3 Assignment to progress
```mermaid
flowchart TD
Pick[Coach chooses player, source drill and due date] --> Validate[Validate player scope and drill permission]
Validate --> Persist[Create assignment and delivery event]
Persist --> Display[Player reads assignment]
Display --> Reps[Rep counter stays local]
Reps --> Set[Submit set number, reps, day and retry key]
Set --> Lock[Lock assignment and deduplicate ordinal]
Lock --> Commit[Commit set event and one linked practice log]
Commit --> Refresh[Refresh assignment, player totals and coach views]
```
Queue must join progress by player and assignment ID. The same catalog drill can appear on multiple players or several assignments for one player; matching only drill ID/name is incorrect. Review-derived drill recommendations and independent assignments must have an explicit relationship if the Sent card shows completion.
### 8.4 Consent and data export
Guide reads settings → obtains required acceptance if absent → awaits successful N03 → continues. Backend analysis admission independently validates consent. On withdrawal, future submissions fail with a recognizable consent-required error; previously saved data remains accessible according to the agreed privacy policy. A stale client cannot bypass withdrawal.
Video export: N05 authorizes owner and queues job → worker gathers authorized current media → builds private archive → creates expiring link → sends verified account email → records delivery status. If account deletion occurs before delivery, cancel and invalidate. A successful HTTP 202 means “accepted for processing,” not “email delivered.” Large CSV exports may adopt the same pattern after Q15; do not return a nonexistent ready URL.
### 8.5 Scheduled behaviors promised by UI, without new public endpoints
| Behavior | Inputs / work | Decisions still needed |
| --- | --- | --- |
| Automatic monthly parent report | Approved parent recipient, sharing + auto-report flags, prior-month data, scheduled worker, delivery event | Recipient setup/verification, month timezone, actual report format and unsubscribe/revocation policy (Q03/Q06) |
| Drill-due reminders | Assignment due_date, completion state, notification preferences | Reminder time, overdue repeats, deduplication (Q09) |
| Sunday weekly-target reminder | Goal weekly targets and unified practice totals | Week definition, timezone, reminder target/kind, disabled weeks (Q06/Q09) |
| Goal history / milestone evaluation | Goal revisions, observed session data, practice events | Comparator, missing data, close/replacement behavior (Q07) |
| Arm-care warnings | Outing aggregates, feel, validated rule version, coach visibility | Age/source rules, same-day workload, recipients, reminder recurrence (Q08) |
| Notification/email dispatch | Transactional outbox, delivery preferences, target authorization | Provider configuration, retries, dead-letter policy, per-event kind (Q09/Q15) |
| Financial reporting refresh | Approved ledger and academy attribution | Revenue sharing, payout schedules, estimates, refunds and periods (Q10) |
Do not create additional API endpoints merely to represent a cron/worker. Track job failures operationally and provide truthful user feedback where the UI promises a result.
## 9. Required frontend integration work
The backend alone cannot make the current screens complete. These tasks belong in the same delivery plan.
| Area | Required change |
| --- | --- |
| HTTP client | Add PUT support. Keep refresh behavior, error envelopes and idempotency keys. File downloads need a binary/native path rather than JSON parsing. |
| Schemas/adapters | Publish agreed OpenAPI additions, regenerate types, map snake_case to screen models explicitly, unwrap objects, support null/unknown values. Do not cast new shapes to old types. |
| Production mock removal | Stop seeding mock data for production feature state. Do not upload demo AsyncStorage documents. Replace `useMockVersion` with query invalidation/refresh; isolate any demo build explicitly. |
| Reload/error behavior | Thread, Settings, ArmCare and several admin screens use focus:false. Define mutation invalidation, foreground refresh and bounded thread polling if live updates are desired. Add error/retry states where loaders currently stay blank or spinning. |
| Conversation rendering | Pagination, media playback, stable identity, read watermark, deleted-session state and stale URL refresh. Keep unsent text/recording after failure. |
| Audio | Real recording permissions, capture, stop/cancel/redo, preview, upload, progress, retry and actual playback. Remove fixed 12-second messages and timer-based simulated playback. |
| Drill assignment | Add playerId/source kind to sheet, use dates/IDs, return assignment IDs, scope coach queries. Include actual reps and stable retry key on completion. |
| Progress | Unify assignment sets with existing practice totals; remove seeded goal history and milestones. Handle parameter goals and historical month goals after Q07. |
| Access | Use authoritative capabilities for Team/admin menus, route guards and dual-role navigation. A local menu guard supplements server enforcement. |
| Groups | Use fetched groups in CoachManage, pass selected coach/player IDs on creation, apply roster filter. |
| Removal | Send selected replacement; exclude paused/removed/ineligible replacements; preserve selection on error. |
| Staff requests | Surface invalid/expired/exhausted codes, declined and auto-approved outcomes. Refresh capabilities after decision; remove name-based member association. |
| Reporting | Convert financial minor units, consume typed KPI/location arrays, render missing data and empty bars. Label actual periods/as_of. |
| Consent | Await reads/acceptance; display correct version; support withdrawal failures. Decide filming-other/guardian flow before enforcing subject consent. |
| Push | Parse new target transport, route all supported kinds, defer until sign-in/navigation ready, handle stale/deleted targets and retain old review compatibility. |
| Placeholder completion | Real video export trigger, real CSV download, real drill-upload form and real member addition. Native save-to-phone needs implementation but no new endpoint is established. |
| Sharing choices | Implement approved parent/email/private-link flow or change UI copy/options to truthful native summary sharing. Do not mark different recipients as implemented when selection is ignored. |
## 10. Requires Clarification register
These are decisions for product/backend/domain owners. Recommendations are deliberately separated from verified behavior. An unresolved item blocks only its dependent behavior, not all implementation work.
| ID | Unknown / conflicting evidence | Recommendation for decision | Affected work |
| --- | --- | --- | --- |
| Q01 | Relationship among existing team, academy, organization/location; single/multiple memberships; route member IDs; who may create groups/add players | Document tenant model and existing-team migration. Choose stable membership vs user IDs consistently. Resolve academy context server-side; grant corporate visibility explicitly. | C03–C04, N28–N45, data migration |
| Q02 | Dual player/coach access; role defaults; code use counted on submission or approval; pending behavior after revocation/expiry; resubmission | Separate player capability from academy membership. Define state machine and atomic capacity reservation/release. Approve by user ID. Do not seed a default group. | N26–N27, N40–N48, C03 |
| Q03 | Parent-email setup/verification absent; sharing defaults; private links; automatic reports; example clips; precedence with privacy flag | Default optional external sharing off pending setup. Preserve native text share if no delivery/link feature is approved. If browser links are required, separately specify creation, authorization, expiry/revocation and viewer delivery; no such endpoint is established yet. | N01–N02, ReportCard, C07, monthly worker |
| Q04 | Session vs general conversation uniqueness; multiple coaches; read state; review edits; full history vs bounded responses | One explicit context key per conversation, per-user participants/read watermarks, one edited review representation with separate audit. Define summaries for Queue/History before truncating messages. | N10–N15, C01 |
| Q05 | Review drill vs assignment linkage; defaults 3×8; partial sets; source drill IDs; duplicate assignments | Keep distinct assignment identity and source; link review to assignment explicitly if intended. Store actual reps. Choose whether partial reps count as a completed set. Atomic bridge to practice log. | N20–N22, C01/C08 |
| Q06 | Timezone not represented in mock settings; “Saturday,” “Next week,” weekly windows and end-of-month deadlines | Persist IANA timezone; exchange absolute date/deadline plus display label. Decide same-day Saturday and week-start behavior. Test DST and month boundaries. | Goals, drills, reminders, arm care, reporting |
| Q07 | Goal metric direction/range/unit; UI target vs on_target rating mismatch; current vs historical goals; missing reports; goal notification kind | Define metric-specific comparator and evidence period, archive revisions with unknown outcome when unassessed. Resolve historical month selection. Evaluate only after policy defined. | N16–N19, ReportCard, CoachHistory |
| Q08 | Age-specific arm-care policy; only age (not DOB) known; seeded innings; no innings input; filmed-bullpen counts; warnings/coach visibility | Have qualified domain owners approve versioned rules and inputs. Never treat seeded rest thresholds or a single filmed rep as validated workload. Return unknown until sufficient data; revise “Cleared to pitch” copy. | N23–N25, Home, ReportCard, milestones |
| Q09 | Notifications for goal/message/access/weekly events lack kind/target; preference mapping; in-app vs push opt-out | Define event-to-kind/target/preference table and delivery timing. Recommend durable in-app inbox with optional push, pending product agreement. Deduplicate recipient/event. | C05, messaging, goals, reminders |
| Q10 | Earnings values/rate/currency/payout source; active/improving definitions; reply time; corporate scope and denominator | Approve accounting and metric definitions before reporting real money. Use ledger-backed minor units; show unavailable instead of demo totals. Define periods for each metric. | N37–N41 |
| Q11 | Direct invitations vs native team-code sharing; no-team invite behavior | Keep native sharing if sufficient. Adopt N34 only with delivery, verification, redemption and membership workflow defined. | AddPlayers, conditional N34 |
| Q12 | Account deletion vs coach removal; ownership succession; last admin; private notes/history retention; sessions referenced in threads | Specify per-entity retain/delete/anonymize/transfer matrix. Do not transfer private notes automatically. Preserve player-owned sessions when removing coach access. | C06, N30–N31, N42–N43 |
| Q13 | Audio/library content limits, formats, processing, fault-tag vocabulary, video playback | Choose supported recording/encoding pipeline and approved limits. Expose authorized read URLs after bytes verified. Library uploads need a real form and playable assigned content. | C01–C02, N14, N35–N36 |
| Q14 | Terms version distribution; consent actor/subject for minors or filming another person; acceptance history retention; in-flight analysis | Document actual policy and approved legal/guardian UX; version events; fail closed for new admission. This specification makes no legal-compliance claim. | N01–N04, N49–N50, C07 |
| Q15 | Export scale, lifetime, email provider, recipient availability, failure notification, download authorization | Define bounded sync CSV vs async jobs, expiring private artifacts, verified delivery and deletion cancellation. Add status API only if progress UI/delivery guarantees require it. | N05/N50, conditional invite |
### 10.1 Proposed metric definition worksheet
The code displays these values but mostly hardcodes them. Resolve each formula before implementing N37–N41:
| Metric | Required definition |
| --- | --- |
| Active players | Active membership, recent activity, paying status, or another population? Exact rolling/calendar window? |
| New this month | First account creation, first academy join, first subscription or first analysis? |
| Improving percentage | Latest delta, first-to-last change, threshold and mode? Denominator excludes unscored players or counts them? |
| Cards g/y/r | Latest scored session per player/mode, unknown excluded; reconcile with Roster source. |
| Analyses this week/month | Completed reports vs uploads, self vs filmed-other subjects, academy attribution at event time? |
| Average review/reply hours | Session completion to first review vs player message to first coach reply; revisions excluded? |
| Not filmed 7 days | All members vs active/payable cohort, never-filmed inclusion and timezone boundary? |
| Per-player share / earnings | Gross vs net, eligible subscription state, refunds, taxes, fees, prorating, contractual share and currency? |
| YTD/projected | Calendar vs fiscal year, booked vs paid revenue, projection method and estimate label? |
| Common fixes | Latest report vs all reports, per-player vs per-session denominator, mode and period? |
## 11. Implementation order and acceptance criteria
### 11.1 Delivery phases
| Phase | Scope | Exit condition |
| --- | --- | --- |
| 0 — Contract and ownership decisions | Q01/Q02/Q04/Q06; shared envelopes; membership/authorization model; endpoint schema review | Backend/frontend agree IDs, scope, states and dates; blocked behaviors explicitly gated |
| 1 — Settings, consent and access foundations | N01–N04, C03/C07, base academy membership, enforcement | No demo defaults; consent gates enforced; resource authorization tests pass |
| 2 — Coaching conversation | N06–N15, C01/C02/C05 | Two real accounts exchange review, text and audio with correct unread/deep-link behavior |
| 3 — Prescribed practice | N16–N22, N30–N31, C08 | Scoped goal/assignment persistence; duplicate-resistant set logs; consistent progress totals |
| 4 — Academy operations | N26–N29, N32–N33, N35, N40–N48, C04 | Staff-code state machine, group membership, roster addition, permissions and reassignment work across accounts |
| 5 — Domain and reporting | N23–N25, N37–N39, N49; resolve Q07/Q08/Q10 | Real source-backed results, unknown states and approved calculation definitions |
| 6 — Media/export placeholders | N05/N36/N50, conditional N34 if adopted; C06 lifecycle audit | Upload/export workers and native download flows verified, deletion/revocation applied |
Phases describe implementation dependencies, not permission to ship insecure partial functionality. For example, academy capability enforcement is required before exposing any academy feature even if its management screen is delivered later. Arm-care and financial reporting remain gated until their domain definitions are approved.
### 11.2 Backend implementation checklist
- [ ] Publish agreed OpenAPI delta with all request/response variants, enums, nullability and errors; do not overwrite the existing baseline spec with an unverified generated contract.
- [ ] Add migrations, FKs, tenant indexes, uniqueness and bounded-counter checks; test migration/rollback on representative data.
- [ ] Authorize all reads and writes, including nested media/session references, using current effective membership and consent.
- [ ] Add idempotency storage and transaction boundaries; return stable errors for retry/conflict cases.
- [ ] Implement durable outbox, retry limits, dead-letter visibility and delivery deduplication.
- [ ] Define defaults, timezone, role policy, consent version and unknown-state behavior; document any remaining gated feature.
- [ ] Support scoped pagination without breaking consumer aggregates, badges or thread history.
- [ ] Implement media verification, authorized playback, unreferenced-upload cleanup and deletion cancellation.
- [ ] Establish metrics and earnings data lineage; no fixed sample numbers in production.
- [ ] Add request IDs and structured errors; redact codes, private notes, raw media URLs and secrets from operational logs.
- [ ] Test account switch, revoked/paused membership, concurrent actions and network retry paths.
- [ ] Integrate screen adapters and invalidation; disable production mock seeding.
### 11.3 Acceptance tests by functionality
| Area | Required observable acceptance criteria |
| --- | --- |
| Settings | Change on device A is visible on device B. Disabling parent sharing clears auto-report atomically. Conflicting version produces recoverable error. Failed toggle does not remain falsely saved. |
| Consent | First acceptance stored with version and server timestamp. Failed consent read/accept does not continue filming/analysis admission. Withdrawal blocks stale-client new analysis; saved records remain per policy. |
| Notifications | Only recipient sees records. Read-one/all and count agree across devices. New arrival after read boundary remains unread. No duplicate notification on event retry. Deleted targets fail safely. |
| Review/thread | One review submission produces one authoritative thread/card. Updating retains normal replies. Failure after commit is recoverable without duplicate thread or audio bubble. |
| Messages | Player and coach exchange text from separate accounts. Other player/academy cannot read or attach session. Server ignores/rejects forged author. Draft survives failure. Pagination does not hide required review/read state. |
| Voice | Actual bytes are captured, uploaded and playable. Wrong-purpose/other-user uploads rejected. Expired URL refreshed by authorized refetch. Cancel/redo/timeout does not send a fake note. |
| Read state | Opening as one coach does not clear another person's watermark. Concurrent incoming message remains unread until rendered/read. |
| Goals | Authorized coach sets correct player's mode-specific goal. History is scoped and backed by evidence. Invalid parameter/unit rejected. Missing evidence remains unknown. Two concurrent edits do not silently overwrite. |
| Drill assignments | Same catalog drill assigned to two players never crosses progress. Retry same set (even new HTTP connection) increments once; concurrent completion cannot exceed sets. Unified practice totals include the set exactly once. |
| Arm care | Age/inputs unavailable shows unknown. Multiple same-day outings aggregated using approved policy. No demo limits or false coach-alert claim. Rest and deadline boundaries tested against the approved timezone/rules. |
| Staff codes | Revoked/expired/exhausted code rejected; concurrent last-use redemption respects cap. Duplicate retry does not consume another use. Manual and automatic approval behave differently as specified. |
| Membership | Same-name applicants stay separate. Assistant cannot bypass goal/drill restrictions. Paused/removed coach denied with an old token. Dual-role account retains allowed player access. |
| Groups/roster | Create persists exact selected IDs. Selected group filters actual roster. Cross-academy IDs reject entire mutation. Duplicate add is a no-op with truthful response. |
| Notes | Coach A's private note is invisible to coach B/admin unless an explicitly approved policy says otherwise. Empty note clears content; conflict preserves draft. |
| Coach removal | Selected eligible replacement receives defined roster responsibilities atomically. Failure transfers nothing. Last-admin protection and historical/private-data policy verified. |
| Library | Authorized publisher uploads real video, tags it and assigns it to an eligible player. Player can view assigned content without broad library access. Removed/expired media handled clearly. |
| Reports/earnings | Each KPI reconciles to approved source query and period. Empty/no-denominator cases show unknown or empty. Cross-location access denied without explicit grant. Refund/chargeback cases reconcile where applicable. |
| Exports | Export contains only authorized data; CSV escapes formula-leading values. Ready link resolves to an actual artifact; queued work does not claim completed delivery. Expiry/deletion/revocation behaviors tested. |
| Push/navigation | Foreground, background and cold start route each supported target after sign-in. Old review payload still works during rollout. Switching accounts never exposes previous user's notification content through APIs. |
| Deletion | Player-owned media and applicable new records processed under agreed matrix. Session deletion invalidates media and thread references. Coach removal does not delete players' sessions. |
### 11.4 Rollout and verification boundaries
Use additive schema migrations and compatible reads before switching screens. Introduce capability/feature gating for new domain features whose rules remain undefined. Do not require new response fields from an old server until deployed; fail visibly rather than falling back to fabricated demo content. Instrument request failure rates, idempotency conflicts, notification outbox backlog and export failures.
Validation of this document is a static traceability and consistency check, not an application test run or verification of live backend behavior. Implementation teams should run contract, authorization, transaction/concurrency and two-account end-to-end tests described above after development.
## 12. Consolidated API inventory
**Counting rule:** One unique HTTP method + path is one endpoint. Primary proposed endpoints exclude unchanged operations, conditional N34 and consolidated N51. Changes C01–C08 are change packages, not eight additional new endpoints; some span multiple existing operations or internal processing.
**49 primary proposed endpoints:** 16 Critical, 18 High, 11 Medium, 4 Low. One conditional invitation proposal would bring the adopted set to 50 if confirmed. No separate coach-activity endpoint is required by the current screen.
| ID | Method | Suggested path | Purpose | Priority |
| --- | --- | --- | --- | --- |
| N01 | GET | `/v1/me/settings` | Read effective settings | Critical |
| N02 | PATCH | `/v1/me/settings` | Update preferences | Critical |
| N03 | POST | `/v1/me/consent` | Record consent acceptance | Critical |
| N04 | DELETE | `/v1/me/consent` | Withdraw analysis consent | High |
| N05 | POST | `/v1/me/exports` | Request all-video export | Low |
| N06 | GET | `/v1/notifications` | List in-app notifications | Critical |
| N07 | GET | `/v1/notifications/unread-count` | Read notification badge | Critical |
| N08 | POST | `/v1/notifications/{id}/read` | Mark one notification read | Critical |
| N09 | POST | `/v1/notifications/read-all` | Mark viewed notification batch read | High |
| N10 | GET | `/v1/threads` | List authorized conversations | Critical |
| N11 | GET | `/v1/threads/{id}` | Read conversation and messages | Critical |
| N12 | GET | `/v1/sessions/{session_id}/thread` | Resolve session conversation | Critical |
| N13 | POST | `/v1/threads/{id}/read` | Advance participant read watermark | Critical |
| N14 | POST | `/v1/threads/{id}/messages` | Send text, audio or session attachment | Critical |
| N15 | POST | `/v1/coach/players/{player_id}/thread` | Resolve or start player conversation | High |
| N16 | GET | `/v1/players/{player_id}/goals` | Read current goal | Critical |
| N17 | PUT | `/v1/players/{player_id}/goals/{mode}` | Set or replace goal and weekly targets | Critical |
| N18 | GET | `/v1/players/{player_id}/goals/history` | Read scoped historical goals | High |
| N19 | GET | `/v1/me/milestones` | Read supplemental progress milestones | Medium |
| N20 | GET | `/v1/drill-assignments` | Read authorized assignments | Critical |
| N21 | POST | `/v1/coach/players/{player_id}/drill-assignments` | Assign catalog/library drill | Critical |
| N22 | POST | `/v1/drill-assignments/{id}/sets` | Log assignment set completion | Critical |
| N23 | GET | `/v1/me/arm-care` | Read outings and rest assessment | High |
| N24 | POST | `/v1/me/arm-care/outings` | Log game pitch count | High |
| N25 | PUT | `/v1/me/arm-care/feel` | Record current arm feel | Medium |
| N26 | GET | `/v1/me/coach-access` | Read coaching-access application | High |
| N27 | POST | `/v1/me/coach-access` | Apply using staff code | High |
| N28 | GET | `/v1/academy/groups` | List visible player groups | High |
| N29 | POST | `/v1/academy/groups` | Create group and membership | High |
| N30 | GET | `/v1/coach/players/{player_id}/note` | Read private coaching note | High |
| N31 | PUT | `/v1/coach/players/{player_id}/note` | Save private coaching note | High |
| N32 | GET | `/v1/academy/members` | Search players available for roster addition | Medium |
| N33 | POST | `/v1/coach/roster/players` | Add selected academy players | Medium |
| N35 | GET | `/v1/academy/library` | Read academy drill library | High |
| N36 | POST | `/v1/academy/library` | Publish uploaded library drill | Low |
| N37 | GET | `/v1/academy/dashboard` | Read academy dashboard aggregates | Medium |
| N38 | GET | `/v1/academy/earnings` | Read revenue share and payout history | Medium |
| N39 | GET | `/v1/academy/corp` | Read permitted cross-location reporting | Low |
| N40 | GET | `/v1/academy/coaches` | List academy coaching members | Medium |
| N41 | GET | `/v1/academy/coaches/{id}` | Read coach management detail and activity | Medium |
| N42 | PATCH | `/v1/academy/coaches/{id}` | Edit permissions, groups or pause state | Medium |
| N43 | DELETE | `/v1/academy/coaches/{id}` | Remove coach and reassign roster | Medium |
| N44 | GET | `/v1/academy/coach-requests` | List coaching access requests | High |
| N45 | POST | `/v1/academy/coach-requests/{id}/decision` | Approve or decline access request | High |
| N46 | GET | `/v1/academy/staff-codes` | List staff access codes | High |
| N47 | POST | `/v1/academy/staff-codes` | Generate controlled staff code | High |
| N48 | DELETE | `/v1/academy/staff-codes/{code}` | Revoke future code use | High |
| N49 | GET | `/v1/academy/consent` | Read academy consent records | Medium |
| N50 | POST | `/v1/academy/consent/export` | Export scoped consent CSV | Low |
### Endpoint totals by module
| Module | Endpoints |
| --- | ---: |
| Settings and consent | 5 |
| Notifications | 4 |
| Conversations | 6 |
| Goals and milestones | 4 |
| Drill assignments | 3 |
| Arm care | 3 |
| Coach access | 2 |
| Groups, roster and notes | 6 |
| Academy library | 2 |
| Academy reporting | 3 |
| Academy staff | 9 |
| Consent administration | 2 |
| **Total primary** | **49** |
### Changes inventory
| Change | Scope | Priority |
| --- | --- | --- |
| C01 | Review-to-thread transaction, optional review audio and review read representation | Critical |
| C02 | Audio/library upload purposes and authorized media access | Critical |
| C03 | Account academy/capability projection and dual-role integration | Critical |
| C04 | Roster group IDs and current membership visibility | High |
| C05 | Notification production, delivery payload and deep-link routing | High |
| C06 | Account/session deletion and related data/media lifecycle | High |
| C07 | Server enforcement of consent/sharing preferences | Critical |
| C08 | Assignment sets integrated into practice logs/progress | High |
### Source index for implementation handoff
| Source | Relevant evidence |
| --- | --- |
| `src/mock/types.ts` | Current app-side feature shapes; absence of player ID in AssignedDrill; incomplete access status enum |
| `src/mock/endpoints.ts` | All local mutation behavior, unscoped history, static aggregates, restFor and review upsert |
| `src/mock/seed.ts` | Demo defaults, fixed financial/health data, sample users; not production requirements |
| `src/mock/store.ts / src/mock/useMock.ts` | Per-user persistence and local mutation notifications |
| `src/api/client.ts` | JSON request parser, method union, errors, token refresh and idempotency header support |
| `backend-docs/openapi.json / src/api/types.ts` | Checked-in integrated shapes used to identify additive changes only |
| `src/state/AppContext.tsx` | Account load/reset and best-effort local review bridge |
| `src/state/useLoad.ts` | Mount/focus loading and explicit focus:false override |
| `src/navigation/types.ts / PlayerTabs.tsx / CoachTabs.tsx / RootNavigator.tsx` | Route inventory, role-based navigation and push listener |
| `src/push/index.ts` | Current review/session-only push route |
| `src/screens/player/SettingsScreen.tsx / GuideScreen.tsx` | Consent and sharing promises; export toast; fail-open consent handling |
| `src/screens/player/ThreadScreen.tsx / messages/Composer.tsx / messages/VoiceNote.tsx` | Message variants, 500-character limit, fixed voice send and simulated playback |
| `src/screens/player/HomeScreen.tsx / HistoryScreen.tsx / ReportCardScreen.tsx` | Goal/progress consumers, duplicated rest rules, current-goal month mismatch and native-only sharing |
| `src/screens/player/ArmCareScreen.tsx` | Observed pitch logging/feel controls and unsupported workload/alert promises |
| `src/screens/player/DrillsScreen.tsx / DrillScreen.tsx` | Assignment list, local reps and completed-set mutation |
| `src/screens/coach/parts/AssignDrillSheet.tsx` | Missing player identity, relative due labels and source options |
| `src/screens/coach/GoalEditScreen.tsx` | Goal types, target ranges, weekly targets and 160-character note limit |
| `src/screens/coach/CoachPlayerScreen.tsx / CoachHistoryScreen.tsx / QueueScreen.tsx` | Unscoped assignment/history queries and drill-name completion matching |
| `src/screens/coach/AddPlayersScreen.tsx / CreateGroupScreen.tsx / RosterScreen.tsx` | Hardcoded candidates, native invitation branch, lost selected IDs and unapplied group filter |
| `src/screens/coach/ReviewScreen.tsx / TeamScreen.tsx` | Audio simulation, local thread lookup, assumed Admin badge and deletion copy |
| `src/screens/admin/*.tsx` | Management actions, fixed group choices, ignored reassignment selection, report and export/upload placeholders |
|