Sensor API – Update – Rework

New Knowledge and full steam ahead:

Recently discovered GraphQL, and that seems to be more fitting on how I want to interact with my API. Also, even though I had fun with the previous implementation and all the fancy designs I worked with. Let’s face it: if I want to complete this application some day (and I want it to move to other projects) I need to get to real quick solution that will be working in a few week time.

So here is the new repository (I keep the old one for some code snippet always nice to have).

Why GraphQL?

Well REST would have worked just as fine with my current application, for storing new data, I feel like the way GraphQL handles queries and mutation is quite nice, and might be a useful skill to learn for the future.

And in the future I might want to retrieve more data in one query, which looks pretty simple with GraphQL.

Base Server:

I choose Strawberry as the implementation is quite similar as dataclasses, this makes things quite simple to work with the data elements I will interact with. The implementation should be really lightweight with little to no overhead. All I have to do is create my structures, interface everything with the database and voilĂ .

Base Data Structures:

The end goal here is to end with a raw list of measurements, from sensors, the external types will be used for filtering and presentation. Having the sensor location is also important.

Storing the address will be a network related address, ideally I will use Wireguard to create a secured network for the sensors. This will depend on how restricted I will be with an arduino. Maybe I’ll evaluate using a raspberry pie nano instead.

Database:

As up for now I’m using PostgreSQL as I already have a server I can use for this application as well. Still I want to avoid coupling with the back-end there, I don’t know how things will evolve in the future, so better stay prepared now.

I will just create a wrapper for the most common SQL databases, this should allow me to a have a very simple access to the SQL clients, but still be usable for noSQL.

I want this interface to also support Data object insertion/update/select by providing the object. And support the setup of the database from the same interface for easy deployment.

Overall I think this will be the longest part to implement once all is set, I should almost be done.

0 Replies to “Sensor API – Update – Rework”

Leave a Reply

Your email address will not be published. Required fields are marked *