Hello!
I am pretty new to Elixir and OTP platform in general, so this might be very stupid question ![]()
I want to build a simple parcel tracking service for myself and my friends. Since I am just learning Elixir and functional programming in general, I want to avoid big frameworks as much as possible. Currently I am only using Ecto for the database connection and data validation, and Req for external API calls.
The idea of the application is that user can send a tracking number to a Telegram bot, and it will periodically fetch the parcel state and notfiy user if there are new events. It will be very low-concurrent application, since itās probably will be used by one or two people, but I still want to use best practices, just for personal education. So I would be very glad to hear experienced developersā opinion on the architecture and approaches I am going to use.
I want to create a GenServer per parcel. It is going to manage the persistence, status updates, and stuff like that. I had the idea that I can just pass the tracking number to GenServer, and let it handle the initial validation by itself. By validation I mean a 3rd party API call, to verify that the tracking number is correct.
First, I am not sure how to implement the initialization. Iāve read that it is not a good idea to do IO inside init, since it is blocking the supervisor, so I am doing it via handle_continue. However, this raises a problem: how do I let the client know that the tracking number they passed is incorrect? I can obviously validate it outside of GenServer, but it feels wrong, since I want to avoid calling that API if I can, and thereās no point in calling the API if I already validated that the certain tracking number is correct, and saved it to the database.
Another thing, is how do I handle the persistence? Currently I plan to have a :timer that will send messages to Parcel server every hour, and Server will call an API, check if there are new tracking events, and save them to the database and its internal state. Is it a correct approach?
Third, who should manage subscriptions? For example, two users want to track the same parcel. Should the list of clients also be stored in the Parcel server, or should I offload this to some other process?
Thanks in advance for any advices ![]()






















