I’m building an expense tracker app, and live streaming the whole process! This blog series is a written form of each livestream.
Before writing the iOS app, I wanted to plan how it will interact with the database. I’m writing both the front-end, iOS app, and backend, using Vapor and PostgreSQL, so eventually I would have had to plan both sides, but for me, understanding what data looks like will help me write a better iOS app.
I went through and started to think of what the data models and API endpoints are going to look like.
One big roadblock I ran into during this stream was deciding what data type to use for currency. I wanted the app to start out with only USD (United States Dollar), but later want to expand it to use any currency. Currencies are all very different. They’re represented in different ways and have different amount of numbers after the decimal point. Given that, I didn’t know if Double
, Float
, Int
, or something else would be best.
I landed on money
for the PostgreSQL database and Decimal
for the Swift model, later changed in the next stream.
Once all the models / tables were mapped out I started planning the endpoints. I need CRUD endpoints for every table. This means create, read, update, and delete, 4 different endpoints for a single table.
Lastly, I looked at the Swift charts that I am planning on using and started to think about other endpoints that would make it easier to show chart data (cumulative data), rather than calculating it on the iOS side. This resulted in 2 more endpoints to show monthly income and yearly income.
Everything is still in a planning phase and not set in stone. Which is the point! To plan early to help move development along, but it doesn’t have to be set in stone, and never change.