Server app for CropDate, an agriculture app that provides updates on crop prices from wholesale markets in Trinidad and Tobago.
Live Demo:
server-demo-link
- Cron job is run every morning, Monday to Friday.
- App checks if the source data is updated or not
- If updated, it fetches the data, parses it, and then updates the database. It also clears the cache
- When the API is called the app caches the data and returns the value
The source data is only updated on weekdays but sometimes skips days so there's a buffer between the job and the function to fetch the data. It checks if the date from the source data (which only changes when the data updates) and the current date align.
I used PostgreSQL and Azure to create the database. I'm not familiar with the syntax so to avoid issues I used an ORM (Prisma). There was no particular reason for using these tools over anything else, I just used the most convenient and reliable tech.