Dattavani Backend: Auth and Identity (parent sign-in, PIN, kid session)

Dattavani Backend: Auth and Identity (parent sign-in, PIN, kid session) A sequence diagram generated by Archify. POST /api/auth/send-otp email or phone sign_in_with_otp skipped for test-authemails 200: code sent, expires in 600 s POST /api/auth/verify-otp otp + device_id verify_otp email type, then signuptype user + access and refresh token parent_profile + device_sessions creates the parent onfirst login; refresh tokenstored per device app_metadata: parent_id, consent, premium after the response; onlylater tokens carry it access + refresh token, user, subscription GET /api/auth/me rpc get_auth_me_bundle children + active childsession, parent RLS bundle user, children, subscription POST /api/auth/pin/verify PBKDF2-SHA512, 390kiterations, server pepper verified POST /api/kids/select-profile parent JWT + kid_id,device_id owns kid? consent? save parent token device_sessions gets thelive parent access token mint HS256, [redacted],12 h kid JWT data.access_token = kid JWT POST /api/kids/refresh-token kid JWT; re-mints from itsown claims new kid JWT POST /api/auth/token/refresh refresh_session new access + refresh rotate device_sessions token kid routes need it to actas the parent new token pair POST /api/auth/signout device_id optional deactivate device session only when device_id issent sign_out falls back to local logout logged_out Parent sign-in (OTP) Profile bundle and PIN Kid profile session Refresh and sign-out Mobile app · parent, then kid · Sequence participant Mobile app parent, then kid Auth routes · user_management.py · Sequence participant Auth routes user_management.py Supabase Auth · OTP, sessions · Sequence participant Supabase Auth OTP, sessions Postgres · parent and session rows · Sequence participant Postgres parent and session rows Kid routes · kids.py · Sequence participant Kid routes kids.py Kid JWT · kid_profile_jwt.py · Sequence participant Kid JWT kid_profile_jwt.py Legend main request return security async trace message