End Session
When the user stops recording, the app signals session end; the server marks the session as ended and triggers ingest for any windows that have accumulated data but have not yet been processed.
Flow
-
User stops recording — The mobile app sends a
POSTrequest to/sessions/{sessionId}/end. -
Session ID validation —
sessionIdis extracted from path parameters; missing returns HTTP 400. -
Session state fetch — The full DynamoDB session record is read. A missing session returns HTTP 404.
-
Status update — The session's
statusfield is set to"ended". -
Pending window resolution — The Lambda computes which windows have data but have not yet triggered ingest:
- If there are frames in the current (partial) window (
frameCount > 0), that window is treated as completed. - The union of
completedFrameWindowsandcompletedAudioWindowsforms the set of all data-bearing windows. -
Windows already in
ingestTriggeredWindowsare excluded. -
Ingest triggering — For each untriggered window (in ascending order), the Lambda attempts a conditional claim on
ingestTriggeredWindowsand then invokes the ingest Lambda asynchronously with{ sessionId, userId, windowIndex, frameCount }. -
Response — Returns
{ "ok": true, "ingestTriggered": <count> }.
Entry Point
- Lambda:
main/server/api/sessions/end/app.py→lambda_handler - HTTP method:
POST /sessions/{sessionId}/end(API Gateway)
Dependencies
- DynamoDB:
SESSIONS_TABLE_NAME - Lambda:
INGEST_FUNCTION_NAME
Error Cases
| Condition | Response |
|---|---|
| Missing sessionId | 400 |
| Session not found | 404 |