Benzaiten Sensor API – 2022-01-02

Hello, so this is my new project, this one is a real one, so some context:

I plan to build a weather station at home using an Arduino, but for it to be useful, I need to have a Rest API to collect the data.

About the name

I like big projects, and I plan to make a nice unified application to gather multiple metrics for future dometic projects, I’m quite interested in all these application, but I want to own the software I use, for obvious privacy reason. If I can have nice tech stuff, without giving up my privacy. I name this whole project, “Benzaiten” named by the Buddist deity of wisdom. And it gets a bit outside of usual Nordic/Greecs name we give to our toys.

Technology used

I choose to create this API using python 3.10 (with 3.11 readiness), I’ll use flask as the web framework as it’s a lightweight framework and it seems quite easy to deploy.

I want to decouple my application as much as possible so if in the future I want to change some stuff it will be easy, and also I would be easier to share with people using different technology.

For the database, I’ll go for PostgreSQL as I already have a server I use for multiple purposes.

I’ll deploy the API on an ARM64-based Kubernetes cluster and my goal is to take the deployment to auto deploy any changes that hit the production branch using a canary.

Obviously the goal is also to integrate automated integ tests.

Current Status

I started the project in late November, but I pause in December while doing Advent of Code.

For now I’ve made most of the abstract layer of configuration. My idea here is to load configuration for various sources (arguments, environment, files, secrets managers, api calls, etc…). As I want my secrets to be rotated, I’ll need my application to be able to refresh the configuration before using it.

I’ll store my configuration as a tree like mapping of keys to callable that returns the value. Each time I’ll need a configuration parameter I’ll be able to call to the configuration map and get live updated values.

For the moment only arguments and environment variables are done.

It’s all quite crude work, but this whole configuration thingy, might be quite useful in the future, so I’ll use this project to prepare my configuration to be exported as a standalone library in the future.

Next step

My next implementation will be designing the API with an empty skeleton. So I’ll create the PUT /api/metrics entry point as well as GET /api/metric

0 Replies to “Benzaiten Sensor API – 2022-01-02”

Leave a Reply

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