Device Discovery in MQTT: Using Retained Messages as a Service Registry

When you have some number of IoT devices connected to an MQTT broker, one of the major concerns we had is - how do we know what devices came online, what topics they publish to, and what are its other params (device details). Most solutions involve maintaining a separate device registry database. But the idea here is to use MQTT broker itself as a device registry. In typical MQTT deployments, you need to maintain device inventories separately: a database to store device metadata. Still, at this point, the path to write this info to the database write/read has to be created. ...

October 20, 2025 · 5 min

User Attribute-Based Authorization in Multitenant Apps - Django-tenants

This article assumes you’re using django-tenants for schema-based multitenancy (separate PostgreSQL schema per tenant). The authorization pattern described here works specifically with django-tenants’ schema_context() approach. If you’re curious, read the AWS cognito part as well. The Problem When building a multitenant application with django-tenants, we needed to control which PostgreSQL schema each user could access. Each tenant has its own isolated schema, but we needed a lightweight authorization mechanism to ensure users could only access their assigned tenant’s data. ...

April 15, 2025 · 6 min

Django (DRF) Serializers To Handle Nested JSON data

I have been dealing with a lot of JSON data more than ever before. All of the data are coming from a Webhook provider upon certain events. One of the things I was not comfortable with was the nested JSON structure until I found there is a clean way to solve it. Our Django app uses Django REST Framework (DRF) and relies heavily on its serialization capabilities. What are we going to see Looking at the data (JSON/dict) Looking at the model where the data is about to be stored Writing DRF serializer to handle the nested data More details of how its done using to_internal_value() conclusion A sample JSON data for context This is a webhook event when a charging session is started and stopped. Looking at the JSON (data) itself - it has a max depth of 5. ...

October 25, 2024 · 7 min

Python - A Clean Way to Traverse Nested Dict/List

I had to work with some complex structured JSON responses having multiple levels of nesting. The issue has always been that the API would return nested JSON where I have to walk different levels to get data by using x.get('y')[0].get... chains. For this very reason, I was looking for an optimal and efficient solution so that at least I can avoid calling get() many times. The Problem Let’s say you’re working with user data from an API: ...

August 28, 2024 · 3 min

Auth0 as OpenIDC broker in AWS Cognito for AzureAD multi-tenancy support

If you read the previous article OAuth using AWS Cognito, then you should be also reading this. I’m writing this article after a month of this very story. But I believe I won’t miss much. SAML, OIDC setup and overview If we look into the out-of-the-box social identity providers , there are few. If we want to add Microsoft/Azure, that would be done via SAML or OpenID connect. Due to our client requirement, we started working on integrating Azure (now Entra) into Cognito via SAML. In Azure, to setup SAML, we start by creating an Enterprise Application. ...

March 24, 2024 · 5 min

Django OAuth setup with social login, AWS Cognito, GitHub - Full story

I spent some quality time researching about OAuth in Django. Tried more than 3 packages. Well, it was not just about just installing something and expect everything to work. There was some tinkering which i think i did well. Therefore, this some part of this blog might also help in your case i guess. I will be also uploading a YouTube video of the same, if i do, you can find the video at the bottom of this page. ...

January 25, 2024 · 12 min

Global variables in AWS λ are dirty!

Hello everyone, I know that it has been a long time since i wrote a post. I hope every thing is going well with you. I always wanted to consistently write here. But lets see if I can make it possible sometime soon :) What is this post about? Today, as usual i started off the job in the morning. I’m at a juncture point of building a part of the project. There again, we need yet another micro-service. So, I started writing a piece of script (Python) that needs to be deployed in AWS Lambda. This usually should only take couple of hours, max. But, after that i wrote it, I realized that, half the time writing the script was spent on debugging an issue that i did not even understand how/why it happens. After finding the why/how, I thought it’ll good to share it here and someone will find it useful on the way. ...

November 1, 2023 · 4 min

POV: 'smart-work' over 'hard-work'

Let me start off by this simple quote: The Only Way to Do Great Work is To Love What You Do - Steve Jobs The best way to inherently learn more is by doing what you really like. Say it’s software dev, farming, carpentey or any task. If you enjoy/like it, you would love doing it and also learn from experience. This is what we already know. Our mind simply grasp things that we really like and if we put in more work in the same, we will become better on that. I thought I would say this first because, this is something I always told myself in my head. ...

August 28, 2022 · 6 min

what does the Bible say about jobs 👷‍♂️

Are you a wagie? Most probably you are unless you have some passive/active income from your product. Over the past decade, I’ve seen many people jumping from a mechanical engineer role to a software field. Reason is quite obvious. I don’t want to tell you that software industry now provides more employment. It’s really good if you enjoy it. What if you are not interested in but still working on it.? I don’t know how it feels like considering money comes on top of it as a reward. ...

July 31, 2022 · 7 min

Introduction to Termux-API and script automation 🧑‍🔧

Welcome back to yet another amazing article. By the way, have you seen the new video uploaded at YT? This article is about about the same. Now, If you think about why do I write this blog after creating a video - well, a video is mostly a quick take (for me). We miss many things. Writing a blog mostly explains everything. Yes, now you have an idea about what I’m talking about. It’s about Termux-API and how we can make use of them in real life applications. ...

July 1, 2022 · 4 min