Lesson Complete!

Save Your Data

What you learned

  • Why in-memory storage is not sufficient for real applications and how file-based persistence solves the problem
  • How to write a save function that serializes your data to a JSON file using json.dumps() and Path.write_text()
  • How to write a load function that reads the file back, parses the JSON, and converts string keys back to integers
  • How to wire save and load into your existing endpoints so that data persists across server restarts

Next up

Your API is fully functional and persistent. In the final lesson, you will polish it by adding response models so that your API documentation shows exactly what each endpoint returns, including error responses. You will also build a spending summary endpoint as a capstone feature.