How do you manage state and API communication in a way that keeps the frontend and backend loosely coupled?