Given a full-stack Movie DB application where users can log in, create, update, and delete watch lists, and add/remove movies, debug and fix the backend handler logic so all unit tests pass with correct persistence and HTTP responses. Asked in the Technical Round 2 (LLD / Maintainable Code + LP) stage. Implement the routing logic over a pre-existing in-memory model.
Implement process_requests(state, requests). Return {"responses": [...], "state": state}. Requests support login, create_list, update_list, delete_list, add_movie, and remove_movie. Each response contains status and body. Successful mutations must persist in state; unauthorized or invalid requests must leave it unchanged.
state contains users, sessions, lists, and integer next_list_id keys.password string.owner, name, and a list of movie IDs.def process_requests(state, requests):