<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by kaveesha gimhani on Medium]]></title>
        <description><![CDATA[Stories by kaveesha gimhani on Medium]]></description>
        <link>https://medium.com/@kaveeshagimhani?source=rss-7c302a19d4b9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LjSiXmnZJoxtUnOtYyApcQ.png</url>
            <title>Stories by kaveesha gimhani on Medium</title>
            <link>https://medium.com/@kaveeshagimhani?source=rss-7c302a19d4b9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 20:34:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kaveeshagimhani/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Would you still love me if I was a worm? ]]></title>
            <link>https://medium.com/@kaveeshagimhani/would-you-still-love-me-if-i-was-a-worm-069b858a3b83?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/069b858a3b83</guid>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[love]]></category>
            <category><![CDATA[human-behavior]]></category>
            <category><![CDATA[relationships]]></category>
            <category><![CDATA[dating]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 16:00:46 GMT</pubDate>
            <atom:updated>2026-09-27T16:00:46.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XyKXOWSYSUytYxVUr11zRA.png" /></figure><p>An outwardly silly question that hides a surprisingly serious skepticism about unconditional love, replaceability, and whether love can exist without any expectation.</p><p>Or in other words,</p><p><strong>Would you still love and care for me the same way when im completely vulnerable, helpless, and had nothing to offer you?</strong></p><p>Because human love and relationships are often tied to what someone brings into our lives and the other things about them that make them worthy of our affection.</p><p>We love someone’s sense of humor, their intelligence, how they make you feel, their beauty, their companionship, their ability to make us feel seen, loved, understood and excited.</p><p>And this is where the worm crawls in.</p><p>What happens if you remove all that?</p><p>Is love still love? Or have we created a very emotionally sophisticated business transaction?</p><p>But there is something dishonest about pretending that human relationships have nothing to do with what people bring into each other’s lives. Of course they do. We choose people partly because of what we love about them. Their personality, their humor, their weird little habits and ridiculous messages become our favorite things about them. If you remove all of those things, you wouldn’t necessarily have the same relationship anymore.</p><p>A relationship is built through experiences, memories, attraction, compatibility, trust, affection and everything two people create together.</p><p>So maybe the problem is not that our love has conditions. The problem seems to be that we sometimes interpret having conditions as meaning that the love isn’t real. But there is a difference between “I love you because you are exactly this person” and “I only love you as long as you continue providing me with something”.</p><p>The first is human. Second is transactional.</p><p>And perhaps the worm question is trying to figure out which one we are experiencing.</p><h3>The worm question: more than a tiktok meme</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_Kk84vxRlQyqvdO3eWK0g.jpeg" /></figure><p>Our absurd question directly challenges this idea that our partner might only be there with us for what we have to offer. And if that variable is taken out of the equation, would their love remain the same or will they eventually deviate to someone who can offer them something more?</p><p>And a worm removes almost every source of value when substituted for a person: no beauty, no care, no intimacy, no status, no companionship, no shared hobbies, cannot even communicate. Just crawling around eating mud…Literally the worst possible candidate for a “human” relationship.</p><p>This translates into, <em>if everything that makes me desirable disappears, would you still choose me?</em></p><p>It completely strips a person down to almost nothing and asks whether there is still something left that makes them worth choosing. Because if all the things that make me desirable disappear, what exactly is left?</p><h3>Why does it sound “feminine”?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*yzAT2TnLqDpaP-J02xszHg.jpeg" /></figure><p>You see, women aren’t naturally programmed to ask absurd worm questions to ragebait their significant other. (Although, if you ask me, it is a pretty fun activity). It is more connected to how women are socialized to experience relationships and emotional security.</p><p>We are often encouraged and naturally pay close attention to the emotional state of the relationship. We tend to notice changes in affection, communication, energy, and sometimes that awareness turns into a need to know whether we are still being chosen.</p><p><em>Do you still love me?</em></p><p><em>Are you losing interest?</em></p><p><em>Do you think someone else is prettier?</em></p><p>And somewhere between all those questions is a much bigger one:</p><p><strong><em>Am i still the person you choose when all the odds are against me?</em></strong></p><p>So perhaps the question isn’t uniquely feminine at all. It is simply a fun way to ask for reassurance and emotional security.</p><h3>But men have their own version</h3><p>The idea that men don’t ask such questions and that it is an absurd feminine invention is not true. The question just tends to take a different form.</p><p><strong>“Is she with me because of what I can provide?”</strong></p><p>Money, security, success, social position?</p><p>For some men, the fear isn’t necessarily about them losing their desirability but rather a question about whether their partner would choose them if they come into a position where they can no longer provide. Losing a job, money, status can turn that fear into a very real question about whether someone loves you or the life you create for them.</p><p>So in reality, both men and women are asking the same question but in different ways.</p><h3>Why are we so compelled to ask?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7bi4lg9klSC8GbFcpoFSA.jpeg" /></figure><p>Maybe sometimes it’s just for fun. Sometimes you genuinely want to see your significant other struggle with the finding the right answer that won’t offend you while remaining truthful.</p><p>But as i see it, there is something beneath it. An actual relationship need.</p><p>This question at its core, is the need for <strong>reassurance</strong>. Even though personally we should be able to ask the most uncomfortable questions from our partner, it’s not the case for everybody. Most people feel embarrassed to explicitly ask for reassurance because it can seem pretty desperate or clingy.</p><p><strong>Would you love me when i can’t give you anything?</strong></p><p><strong>Would you love me if i get bed ridden and you have to take care of me for the rest of my life?</strong></p><p>Questions that seem too desperate, too vulnerable, too clingy to ask directly. So instead we ask a fun ridiculous question because even if the answer is bad, we can still laugh.</p><p>We can hide our vulnerabilities and fears behind a worm question.</p><p>What if i stop being everything you love about me?</p><p>What if i’m not beautiful anymore?</p><p>What if i can’t take care of you?</p><p>What if i’m boring and sit stationery all day eating mud?</p><p>What if someone better comes along?</p><p>What if i become helpless?</p><p>What if i can’t satisfy your needs?</p><p>What if i becomes completely useless?</p><p><strong><em>Would you still choose me?</em></strong></p><h3>The worm was never the actual question</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ERTD43MPOjlsCZAW3S8XA.jpeg" /></figure><p>One might feel uncomfortable about looking at the person you love and saying <em>“Please reassure me that you would still love me if i became someone completly different”. </em>So we turn it into a joke,</p><p><strong><em>“Would you still love me if I was a worm?”</em></strong></p><p>And if they say yes, you get the reassurance you were looking for.</p><p>But then comes the interesting part. Because if you really became a worm, I don’t know what love would even mean anymore. What would loving you even look like.</p><p>Would i put you in a nice terrarium?</p><p>Would i feed you mud?</p><p>Would i introduce you to other worms?</p><p>Would i still call you by your name?</p><p>Should i tuck you into bed?</p><p>Am i supposed to spend an unreasonable amount of money making your little worm enclosure luxurious?</p><p>At some point the question stops being about whether i would love you and starts becoming a question of how i would love you. Because obviously i can’t love you in the exact same way i did when you were a human.</p><p>If the way i love you changes, does that mean i love you less? or does it simply mean that love adapts to the person who is receiving it? Because we already accept thisin other forms on love. We love our pets deeply, but we don’t love them in the same way we love a romantic partner. We feed them, we learn their little habits, we worry when they’re sick and we love them without expecting anything in return. And that love is real.</p><p>So if you become a worm and i continued caring for you, protecting you, feeding you, keeping you safe and treating you as something precious because i knew you were still you, would that love be the same love? or a different kind of love?</p><p>So when we ask someone the worm question, maybe we are really asking them whether the care will remain.</p><p>Maybe unconditional love doesn’t mean that i will love you exactly the same way regardless of what happens to you. Maybe it means even if everything about you changes, i will still recognize that you are someone worth loving.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=069b858a3b83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Emotional Storytelling in Moon Lovers: Scarlet Heart Ryeo]]></title>
            <link>https://medium.com/@kaveeshagimhani/the-art-of-emotional-storytelling-in-moon-lovers-scarlet-heart-ryeo-a9692c873516?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9692c873516</guid>
            <category><![CDATA[scarletheartryeo]]></category>
            <category><![CDATA[tv-analysis]]></category>
            <category><![CDATA[korean-drama-review]]></category>
            <category><![CDATA[moonlover]]></category>
            <category><![CDATA[kdramareviews]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sat, 09 May 2026 09:17:19 GMT</pubDate>
            <atom:updated>2026-05-09T09:17:19.792Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1am37ZHaW0Z_JsLcmpgKw.png" /></figure><p>It’s 2026, and somehow the internet has collectively decided to romanticize 2016 again. Old makeup trends, fashion, playlists, songs, movies, Tumblr aesthetics, and the strange but bittersweet nostalgia of a time that felt simpler.</p><p>Somewhere along that wave of nostalgia, I found myself wanting to revisit drama that I have been avoiding for years.</p><p><em>Moon Lovers: Scarlet Heart Ryeo</em></p><p>Released in 2016, this <em>Goryeo-era</em> drama became a story that never fully leaves you. Not because it was perfect. But because it left something behind. An emotional weight that lingered long after it ended.</p><p>The first time I watched it, it didn’t feel like I had simply finished a drama. It felt like I had lived through it alongside the characters through their laughter, their small moments of peace, carrying their grief, their hope and the quiet helplessness that followed every choice they could not undo.</p><p>Because before the politics, the betrayals, and the grief, there was innocence. There were moments when they laughed without fear, loved without suspicion, and believed life could remain that way.</p><p>Watching that slowly disappear scene by scene, episode by episode as the atmosphere turned heavier and every moment of happiness became something fragile, was what made the story so devastating.</p><p>I wasn’t just mourning the ending. I was mourning the loss of who they once were before everything changed.</p><p>Some stories entertain you, but others leave a mark. Scarlet Heart Ryeo was one of those rare dramas that felt almost too heavy to return to.</p><p>Part of the reason I finally decided to rewatch it was to test my own memory. I wanted to know if nostalgia had exaggerated it into something greater than it was, or if it truly deserved the emotional reputation it still holds years later.</p><p>Rewatching it now, years later, I realized the pain was never just in the ending. It was in the writing, in the quiet scenes, the pauses, the things left unsaid. and the way ordinary moments were made to carry unbearable emotional weight.</p><h3>A Story Built on Love, Timing, and Loss</h3><p>Set in the <em>Goryeo</em> dynasty, <em>Moon Lovers: Scarlet Heart Ryeo</em> follows <em>Go Ha Jin</em> (later <em>Hae Soo</em>), a modern woman who suddenly finds herself transported back in time into the middle of royal politics, power struggles, and the dangerous lives of the princes of <em>Goryeo</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*0RkqTCXbeIEUC3SeX91CxQ.png" /></figure><p>What begins as a story filled with curiosity, humor, and unexpected relationships slowly transforms into something far heavier. As <em>Hae Soo</em> becomes entangled with the royal family, especially with the feared and misunderstood <em>Fourth Prince, Wang So</em>, the drama shifts from historical romance into a tragedy shaped by timing, power, survival, and choices that cannot be undone.</p><p>What made the story unforgettable for me was never just the plot itself, but how certain scenes were written and portrayed with such emotional precision that they stayed long after the episode ended.</p><p>Some scenes were quiet, almost simple on the surface, yet they carried more emotional weight than dramatic confessions ever could. They were the moments where silence said more than dialogue, where a single gesture meant more than an entire speech.</p><h3>Love Without Asking to Be Chosen : Lady Myung Hee’s Death Scene</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*UXq_X7ct3idHaApgib0bCw.png" /></figure><p>One of the earliest scenes that stayed with me was the death of <em>Lady Myung Hee</em>, the wife of the <em>Eighth Prince Wang Wook</em>.</p><p>For me, this scene is the entry point that set the trigger for the emotional turmoil that were about to roll out in the rest of the story. It was the first warning that this story would not protect the people who loved the most. First of the many deaths that were about to happen.</p><p>What made this scene unforgettable wasn’t the tragedy of her death, but the way it was written.</p><p>It would have been easy and predictable to make her die on a royal bed, surrounded by the people who cared about her. In fact, there were multiple moments where I kept expecting that. It felt like the obvious direction the story would take.</p><p>But it didn’t.</p><p>On the day she knew would likely be her last, Myung Hee asked for something simple: she wanted to see her husband and take one final walk with him in the snow. There was no anger, no confrontation, no desperate attempt to hold on. Just one last ordinary moment with the person she had loved for most of her life.</p><p>As they walked together, with Hae Soo quietly following behind, there was already a sense of silent farewell in the air. Myung Hee was tired, physically weak, but emotionally calm. As always. She was not fighting death anymore. She was accepting it.</p><p>She did not die surrounded by luxury or on a royal bed, despite being a princess. Instead, she died in the arms of the man she had loved quietly and faithfully for years. Her final moments spent leaning on his shoulders, not in comfort, but in closeness.</p><p>As he carried her, she reflected on the first time she saw him — the moment she fell in love. Even in her final moments, her heart returned not to regret, but to love.</p><p>That says everything about who she was.</p><p>Her entire life had been spent serving her husband with devotion, carrying both love and insecurity at the same time. Because of her illness, she constantly felt inadequate, as though she could never fully be enough for him. Yet she never allowed that pain to turn into bitterness.</p><p>Even after realizing that the Eighth Prince’s heart was slowly turning toward Hae Soo, she did not respond with jealousy or resentment. She remained gentle. She continued to love him with dignity, offering care without demanding anything in return.</p><p>That made her tragedy even heavier.</p><p>She loved him fully, but she died before hearing the one thing she deserved most. To know that he loved her too. How she took her last breathe before Wang Wook could complete his sentence “I love….”.</p><p>Because Lady Myung Hee was never written as a dramatic victim. She was written as something far more painful: someone who loved deeply, asked for little, and left too soon.</p><h3>When One Walked Away and Another Stayed : Court Lady Oh’s Death, Wook’s Betrayal, and Hae Soo’s First Acceptance of Wang So</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*MUm9cJMq-3oN7nrxACxDcA.png" /></figure><p>The next emotionally wrecking set of scenes come with the framing of Hae Soo for poisoning the <em>Crown Prince Wang Moo</em>. In place of her death, <em>Damiwon Court Lady Oh</em> ,her senior, who was a motherly figure to Hae Soo begged to be executed in place of Hae Soo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*ILeDC8ogjT-s08rtPCNQwg.png" /></figure><p>Hae Soo, with her injured knee from the multiple beatings during her questionings, and her fragile body, sat under the rain and continued her protest to pardon Court Lady Oh. Here we see Wook coming towards Soo in the rain, hesitant, guilty. Then he turns his back on her while she watches him go away at a vulnerable moment in her life, when she needed him the most. Next scene we see the Fourth Prince Wang So, standing beside her, covering her from the rain. Unlike the Eighth Prince, he isn’t hesitant to show his love and care towards her. As we see Hae Soo watch Wook turn his back on her, there is a moment where we see her slowly accept the fact that Wook was no longer there at her most vulnerable and she leans back towards Wang So, getting under his shelter, covered from the rain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*ATIlpd_QrwQ7ofwftKn3Ug.png" /></figure><p>This moment signifies the first point where Hae Soo, finally accepts Wang So’s care for her and it’s a moment of foreshadowing and turning point in the story.</p><p>The cinematography here is simple, but devastating.</p><p><em>One man walks away.<br>Another quietly stays.</em></p><p>That visual says more than dialogue ever could.</p><p>And then comes the smallest but most important moment: <em>Hae Soo leans back.</em></p><p>After watching Wook turn his back on her, she slowly allows herself to move under Wang So’s shelter. It is not dramatic. There is no confession. But emotionally, it is enormous.</p><p>It is the first moment she truly accepts Wang So’s care.</p><p>That small movement becomes a turning point in the entire story.</p><p>It is not just about romance. It is about trust. It is about realizing who remains when everything falls apart.</p><p>I loved how carefully this scene was written because it understood that emotional shifts do not happen through grand speeches. Sometimes they happen in silence, in hesitation, in the choice to stay, and in the quiet decision to finally let someone protect you.</p><h3>The Fourteeth Prince, Hae Soo’s Final Moments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*C8-6rN5xGc8J7CEC8NAq7A.png" /></figure><p>As the story moves toward its ending, the tragedy in <em>Moon Lovers: Scarlet Heart Ryeo</em> becomes quieter, heavier, and far more isolating.</p><p>The deaths are no longer shocking. They are expected.</p><p>What changes is the emotional atmosphere.</p><p>There is a growing stillness in these final episodes. A sense of loneliness that lingers in every scene. And a large part of that comes not just from the writing, but from how the drama uses its OST.</p><p>The music does not overwhelm the scenes. It lingers softly, almost like an echo, allowing the silence, the distance between characters, and the emotional exhaustion to settle in. It makes the loneliness feel real.</p><p>By the time we reach Hae Soo’s final moments, the story is no longer about dramatic loss. It is about quiet resignation.</p><p>And what makes her death especially painful is not just that she dies — but <em>who is there, and who is not.</em></p><p>Wang So, the person who loved her most intensely, is absent.</p><p>Instead, she dies leaning against the <em>Fourteenth Prince, Wang Jung</em>.</p><p>This choice is deliberate.</p><p>Because the Fourteenth Prince represents a completely different kind of love. One that is steady, uncomplicated, and without expectation.</p><p>From the beginning, his feelings for Hae Soo were never driven by possession, power, or timing. He did not need her to choose him. He did not try to force himself into her life. He simply remained constant.</p><p>That kind of love is often overlooked because it is quiet.</p><p>But in her final moments, that quiet presence becomes everything.</p><p>He is there not as someone demanding to be loved back, but as someone who understands her.</p><p>He was the only one who truly recognized the life Hae Soo wanted. Not a life bound by palace politics or royal expectations, but something peaceful, distant, and free. And more importantly, he was willing to give that to her.</p><p>That is what makes his presence in her final moments so meaningful.</p><p>Not because he “won,” but because he stayed true to what she needed, not what he wanted.</p><p>At the same time, Wang So’s absence is equally important.</p><p>It reinforces one of the drama’s central ideas: love, no matter how intense, is not always enough to survive timing, circumstance, and the weight of the choices that come with power.</p><p>Both Wang Wook and Wang So, in different ways, moved toward the throne with the belief that power would allow them to protect Hae Soo.</p><p>And yet, that very pursuit is what distanced them from her.</p><p>The closer they came to power, the further they moved from the kind of presence she needed.</p><p>Because the throne is not just authority. It is responsibility, calculation, and sacrifice. It demands decisions that serve stability over personal desire, even when those decisions come at the cost of the person you love most.</p><p>In the end, both men failed her, not because they did not love her enough, but because the paths they chose made it impossible to be there when it mattered most.</p><p>Hae Soo does not die in the arms of the person she loved most.</p><p>She dies beside the person who understood her most.</p><h3>Love Remembered Too Late</h3><p>One of the most quietly tragic patterns throughout <em>Moon Lovers: Scarlet Heart Ryeo</em> is how its characters only seem to fully understand the people who loved them after they are gone.</p><p>Not during the relationship.<br>Not while they still had time.</p><p><em>Only after loss.</em></p><p>And the drama repeats this pattern again and again in different forms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*MTe2gvhaJzGII1ShDkH_Jw.png" /></figure><p>One of the examples comes near <em>King Taejo’s</em> final moments. As he approaches death, the story does not focus on power, his legacy, or the throne. Instead, his mind returns to the court lady he truly loved. The woman who could never become queen because she lacked royal status, yet remained by his side quietly for years.</p><p>Even at the end of his life, it is not politics he remembers.</p><p>It is love.</p><p>That detail says a lot about the drama’s writing. Beneath all the royal conflict and power struggles, <em>Scarlet Heart Ryeo</em> constantly reminds us that emotional connections are the only things that truly linger.</p><p>The same tragedy repeats itself with Wang Wook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*-OXljD0YlJuhadDsLZwmXA.png" /></figure><p>For much of the story, he spends so much time chasing power, status, and the possibility of protecting Hae Soo that he fails to fully see the person who had already devoted her life to him: Lady Myung Hee.</p><p>But later, when the <em>Thirteeth Prince, Baek</em> <em>Ah</em> asks whether he still thinks about Hae Soo, the memory that surfaces is not Hae Soo.</p><p>It is <em>Myung Hee</em>.</p><p>The woman he only fully understood after losing her.</p><p>That moment quietly completes the tragedy of their relationship.</p><p>And this is what I think <em>Moon Lovers: Scarlet Heart Ryeo</em> understood so well about human emotion: people often fail to recognize the depth of love while they are still living inside it.</p><p>The drama is filled with characters who spend too much time chasing what is distant, only to be haunted by what was quietly beside them all along.</p><p>That emotional pattern is what gives the story its lingering sadness.</p><p>Not just death, but delayed understanding.</p><p>Not just heartbreak, but realization arriving too late.</p><h3>Trying to Prevent Fate, Only to Create It</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Iet-umTRYvluziHhzY0yoA.png" /></figure><p>One interpretation I kept returning to while rewatching <em>Moon Lovers: Scarlet Heart Ryeo</em> was the idea that many of the tragedies in the story may have happened precisely because Hae Soo knew the future.</p><p>From the beginning, Go Ha Jin carries the burden of historical knowledge since she’s from the future. She already knows the kind of king Wang So will become, the bloodshed associated with his name, and the fate awaiting many of the princes.</p><p>And because of that, she spends much of the story trying to prevent history from repeating itself.</p><p>Especially when it comes to Wang So.</p><p>Again and again, she pleads with him not to kill his brothers, constantly fearing the version of him history remembers rather than fully trusting the person standing in front of her.</p><p>But the tragedy is that her fear often becomes the very thing that creates distance, misunderstanding, and eventually loss.</p><p>The clearest example of this, for me, is the death of the <em>Tenth Prince Wang Eun</em> and his wife <em>Park Soon Deok</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*JIdhkQr_S8hSJ6H7C4cSgQ.png" /></figure><p>When Wang So searches for them, Hae Soo lies about their whereabouts because she believes he intends to kill them. In her mind, she is trying to stop the future she fears.</p><p>But in reality, Wang So wanted to protect them.</p><p>And because she hides the truth, the Tenth Prince and his wife fail to escape safely. Instead, they are cornered and killed within the palace grounds.</p><p>That moment feels deeply tragic because the story almost suggests a cruel paradox: the harder Hae Soo tries to change fate through fear of the future, the more she unintentionally moves events toward the very outcome she wanted to avoid.</p><p>It turns her knowledge of history into both a gift and a curse.</p><p>She is not just trapped by fate.</p><p>In some ways, she becomes part of its execution.</p><p>And I think that idea adds another layer of sadness to the drama, because many of its tragedies are not caused by hatred or evil intentions, but by love, fear, and the desperate desire to protect the people they care about.</p><h3>Conclusion: Why Scarlet Heart Ryeo Still Lingers Years Later</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*Ez9nVzWK1w4kZqBsZswLmA.png" /></figure><p>Rewatching <em>Moon Lovers: Scarlet Heart Ryeo</em> in 2026 made me realize that what stayed with me was never just the tragedy of the story itself.</p><p>It was the way the drama understood emotional restraint.</p><p>Its most painful moments were rarely loud. They lived in pauses, unfinished sentences, silent acts of care, people walking away, people quietly staying, and feelings realized only after it was too late to say them aloud.</p><p>The drama was not perfect. Its pacing faltered at times, and some storylines deserved more depth. But emotional storytelling does not become unforgettable because it is flawless. It becomes unforgettable because it understands something deeply human.</p><p>It was the kind of drama that emotionally exhausted you by the end of an episode. The kind where you needed a moment before starting the next one, just to sit with everything you had just felt. Not because the story relied on constant shock or tragedy, but because it allowed emotions to linger instead of rushing past them.</p><p>And strangely, that sadness became part of the beauty of watching it.</p><p>Maybe that is why people continue returning to it years later. Not just to relive the sadness, but to revisit the strange beauty of being so emotionally affected by a story.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9692c873516" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recording & Transcribing Twilio Voice Calls with AWS S3 and OpenAI GPT-4o in NestJS]]></title>
            <link>https://medium.com/@kaveeshagimhani/recording-transcribing-twilio-voice-calls-with-aws-s3-and-openai-gpt-4o-in-nestjs-44e32a223e30?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/44e32a223e30</guid>
            <category><![CDATA[text-to-speech]]></category>
            <category><![CDATA[transcribe]]></category>
            <category><![CDATA[bullmq]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sun, 29 Mar 2026 15:10:45 GMT</pubDate>
            <atom:updated>2026-03-29T15:10:45.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kil4H5cWkqR3mIZrzrwMWg.png" /></figure><p>Part 2 of my Twilio voice calling series. If you haven’t read Part 1, start there.</p><p><a href="https://medium.com/@kaveeshagimhani/building-real-time-voice-calling-in-nestjs-with-twilio-voice-sdk-9e1df3ded7fb">https://medium.com/@kaveeshagimhani/building-real-time-voice-calling-in-nestjs-with-twilio-voice-sdk-9e1df3ded7fb</a></p><p>This post assumes you already have calls working.</p><h3>What we are building</h3><p>Once a call ends, Twilio hands you a recording. From there we:</p><ol><li>Twilio saved the recording directly to your S3 bucket (configured in the Twilio console. No download step needed)</li><li>Twilio POSTs a recording-callback webhook to your backend</li><li>You handler builds the S3 key from the payload and saves it to the DB</li><li>A BullMQ job in enqueued for transcription</li><li>The worker fetches the file from S3, converted it from µ-law 8kHz → 16kHz PCM with ffmpeg</li><li>The converted audio is sent to gpt-4o-transcribe and the transcript is saved</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*YLZ3w41u1b_JwkFj1p1wGQ.png" /></figure><p>The difference here from a usual scenario would be that we skip saving the recording to Twilio storage and access it using Twilio’s API endpoint for recording, we save it directly to our own S3 bucket.</p><h3>Step 1: Configure Twilio to Save Recordings to S3</h3><p>In the Twilio Console, go to:</p><p><strong>Voice -&gt; Settings -&gt; General -&gt; Voice Recording External Storage</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiFSrsqgHIm5tor9UpgCXg.png" /></figure><p>If you haven’t already added your AWS Credentials, click <em>“Add new AWS credentials”</em> and add a friendly name to your account, your AWS Access Key Id, AWS Access Secret Key and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Au8SzcocvSiVH-9VJaTUdw.png" /></figure><p>Now you will be able to select your AWS credentials and set your S3 bucket URL Once this is configured, when a call recording completes, Twilio will upload the file to your bucket before firing the recording-callback webhook. By the time your handler runs, the file is already in S3.</p><h3>IAM Policy for Twilio</h3><p>Twilio needs write access to the recording prefix:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;AllowTwilioRecordingWrite&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [&quot;s3:PutObject&quot;, &quot;s3:GetObject&quot;],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::your-chat-app-bucket/call-recording/*&quot;<br>    }<br>  ]<br>}</pre><p>Your backend IAM user needs read access to the same prefix (plus write access for transcripts):</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;AllowBackendRecordingAccess&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [&quot;s3:GetObject&quot;, &quot;s3:HeadObject&quot;, &quot;s3:DeleteObject&quot;],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::your-chat-app-bucket/call-recording/*&quot;<br>    },<br>    {<br>      &quot;Sid&quot;: &quot;AllowBackendTranscriptWrite&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [&quot;s3:PutObject&quot;, &quot;s3:GetObject&quot;],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::your-chat-app-bucket/transcripts/*&quot;<br>    }<br>  ]<br>}</pre><h4>.env</h4><pre>AWS_ACCESS_KEY_ID=your_access_key<br>AWS_SECRET_ACCESS_KEY=your_secret_key<br>AWS_REGION=us-east-1<br>AWS_S3_BUCKET=your-chat-app-bucket<br>AWS_S3_URL_EXPIRY=3600<br>OPENAI_API_KEY=sk-...</pre><h3>Step 2: The Call Entity</h3><p>Add recording and transcription fields:</p><pre>@Column({ nullable: true })<br>twilioRecordingSid: string;<br>@Column({ nullable: true })<br>recordingUrl: string; // S3 key, e.g. &quot;call-recording/AC.../RE123.wav&quot;<br>@Column({ nullable: true })<br>transcriptUrl: string; // S3 key for the saved transcript text<br>@Column({ nullable: true })<br>transcriptionStatus: string; // &#39;queued&#39; | &#39;completed&#39; | &#39;failed&#39;</pre><p>Point to remember: Store the S3 <strong>key</strong>, not a URL. Presigned URLs expire after seconds or hours. The key never does . Generate a fresh presigned URL on demand every time a client requests playback.</p><h3>Step 3 : The Recording Callback Handler</h3><p>Twilio POSTs to this endpoint after the recording is uploaded to S3. The payload includes;</p><ol><li>RecordingSid</li><li>CallSid</li><li>RecordingFileExtension</li></ol><p>This is all your need to construct the S3 key</p><pre>// POST /voice/recording-callback  (public — Twilio webhook, guard applied)<br>async handleRecordingCallback(body: any) {<br>  const { CallSid, RecordingSid, RecordingStatus } = body;<br>if (RecordingStatus !== &#39;completed&#39;) return { received: true };<br>  const call = await this.callRepository.findOne({<br>    where: { twilioCallSid: CallSid },<br>  });<br>  if (!call) {<br>    this.logger.warn(`Recording callback: no call found for CallSid ${CallSid}`);<br>    return { received: true };<br>  }<br>  // Build the S3 key - matches the path Twilio uploaded to<br>  const ext = body.RecordingFileExtension;<br>  const s3Key = ext<br>    ? `call-recording/${this.accountSid}/${RecordingSid}.${ext}`<br>    : `call-recording/${this.accountSid}/${RecordingSid}`;<br>  call.twilioRecordingSid = RecordingSid;<br>  call.recordingUrl = s3Key;<br>  call.transcriptionStatus = &#39;queued&#39;;<br>  await this.callRepository.save(call);<br>  // Hand off to worker - webhook returns immediately<br>  await this.transcriptionQueue.add(&#39;transcribe-call&#39;, {<br>    callId: call.id,<br>    s3Key,<br>  });<br>  return { received: true };<br>}</pre><p>The webhook handler is intentionally thin. It does no I/O beyond the DB write, so it returns in milliseconds and Twilio gets a fast 200 response.</p><h3>Step 4: The BullMQ Transcription Worker</h3><p>The worker does the heavy lifting here. It fetches the audio from S3, converts it with ffmpeg, and sends it to gpt-4o-transcribe</p><pre>@Processor(&#39;transcription&#39;)<br>export class TranscriptionWorker {<br>  constructor(<br>    private readonly voiceService: VoiceService,<br>  ) {}<br>@Process(&#39;transcribe-call&#39;)<br>  async handleTranscription(job: Job&lt;{ callId: number; s3Key: string }&gt;) {<br>    const { callId, s3Key } = job.data;<br>    // Get a presigned URL so we can download the file<br>    const { downloadUrl } = await this.voiceService.s3Service.getPresignedDownloadUrl(s3Key);<br>    // Transcribe (handles download + ffmpeg + gpt-4o-transcribe internally)<br>    const transcript = await this.voiceService.transcribeFromS3(downloadUrl);<br>    // Save transcript to DB and S3<br>    await this.voiceService.saveTranscript(callId, transcript);<br>  }<br>}</pre><h3>Step 5: Why ffmpeg before gpt-4o-transcribe?</h3><p>Twilio records telephony audio in <strong>µ-law (G.711) at 8kHz</strong>. This is the standard VoIP codec designed for phone networks. Not AI models.</p><p>Feeding 8kHz µ-law directly to a transcription model causes hallucination. This models tries to fill in audio artifacts as words. The fix is to convert this to a 16kHz mono PCM WAV before sending to the model.</p><pre>private convertAudio(inputPath: string, outputPath: string): Promise&lt;void&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    ffmpeg(inputPath)<br>      .setFfmpegPath(ffmpegStatic as string)<br>      .audioChannels(1)      // mono<br>      .audioFrequency(16000) // 16kHz — what AI models expect<br>      .audioCodec(&#39;pcm_s16le&#39;)<br>      .audioFilters([<br>        &#39;highpass=f=200&#39;,    // remove low-frequency rumble<br>        &#39;lowpass=f=3000&#39;,    // remove high-frequency hiss<br>      ])<br>      .output(outputPath)<br>      .on(&#39;end&#39;, resolve)<br>      .on(&#39;error&#39;, reject)<br>      .run();<br>  });<br>}</pre><p>Then transcribe:</p><pre>async transcribeFromS3(presignedUrl: string): Promise&lt;string&gt; {<br>  const tempFile = `/tmp/transcription-${Date.now()}.wav`;<br>  const convertedFile = tempFile.replace(&#39;.wav&#39;, &#39;-converted.wav&#39;);<br>try {<br>    // Download from S3<br>    const res = await fetch(presignedUrl);<br>    const buffer = Buffer.from(await res.arrayBuffer());<br>    if (buffer.length &lt; 10000) {<br>      // Too small - likely silence, would cause hallucination<br>      return &#39;&#39;;<br>    }<br>    fs.writeFileSync(tempFile, buffer);<br>    // Convert µ-law 8kHz → 16kHz PCM WAV<br>    await this.convertAudio(tempFile, convertedFile);<br>    // Transcribe with gpt-4o-transcribe<br>    const transcript = await this.openai.audio.transcriptions.create({<br>      file: fs.createReadStream(convertedFile),<br>      model: &#39;gpt-4o-transcribe&#39;,<br>      response_format: &#39;text&#39;,<br>    });<br>    return transcript as unknown as string;<br>  } finally {<br>    // Clean up temp files<br>    for (const f of [tempFile, convertedFile]) {<br>      if (fs.existsSync(f)) fs.unlinkSync(f);<br>    }<br>  }<br>}</pre><h3>Why I chose gpt-4o-transcribe</h3><p>Picking a transcription method was the hardest of them all, because it’s audio we are dealing with here. Real life call scenarios. There can be unnecessary background noise, poor call quality, use of multiple languages, multiple voice actors etc.</p><p>My first option was to look at Twilio’s own built-in transcription. It’s right there in the Voice API. You set a flag on the recording and Twilio transcribes it for you. The issue I came across here was that Twilio had deprecated their native transcription service. It’s no longer available for new integrations. So unfortunately I had to rule out that simple zero infrastructure solution.</p><p>Next was Twilio Conversational Intelligence. A more advanced product that does transcription plus sentiment analysis, topic detection and operator scripting. It looks amazing on the surface..</p><p>I had to rule it out for two reasons:</p><ol><li>Pricing: Conversational intelligence is priced per minute of audio processed, and the cost adds up fast at scale. I was looking for a cheaper option (But I would recommend this if you are serious about transcription and for a production grade app)</li><li>Overkill: I didn’t need sentiment analysis or topic modelling. I just needed the words</li></ol><p>Then comes Deepgram, which had a solid reputation for telephony audio and a playground for testing. The accuracy was impressive. But it revealed a core problem. Deepgram detects a dominant language and transcribes everything through that language. It doesn’t switch mid-stream. When my sample audios switched languages, it kept transcribing in the same dominant language it picked up. For monolingual calls, this is fine. But in a real world call scenario, people usually mix a few languages when speaking.</p><p>After those three options out of the picture, I started searching for AI models which can help with my requirement. And these are the 3 main models I found:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*RYdptxbXg_hrWCBzvkJTFA.png" /></figure><p>gpt-4o-transcribe hit the right balance: accurate on my specific audio characteristics, affordable per-minute pricing for the expected call volume, and no additional infrastructure to manage beyond what I already had with OpenAI.</p><h3>Step 6: Saving the Transcript</h3><p>After transcription the text is saved to both the DB and S3:</p><pre>async saveTranscript(callId: number, text: string): Promise&lt;void&gt; {<br>  const call = await this.callRepository.findOne({ where: { id: callId } });<br>  if (!call) return;<br>const s3Key = `transcripts/call-${callId}.txt`;<br>  const transcriptUrl = await this.s3Service.uploadText(s3Key, text);<br>  call.transcriptUrl = transcriptUrl;<br>  call.transcriptionStatus = &#39;completed&#39;;<br>  await this.callRepository.save(call);<br>}</pre><h3>Step 7: Serving Recordings to Clients</h3><p>Generate presigned URLs on demand — never expose S3 keys directly:</p><pre>// GET /voice/calls/:id/recording<br>async getCallRecording(<br>  callId: number,<br>  userId: string,<br>): Promise&lt;{ recordingUrl: string; duration?: number }&gt; {<br>  const call = await this.callRepository.findOne({ where: { id: callId } });<br>if (!call) throw new NotFoundException(&#39;Call not found&#39;);<br>  if (call.callerId !== userId &amp;&amp; call.calleeId !== userId) {<br>    throw new UnauthorizedException(&#39;Not authorized to access this recording&#39;);<br>  }<br>  if (!call.recordingUrl) throw new NotFoundException(&#39;No recording available&#39;);<br>  const { downloadUrl } = await this.s3Service.getPresignedDownloadUrl(call.recordingUrl);<br>  return { recordingUrl: downloadUrl, duration: call.duration || 0 };<br>}</pre><h3>Some common gotchas</h3><p>The recording callback fires before the status callback. Don’t assume CallStatus.COMPLETED when the recording arrives. They are independant webhooks. Therefore handle them seperately.</p><p><strong>RecordingFileExtension can be absent.</strong> Twilio doesn&#39;t always include it. Build your S3 key to handle both cases:</p><pre>const s3Key = ext<br>  ? `call-recording/${this.accountSid}/${RecordingSid}.${ext}`<br>  : `call-recording/${this.accountSid}/${RecordingSid}`;</pre><p>Skip tiny files because they cause hallucination. If the buffer is under ~10KB it’s probably silence or a failed recording. Sending it to the model produces nonsense output. Check size before transcribing.</p><p>Temp files must be cleaned up. Always wrap ffmpeg and transcription in a try/finally and delete temp files. On a busy server these accumulate fast and will fill /tmp.</p><h3>Wrapping up</h3><p>By the end of this setup, we’ve built a fully automated pipeline that takes a raw phone call and turns it into structured, searchable text, without manual intervention.</p><p>This architecture is flexible. You can extend it with features like sentiment analysis, keyword extraction, or call summaries without changing the core pipeline.</p><p>Thanks for reading 🌟</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44e32a223e30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Real-Time Voice Calling in NestJS with Twilio Voice SDK]]></title>
            <link>https://medium.com/@kaveeshagimhani/building-real-time-voice-calling-in-nestjs-with-twilio-voice-sdk-9e1df3ded7fb?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e1df3ded7fb</guid>
            <category><![CDATA[firebase-fcm]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[voice-calls]]></category>
            <category><![CDATA[twilio-integration]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 14:35:00 GMT</pubDate>
            <atom:updated>2026-03-28T14:35:00.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L8lb6qFfphqVkkkPdYHqig.png" /></figure><p>Let me paint a picture.</p><p>You’re building a chat app. Text messages are working beautifully. Then someone says, <em>“Can we add voice calls?”.</em> You say sure, how hard can it be? Then you spend the next three days reading Twilio docs, staring at TwiML, wondering why the callee’s phone isn’t ringing, and googling <em>“Twilio pushCredentialsSid what does it even do.”</em></p><p>This post is the guide I wish existed when I started. I’ll walk through how I built a full voice-calling feature inside a NestJS backend, end to end, convering:</p><ul><li>How Twilio Voice SDK actually works (the mental model)</li><li>Setting up the NestJS module, controller, and service</li><li>Generating Twilio Access Tokens (with push credential SID for mobile)</li><li>TwiML webhooks: the magic glue Twilio uses to route calls</li><li>Handling call status callbacks</li><li>FCM push notifications for iOS and Android (for when the app is in the background)</li></ul><h3>The Mental Model</h3><p>Before we touch any code, let’s make sure we understand how Twilio Voice SDK works at a high level.</p><p><strong>Twilio Voice SDK is not a regular API call where you say “call this person”. It’s a peer-to-peer relay where your backend acts as a traffic director, not a caller.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M3v9j5OEDt4XPfVrVWeFug.png" /></figure><p>Your backend job is:</p><ol><li>Issue JWTs so clients can talk to Twilio</li><li>Answer webhooks so Twilio knows where to route calls</li><li>Track call state in your own database</li></ol><p>The actual audio? That flows directly between the client SDKs and Twilio’s media servers. Your NestJS server never touches audio bytes</p><h3>Architecture Overview</h3><p>Here’s how all the pieces fit together</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MNKcDIh9drdvFvWurzJ1SA.png" /></figure><h3>Step 1: Twilio Console Setup</h3><p>Before writing a line of code, you need a few things from the Twilio console. Here’s the exact checklist:</p><h3>1.1 Get your Account SID and Auth Token</h3><p>Go to <a href="https://console.twilio.com/">https://console.twilio.com</a> -&gt; Dashboard</p><p>There are your master credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oOad5BMg8gPcUN-RRBeXOg.png" /></figure><h3>1.2 Create an API Key (this is different from your Auth Token)</h3><p>Navigate to: Account -&gt; API Keys &amp; Tokens -&gt; Create API Key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BSsyV5Iceax_vmJzcnMWVg.png" /></figure><p>Choose Standard. You’ll get:</p><ul><li>TWILIO_API_KEY_SID (starts with SK...)</li><li>TWILIO_API_KEY_SECRET</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1u7hzzMVBB4xW1xVUYbgA.png" /></figure><p>Why API Keys instead of Auth Token directly? Because you’ll embed these in JWTs given to your clients. If a key is compromised, you can revoke just that key without resetting your entire account.</p><p>(source: <a href="https://www.twilio.com/docs/iam/api-keys">API keys overview | Twilio</a>)</p><h3>1.3 Create a TwiML Application</h3><p>Navigate to: Voice -&gt; TwiML Apps -&gt; Create new TwiML App</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhovSP914tHFlEkCbJH-NA.png" /></figure><p>See the Voice Request URL to:</p><pre>https://your-backend.com/api/voice/twiml/call</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s51mm-mSSvySjNZHthjHsQ.png" /></figure><p>You’ll get a TWILIO_TWIML_APP_SID (starts with AP..).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLLU4CjhKLkNgUxMsAH69w.png" /></figure><p>This is the webhook Twilio calls when a client SDK initiates an outbound call. It’s how Twilio knows where to route the call.</p><h3>1.4 Create Push Credential (for mobile push)</h3><p>This step is often skipped by tutorials, but it’s crucial for mobile apps. Without it, Twilio cannot alert your backgrounded app of an incoming call.</p><p>When a callee’s app is in the background, Twilio can’t ring them via the SDK alone. It needs to send a push notification first so the OS wakes the app.</p><p>(source: <a href="https://www.twilio.com/docs/voice/sdks/ios/faq">Voice iOS SDK FAQ | Twilio</a>)</p><p>For iOS (APN): Go to Voice -&gt; Push Credentials -&gt; Create New Credential -&gt; iOS</p><p>Upload your .p8 APN key (from Apple Developer Console), your Key ID, and your Bundle ID.</p><p>You’ll get an iOS Push Credential SID (starts with CR...).</p><p><strong>For Android (FCM):</strong> Go to: <strong>Voice → Push Credentials → Create New Credential → Android/FCM</strong></p><p>Paste your FCM Server Key (from Firebase Console → Project Settings → Cloud Messaging).</p><p>You’ll get an Android Push Credential SID (starts with CR...).</p><p><strong>Here’s the critical bit:</strong> When generating an access token for a mobile user, you pass their device’s Push Credential SID to Twilio. This tells Twilio “if this user gets an incoming call, wake them up via APN/FCM first.” More on this below sections.</p><h3>1.5 Your .env file</h3><pre># Twilio Core<br>TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>TWILIO_AUTH_TOKEN=your_auth_token<br><br># Twilio Voice<br>TWILIO_API_KEY_SID=SKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>TWILIO_API_KEY_SECRET=your_api_key_secret<br>TWILIO_TWIML_APP_SID=APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>TWILIO_PHONE_NUMBER=+1234567890<br><br># FCM (Firebase Cloud Messaging)<br>FCM_ENABLED=true<br>FCM_PROJECT_ID=your-firebase-project-id<br>FCM_CLIENT_EMAIL=firebase-adminsdk-xxx@your-project.iam.gserviceaccount.com<br>FCM_PRIVATE_KEY=&quot;-----BEGIN PRIVATE KEY-----\nYour key here\n-----END PRIVATE KEY-----\n&quot;<br><br># App<br>APP_BASE_URL=https://your-backend.com</pre><h3>Step 2: The NestJS Module Structure</h3><p>With Twilio configured, we can now setup the NestJS backend to use these credentials.</p><p>Here’s how I organized the voice module</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*VQC_fNNNhNGWKwjS1o0HrQ.png" /></figure><p><em>Note: Ignore the transcription services for now. We will get back to this in a seperate blog</em></p><h4>voice.module.ts</h4><pre>@Module({<br>  imports: [<br>    TypeOrmModule.forFeature([Call, User, Contact]),<br>    ChatModule, // for WebSocket gateway<br>  ],<br>  controllers: [VoiceController],<br>  providers: [VoiceService, TwilioWebhookGuard],<br>  exports: [VoiceService],<br>})<br>export class VoiceModule {}</pre><h4>The Call entity (the heart of our tracking)</h4><pre>@Entity(&#39;calls&#39;)<br>export class Call {<br>  @PrimaryGeneratedColumn()<br>  id: number;<br>  @Column()<br>  callerId: string;<br>  @Column()<br>  calleeId: string;<br>  @Column({ type: &#39;enum&#39;, enum: CallType, default: CallType.VOICE })<br>  type: CallType;<br>  @Column({ type: &#39;enum&#39;, enum: CallStatus, default: CallStatus.INITIATED })<br>  status: CallStatus;<br>  @Column({ nullable: true })<br>  twilioCallSid: string;<br>  @Column({ nullable: true })<br>  startedAt: Date;<br>  @Column({ nullable: true })<br>  answeredAt: Date;<br>  @Column({ nullable: true })<br>  endedAt: Date;<br>  @Column({ nullable: true })<br>  duration: number;<br>  @Column({ nullable: true })<br>  callerLeftAt: Date;<br>  @Column({ nullable: true })<br>  calleeLeftAt: Date;<br>  @Column({ nullable: true })<br>  recordingUrl: string; // S3 key, NOT public URL<br>  @Column({ nullable: true })<br>  transcript: string;<br>  @Column({ nullable: true })<br>  transcriptionStatus: string;<br>}</pre><h3>Step 3: Generating Access Tokens</h3><p>This is the very first thing your mobile app should call. Without this token, the Twilio SDK can’t register and can’t make/receive calls.</p><p><strong>The endpoint:</strong></p><pre>@Post(&#39;token&#39;)<br>@HttpCode(HttpStatus.OK)<br>generateToken(<br>  @CurrentUser(&#39;sub&#39;) userId: string,<br>  @Body() body: TokenRequestDto,<br>) {<br>  return this.voiceService.generateToken(userId, body?.pushCredentialSid);<br>}</pre><p><strong>The service:</strong></p><pre>generateToken(userId: string, pushCredentialSid?: string): { token: string; identity: string } {<br><br>const accessToken = new AccessToken(<br>    this.accountSid,   // Your Account SID<br>    this.apiKeySid,    // SK... not the Auth Token<br>    this.apiKeySecret,<br>    {<br>      identity: userId, // Use your user&#39;s ID/uuid as identity<br>      ttl: 3600,        // Token lives 1 hour<br>    },<br>  );<br><br>  const voiceGrant = new VoiceGrant({<br>    outgoingApplicationSid: this.twimlAppSid, // Your TwiML App<br>    incomingAllow: true,                       // Allow incoming calls<br>  });<br><br>  // This is for mobile push<br>  if (pushCredentialSid) {<br>    voiceGrant.pushCredentialSid = pushCredentialSid;<br>  }<br>  accessToken.addGrant(voiceGrant);<br>  return { token: accessToken.toJwt(), identity: userId };<br>}</pre><p><strong>What does pushCredentialSid do?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*Syl63-K1abjtVGtUYEoaLQ.png" /></figure><p>When Alice calls Bob and his app is closed, Twilio sends an APN/FCM push using the credential Bob registered with. The OS wakes the app, the SDK initializes, and the incoming call appears.</p><h3>Step 4: The Full Call Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*4jfh9pgtFR_g0GXy6m4RAQ.png" /></figure><h3>4.1 Initiating a Call</h3><pre>async initiateCall(callerId: string, dto: InitiateCallDto): Promise&lt;CallResponseDto&gt; {<br>  const { calleeId, type } = dto;<br>  const [caller, callee] = await Promise.all([<br>      this.userRepository.findOne({ where: { id: callerId } }),<br>      this.userRepository.findOne({ where: { id: calleeId } }),<br>    ]);<br>    if (!caller || !callee) throw new NotFoundException(&#39;User not found&#39;);<br>    if (callerId === calleeId) throw new BadRequestException(&#39;Cannot call yourself&#39;);<br>    const call = this.callRepository.create({<br>      callerId,<br>      calleeId,<br>      type,<br>      status: CallStatus.INITIATED,<br>    });<br>    const savedCall = await this.callRepository.save(call);<br>    // Notify callee via WebSocket<br>    this.chatGateway.emitToUser(calleeId, &#39;incoming_call&#39;, {<br>      callId: savedCall.id,<br>      callerId,<br>      callerName: caller.fullName,<br>      type,<br>    });<br>    return savedCall;<br>}</pre><h3>4.2 The TwiML Webhook</h3><p>This is the most important endpoint. When Alice’s SDK calls device.connect(), Twilio asks our NestJS backend <em>&quot;What should i do with this call?&quot;.</em> And we respond with TwiML, an XML dialect that tells Twilio to dial Bob.</p><pre>// POST /v1/voice/twiml/call  (public — no auth, Twilio webhook)<br>async handleOutgoingCall(body: TwilioVoiceWebhookDto): Promise&lt;string&gt; {<br>  const callerId = body.From.replace(&#39;client:&#39;, &#39;&#39;);<br>  const calleeId = body.To.replace(&#39;client:&#39;, &#39;&#39;);<br>  const caller = await this.userRepository.findOne({ where: { id: callerId } });<br>    const response = new VoiceResponse();<br>    const dial = response.dial({<br>      callerId: `client:${callerId}`,<br>      timeout: 30,<br>      action: `${this.baseUrl}/api/voice/dial-callback`,<br>    });<br>    const client = dial.client({}, calleeId);<br>    // Pass caller metadata - arrives in callee&#39;s `incoming` SDK event<br>    client.parameter({ name: &#39;callerUserId&#39;, value: callerId });<br>    client.parameter({ name: &#39;callerName&#39;, value: caller?.fullName || &#39;Unknown&#39; });<br>    client.parameter({ name: &#39;callerAvatar&#39;, value: caller?.avatar || &#39;&#39; });<br>    <br>    // Pass our backend call ID - callee needs this for /accept or /reject<br>    const activeCall = await this.callRepository.findOne({<br>      where: { callerId, calleeId, status: In([CallStatus.INITIATED, CallStatus.RINGING]) },<br>      order: { createdAt: &#39;DESC&#39; },<br>    });<br>    if (activeCall) {<br>      client.parameter({ name: &#39;backendCallId&#39;, value: String(activeCall.id) });<br>    }<br>    return response.toString();<br>}</pre><p>The generated TwiML (Twilio Markup Language,):</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;Response&gt;<br>  &lt;Dial callerId=&quot;client:alice-uuid&quot; timeout=&quot;30&quot;<br>        action=&quot;https://your-backend.com/api/voice/dial-callback&quot;&gt;<br>    &lt;Client&gt;<br>      bob-uuid<br>      &lt;Parameter name=&quot;callerName&quot; value=&quot;Alice Smith&quot;/&gt;<br>      &lt;Parameter name=&quot;callerUserId&quot; value=&quot;alice-uuid&quot;/&gt;<br>      &lt;Parameter name=&quot;backendCallId&quot; value=&quot;42&quot;/&gt;<br>    &lt;/Client&gt;<br>  &lt;/Dial&gt;<br>&lt;/Response&gt;</pre><h3>4.3 Securing Webhooks</h3><p>Because TwiML endpoints are publicly accessible, you must secure them. Twilio signs all webhook requests with an HMAC-SHA1 signature (in the X-Twilio-Signature header). Use a guard (as shown) to validate this signature on each request. Do not expose these URLs without authentication/validation.</p><pre>@Injectable()<br>export class TwilioWebhookGuard implements CanActivate {<br>  canActivate(context: ExecutionContext): boolean {<br>    const request = context.switchToHttp().getRequest();<br>    const twilioSignature = request.headers[&#39;x-twilio-signature&#39;];<br>    const url = `${process.env.APP_BASE_URL}${request.originalUrl}`;<br>    const isValid = twilio.validateRequest(<br>          process.env.TWILIO_AUTH_TOKEN,<br>          twilioSignature,<br>          url,<br>          request.body,<br>        );<br>        if (!isValid) throw new UnauthorizedException(&#39;Invalid Twilio webhook signature&#39;);<br>        return true;<br>      }<br>}</pre><pre>@Public()<br>@UseGuards(TwilioWebhookGuard)<br>@Post(&#39;twiml/call&#39;)<br>async handleTwimlCall(@Body() body: TwilioVoiceWebhookDto, @Res() res: Response) {<br>  const twiml = await this.voiceService.handleOutgoingCall(body);<br>  res.set(&#39;Content-Type&#39;, &#39;text/xml&#39;);<br>  res.send(twiml);<br>}</pre><h3>4.4 Status Callbacks and Common Gotchas</h3><p>Twilio continuosly POSTs status updates: initiated -&gt; ringing -&gt; in-progress -&gt; completed.</p><p>Here’s a gotcha:</p><p>For example, if the callee rejects a call (setting status to BUSY), Twilio will later send a completed status callback. To avoid overwriting, we check for existing terminal statuses (BUSY, NO_ANSWER, etc.) before saving. Otherwise Twilio’s final callback might change the status unexpectedly</p><p>Fix: never let Twilio overwrite a terminal status we already set</p><pre>onst terminalStatuses = [<br>  CallStatus.COMPLETED,<br>  CallStatus.BUSY,<br>  CallStatus.NO_ANSWER,<br>  CallStatus.FAILED,<br>  CallStatus.CANCELED,<br>];<br>if (terminalStatuses.includes(call.status)) {<br>  // Still capture duration if we don&#39;t have it yet<br>  if (duration &amp;&amp; !call.duration) {<br>    call.duration = parseInt(duration, 10);<br>    await this.callRepository.save(call);<br>  }<br>  return; // Don&#39;t overwrite our more specific status<br>}</pre><h3>Wrapping Up</h3><p>Building voice calling is genuinely one of the more complex integrations you can add to a backend. But once the mental model clicks, your backend is the traffic director, not the caller. Everything else follows logically.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e1df3ded7fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Server setup with Ansible]]></title>
            <link>https://medium.com/nolooptech/automating-server-setup-with-ansible-783665d5cc33?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/783665d5cc33</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[server-automation]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Fri, 13 Feb 2026 07:10:59 GMT</pubDate>
            <atom:updated>2026-02-13T07:10:59.949Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-FA7TOJL9vET-mxW436o1g.png" /></figure><p>You SSH into a server, install Docker, configure Nginx, set up TLS and a month later you need to do it all over again for production.</p><p>And suddenly you’re asking yourself:</p><p><em>What packages did I install?</em></p><p><em>What commands did I run? In what order?</em></p><p><em>What config tweak did I make at 2am to “just make it work”?</em></p><p>This is the problem Ansible solves. <br>It turns your server setup into actual code — reviewable, reproducible and version-controlled.</p><p>In this blog, I will walk you through on how I used Ansible to automate the full provisioning for a NestJs backend, from a bare Ubuntu VM to a fully running, TLS-secured deployment. I’ll also show how this plugs into CI/CD for automated releases.</p><p>Keep in mind that even though I set it up for a NestJs backend, this guide is fully stack-agnostic and is flexible for any type of VM deployment. The goal is to show the patterns and concepts so you can adapt them to your own setup.</p><p><strong>TL;DR</strong></p><ul><li>⁠ ⁠Ansible turns server setup into version-controlled code <br>•⁠ ⁠Same playbooks for dev &amp; prod, only variables change <br>•⁠ ⁠New servers go from manual setup → one command <br>•⁠ ⁠CI/CD deploys containers without SSHing into servers</li></ul><h4>Why Ansible?</h4><p>Most developers treat server setup as a one-time task. SSH in, run a bunch of commands, move on.</p><p>The problem? You end up with something called <strong>“Snowflake servers”</strong>, which basically means <em>“machines configured by hand that nobody can reliably reproduce”</em>.</p><p>Ansible flips this completely.</p><p>Instead of clicking around and hoping you remember what you did, you declare what your server should look like in YAML files. These are called “<em>playbooks</em>”. Basically your server configuration blueprint. And Ansible makes it happen.</p><p>Some key benefits of Ansible are as follows:</p><ol><li><strong>Reproducible</strong>: Run the same <em>playbook</em> against dev, staging or prod</li><li><strong>Idempotent</strong>: Run it twice, nothing breaks. It only changes what needs changing</li><li><strong>Agentless</strong>: No software to install on the target server. Just SSH</li><li><strong>Version-controlled</strong>: Your infra lives in Git alongside your app code</li></ol><h3>Installing Ansible</h3><p>Ansible runs on your local machine (the control node). There’s nothing to install on the target servers.</p><p><strong>macOS:</strong></p><pre>brew install ansible</pre><p><strong>Ubuntu/Debian &amp; Windows (via WSL):</strong></p><pre>sudo apt update &amp;&amp; sudo apt install -y ansible</pre><p><strong>pip (any OS):</strong></p><pre>pip install ansible</pre><p><strong>Verify it’s installed:</strong></p><pre>ansible --version</pre><p>That’s it. As long as you can SSH into your target server, Ansible can manage it.</p><h3>Key Ansible Concepts</h3><p>Before reading the playbooks, here’s a quick glossary of the keywords you’ll see:</p><ul><li><strong>hosts</strong> — Which machines to target (eg: all , or specific group from your inventory)</li><li><strong>become</strong> — Run tasks with elevated privileges (sudo)</li><li><strong>tasks</strong> — A list of actions to execute, in order</li><li><strong>name</strong> — A human-readable label for each task (shown during execution)</li><li><strong>state</strong> — The desired end state — present (install/create), absent (remove), started (running), latest (updated)</li><li><strong>{{ variable }}</strong> — Pulls values from inventory, group_vars, or extra vars passed at runtime</li><li><strong>register</strong> — Captures a task’s output into a variable for later use</li><li><strong>when</strong> — Conditional — only runs a task if the expression is true</li><li><strong>copy</strong> — Copies a file or writes content to the target machine</li><li><strong>apt</strong> — Manages packages on Debian/Ubuntu systems</li><li><strong>systemd</strong> — Manages system services (start, stop, enable on boot)</li></ul><p>These keywords makeup the core of almost every playbook. Once you know them you can read any Ansible config.</p><h3>The Big Picture (How this actually works)</h3><p>Before diving into code, here’s the 2 phase workflow.</p><h3>Overall Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*rXBaocVwk2E3QTVUPFQo8A.png" /><figcaption><em>Two-phase workflow showing Phase 1 (one-time provisioning from your laptop via Ansible) and Phase 2 (automated deployment from CI/CD pipeline on every release)</em></figcaption></figure><p><strong>Phase 1</strong> happens once (or whenever you need to change the server’s base setup). You run Ansible from your machine to provision the VM</p><p><strong>Phase 2</strong> happens automatically on every code push. The CI/CD pipeline builds your app image, then uses Ansible + SSH to deploy it to the already-provisioned VM</p><h3>What the Provisioned Server looks like</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*pSR0fkzbQxUWGHQHMxIpVA.png" /><figcaption><em>Server architecture showing internet traffic flowing through Nginx reverse proxy with TLS into Docker Compose containers (App, DB, and other services) running inside a VM</em></figcaption></figure><p>Nginx acts as the public-facing entry point with TLS termination. All application containers sit behind it, accessible only internally. This is what Ansible sets up for you</p><h3>Project Stucture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*tzJUCy3LyhjrCSI6qcGBtQ.png" /><figcaption>Ansible folder structure</figcaption></figure><p>Let me go through each of the files I have created</p><ul><li>dev.ini- Dev VM connection details</li><li>prod.ini- Prod VM connections details</li><li>group_vars/dev.yml - Dev specific variables</li><li>group_vars/prod.yml - Prod specific variables</li><li>playbooks/bootstrap.yml- System packages + Docker</li><li>playbooks/nginx.yml- Reverse proxy config</li><li>playbooks/tls.yml - Let&#39;s Encrypt certificate</li><li>playbooks/app-setup.yml - App directories + env + compose</li><li>playbooks/setup.yml- Master playbook (runs all above)</li><li>files/docker-compose.yml- Compose file copied to VM</li></ul><ol><li><strong>inventory</strong> files — define where to run</li><li><strong>group_vars</strong> — define what values to use</li><li><strong>playbooks</strong> — define what to do. swapping dev.ini for prod.ini targets a completely different server with different variables — same playbooks</li></ol><h4>Writing the inventory file</h4><p>The .ini file tells Ansible which server to connect to.</p><pre># inventory/dev.ini<br>[dev]<br>dev-vm ansible_host=192.168.1.10 ansible_user=ubuntu</pre><p>[dev] - the group name. This is what links to the matching group_vars/dev.yml</p><p>dev-vm - a label for this host (can be anything)</p><p>ansible_host - the server&#39;s IP address</p><p>ansible_user - the SSH User Ansible will connect as</p><h4>Writing the group variables</h4><p>The group_vars/*.yml file holds all the variables your playbook references.</p><pre># inventory/group_vars/dev.yml<br>domain_name: dev.myapp.com<br>app_port: 3000<br>app_name: my-app<br>app_user: ubuntu<br>certbot_email: &quot;dev@myapp.com&quot;</pre><p>Every {{ variable }} in your playbooks gets its value from here. Different environments get different files with different values. Your playbooks never need to change. You define whatever variables make sense for your project</p><h4>Why folder placement matters</h4><p>Ansible uses conventions to auto-discover files. If something is in the wrong place, it won’t throw a helpful error. You’ll get undefined variables failures at runtime.</p><p><strong>group_vars/ must live inside </strong><strong>inventory/</strong></p><p>This is the most common gotcha. Ansible automatically loads variables from group_vars/ based on the inventory group names. If your inventory file defines a [dev] group, Ansible looks for inventory/group_vars/dev.yml and injects those variables into every play targeting that group.</p><p>Move group_vars/ outside of inventory/ and you&#39;ll get cryptic errors like:</p><pre>TASK [Enable Docker] ***********************************************************<br>fatal: [83.228.206.90]: FAILED! =&gt; {&quot;msg&quot;: &quot;The task includes an option with an<br>undefined variable. The error was: &#39;app_user&#39; is undefined.</pre><p>The variable exists in your YAML file — Ansible just can’t find it because the folder is in the wrong place.</p><p><strong>files/ lives inside </strong><strong>playbooks/</strong></p><p>When a playbook uses the copy module with src: docker-compose.yml, Ansible looks for that file relative to the playbook&#39;s location. Specifically in a files/ subdirectory next to the playbook. If your playbook is at playbooks/app-setup.yml, Ansible resolves the source to playbooks/files/docker-compose.yml. Move the files/ folder elsewhere and the copy task will fail with a &quot;file not found&quot; error</p><p><strong>Inventory filenames match </strong><strong>group_vars filenames</strong></p><p>The group name in your .ini file must match the .yml filename in group_vars/. If your inventory has [dev] as the group header, the variables file must be group_vars/dev.yml - not group_vars/development.yml or group_vars/vars.yml. Ansible matches these by name, not by explicit configuration.</p><h4>How Ansible connects the pieces</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMhPq_Kn91sc6KAzaZ5p9w.png" /><figcaption><em>Flowchart showing how the ansible-playbook command connects three layers: Inventory (WHERE to connect), Group Vars (WITH WHAT values), and Setup Playbook (WHAT to do — bootstrap, nginx, tls, app-setup)</em></figcaption></figure><h3>Breaking down the Playbooks</h3><p>What follows is how I structured my playbooks. Each concern lives in its own file. This keeps things modular. You can run them individually to debug or test a specific step, or run them all at once through the master playbook.</p><h3>1. bootstrap.yml - Installing the foundations</h3><p>The first playbook gets the bare VM ready:</p><pre>- hosts: all<br>  become: true<br>  tasks:<br>    - name: Install base packages<br>      apt:<br>        name:<br>          - docker.io<br>          - nginx<br>          - certbot<br>          - python3-certbot-nginx<br>        state: present<br>    - name: Enable Docker<br>          systemd:<br>            name: docker<br>            enabled: true<br>            state: started<br>        - name: Add app user to docker group<br>          user:<br>            name: &quot;{{ app_user }}&quot;<br>            groups: docker<br>            append: true</pre><p>Notice become: true -- this runs commands as root (like sudo). The {{ app_user }} syntax pulls values from the inventory&#39;s group_vars file.</p><p>Idempotency in action: If Docker is already installed, apt does nothing. If the user is already in the docker group, no change. You can run this playbook 100 times safely.</p><h3>2. nginx.yml - Reverse proxy configuration</h3><pre>- name: Write nginx site config<br>  copy:<br>    dest: /etc/nginx/sites-available/api<br>    content: |<br>      server {<br>          listen 80;<br>          server_name {{ domain_name }};<br>          location / {<br>              proxy_pass http://127.0.0.1:{{ app_port }};<br>              proxy_set_header Host $host;<br>              proxy_set_header X-Real-IP $remote_addr;<br>          }<br>    }</pre><p>The {{ domain_name }} and {{ app_port }} are injected from group_vars. For dev, this resolves to one domain and port. For prod, different values, same playbook.</p><h3>3. tls.yml - Securing with HTTPS</h3><p>Your server needs a TLS certificate. Ansible can handle this regardless of how you obtain one:</p><p><strong>Option A: Free certificates with Let’s Encrypt (Certbot)</strong></p><pre>- name: Obtain TLS certificate<br>  command: &gt;<br>    certbot --nginx<br>    -d {{ domain_name }}<br>    --email {{ certbot_email }}<br>    --agree-tos<br>    --non-interactive</pre><p>One task. Certbot handles the ACME challenge, certificate issuance, and nginx config modification. It also auto-renews, so you set it and forget it.</p><p><strong>Option B: Paid / pre-issued certificates</strong></p><p>If you have certificates from a CA (DigiCert, Sectigo, etc), Ansible can copy them to the right location:</p><pre>- name: Copy TLS certificate<br>  copy:<br>    src: &quot;{{ tls_cert_file }}&quot;<br>    dest: /etc/ssl/certs/app.crt<br>    mode: &#39;0644&#39;<br>- name: Copy TLS private key<br>  copy:<br>    src: &quot;{{ tls_key_file }}&quot;<br>    dest: /etc/ssl/private/app.key<br>    mode: &#39;0600&#39;</pre><p>Either way, the playbook ensures every server gets TLS configured identically.</p><h3>4. app-setup.yml - Getting the app ready</h3><pre>- name: Write .env file<br>  copy:<br>    dest: &quot;{{ app_dir }}/.env&quot;<br>    content: &quot;{{ app_env_file }}&quot;<br>    mode: &#39;0600&#39;<br>- name: Copy docker-compose.yml to VM<br>  copy:<br>    src: docker-compose.yml<br>    dest: &quot;{{ app_dir }}/docker-compose.yml&quot;</pre><p>Secrets never touch Git. The .env file content is passed in at runtime (from CI secrets or command-line variables) and file permissions are locked to 0600 (owner read/write only)</p><p>The setup.yml master playbook simply imports each file in sequence.</p><pre># setup.yml<br>- import_playbook: bootstrap.yml<br>- import_playbook: nginx.yml<br>- import_playbook: tls.yml<br>- import_playbook: app-setup.yml</pre><p>Running individually (step by step)</p><pre>ansible-playbook -i inventory/dev.ini playbooks/bootstrap.yml<br>ansible-playbook -i inventory/dev.ini playbooks/nginx.yml<br>ansible-playbook -i inventory/dev.ini playbooks/tls.yml<br>ansible-playbook -i inventory/dev.ini playbooks/app-setup.yml</pre><p>Running all at once via setup.yml</p><pre>ansible-playbook -i inventory/dev.ini playbooks/setup.yml</pre><h4>Built-in verification — no need to SSH</h4><p>One of the best parts of Ansible is that you can add verification tasks directly into each playbook. Instead of SSHing into the VM after a run to check if everything worked, let the playbook verify itself.</p><pre># At the end of bootstrap.yml<br>- name: Verify Docker version<br>  command: docker --version<br>  register: docker_version<br>- name: Verify nginx is running<br>  systemd:<br>    name: nginx<br>    state: started<br>  register: nginx_status<br>- name: Show verification results<br>  debug:<br>    msg:<br>      - &quot;Docker: {{ docker_version.stdout }}&quot;</pre><pre># At the end of app-setup.yml<br>- name: Verify .env file exists<br>  stat:<br>    path: &quot;{{ app_dir }}/.env&quot;<br>  register: env_stat<br>- name: Fail if setup is incomplete<br>  fail:<br>    msg: &quot;App setup incomplete (missing .env file)&quot;<br>  when: not env_stat.stat.exists</pre><p>Each playbook can verify its own work and fail loudly if something is wrong. You get confirmation in your terminal output without ever logging into the server. If a verification step fails, you know exactly which playbook and which check caught the issue.</p><h3>Environment Separation</h3><p>This is where Ansible really shines as version control for infrastructure. The same playbooks server every environment. Only the inventory and variables change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*4Wwmo3xGndULXRqjEtAs8w.png" /><figcaption><em>Shared playbooks at the top branching into two paths: dev inventory with dev-specific variables pointing to the Dev VM, and prod inventory with prod-specific variables pointing to the Prod VM</em></figcaption></figure><p>To provision dev:</p><pre>ansible-playbook -i inventory/dev.ini playbooks/setup.yml</pre><p>To provision prod:</p><pre>ansible-playbook -i inventory/prod.ini playbooks/setup.yml</pre><p>That’s it. Same playbooks. Different targets.</p><h3>The CI/CD Integration</h3><p>Once the VM is provisioned, Ansible fits naturally into your CI/CD pipeline for ongoing deployments. Regardless of which platform you use (Github Actions, GitLab CI, Jenkins, etc), the pattern is the same</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bDmJtGVbQl0yzgMSnMkMaA.png" /><figcaption><em>CI/CD Pipeline Flow</em></figcaption></figure><p>The deploy job does two things:</p><ol><li>Ansible syncs the .env and docker-compose.yml to the VM (ensuring the latest config and secrets are in place)</li><li>SSH connects to the VM to pull the fresh image from container registry and restart the containers</li></ol><p>The server never needs manual intervention after initial provisioning.</p><h3>Key Takeaways</h3><ul><li>Your playbooks are the documentation. No more guessing what’s installed on a server. Just read the YAML</li><li>Spinning up a new environment goes from a full day of manual work to a single command</li><li>Dev and prod stay aligned</li><li>Any developer on the team can understand the server setup</li><li>When something breaks, you don’t need to SSH in and poke around. Re-run the playbook and it converges back to the correct state</li></ul><h3>Final Thoughts</h3><p>Treat your servers like your code. If your server setup isn’t in version control, it’s just tribal knowledge waiting to break at the worst possible moments. Once your infrastructure lives in version control, spinning up a new environment stops being scary.</p><p>Your server setup is too important to live in someone’s terminal history. Put it in Git.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=783665d5cc33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nolooptech/automating-server-setup-with-ansible-783665d5cc33">Automating Server setup with Ansible</a> was originally published in <a href="https://medium.com/nolooptech">NoLoopTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Documenting WebSocket Events with AsyncAPI — Beyond Swagger]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@kaveeshagimhani/documenting-websocket-events-with-asyncapi-beyond-swagger-410de1e64358?source=rss-7c302a19d4b9------2"><img src="https://cdn-images-1.medium.com/max/1280/1*hRK4NERX85sCH46J8KoEWA.png" width="1280"></a></p><p class="medium-feed-snippet">Most teams today use Swagger/OpenAPI to document their REST APIs. It works. But the moment your system becomes event-driven and you&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@kaveeshagimhani/documenting-websocket-events-with-asyncapi-beyond-swagger-410de1e64358?source=rss-7c302a19d4b9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@kaveeshagimhani/documenting-websocket-events-with-asyncapi-beyond-swagger-410de1e64358?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/410de1e64358</guid>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[asyncapi]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 14:30:03 GMT</pubDate>
            <atom:updated>2026-01-04T14:30:37.265Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Promise.all vs Promise.allSettled: What’s the Real Difference?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@kaveeshagimhani/promise-all-vs-promise-allsettled-whats-the-real-difference-da83bd1fb5c5?source=rss-7c302a19d4b9------2"><img src="https://cdn-images-1.medium.com/max/1536/1*XM8_t-DLKNmok9Wp8qwiDg.png" width="1536"></a></p><p class="medium-feed-snippet">For my non medium partner readers&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@kaveeshagimhani/promise-all-vs-promise-allsettled-whats-the-real-difference-da83bd1fb5c5?source=rss-7c302a19d4b9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@kaveeshagimhani/promise-all-vs-promise-allsettled-whats-the-real-difference-da83bd1fb5c5?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/da83bd1fb5c5</guid>
            <category><![CDATA[asynchronous-programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[promises-in-javascript]]></category>
            <category><![CDATA[promise-all]]></category>
            <category><![CDATA[parallel-processing]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 15:36:19 GMT</pubDate>
            <atom:updated>2025-09-13T16:53:50.435Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Stop Using VARCHAR(255) by Default: Smarter SQL Schema Design]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@kaveeshagimhani/stop-using-varchar-255-by-default-smarter-sql-schema-design-ceca39bd4a91?source=rss-7c302a19d4b9------2"><img src="https://cdn-images-1.medium.com/max/1536/1*knioN8QcE9D9vr1fjxGjhg.png" width="1536"></a></p><p class="medium-feed-snippet">We&#x2019;ve all done it.</p><p class="medium-feed-link"><a href="https://medium.com/@kaveeshagimhani/stop-using-varchar-255-by-default-smarter-sql-schema-design-ceca39bd4a91?source=rss-7c302a19d4b9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@kaveeshagimhani/stop-using-varchar-255-by-default-smarter-sql-schema-design-ceca39bd4a91?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ceca39bd4a91</guid>
            <category><![CDATA[varchar]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[database-optimization]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 04:29:22 GMT</pubDate>
            <atom:updated>2025-09-13T16:54:13.563Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How AI is Revolutionizing Frontend Development in 2025]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@kaveeshagimhani/how-ai-is-revolutionizing-frontend-development-in-2025-657ad756fdb1?source=rss-7c302a19d4b9------2"><img src="https://cdn-images-1.medium.com/max/1536/1*iH9rg7txUCJX0ZmDtsWpsA.png" width="1536"></a></p><p class="medium-feed-snippet">In the ever-evolving landscape of technology, Artificial Intelligence (AI) continues to redefine the boundaries of what&#x2019;s possible. As we&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@kaveeshagimhani/how-ai-is-revolutionizing-frontend-development-in-2025-657ad756fdb1?source=rss-7c302a19d4b9------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@kaveeshagimhani/how-ai-is-revolutionizing-frontend-development-in-2025-657ad756fdb1?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/657ad756fdb1</guid>
            <category><![CDATA[ai-automation]]></category>
            <category><![CDATA[ai-tools]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sun, 25 May 2025 14:35:40 GMT</pubDate>
            <atom:updated>2025-09-13T16:55:05.270Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Demystifying Ngrok: What Really Happens When You Share localhost]]></title>
            <link>https://medium.com/@kaveeshagimhani/demystifying-ngrok-what-really-happens-when-you-share-localhost-27a4c317af59?source=rss-7c302a19d4b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/27a4c317af59</guid>
            <category><![CDATA[webhooks]]></category>
            <category><![CDATA[ngrok]]></category>
            <category><![CDATA[localhost]]></category>
            <category><![CDATA[tunneling]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[kaveesha gimhani]]></dc:creator>
            <pubDate>Sun, 25 May 2025 14:04:25 GMT</pubDate>
            <atom:updated>2025-09-13T16:55:28.518Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UrComzRTaXJ9X3ZJPZlqzQ.png" /></figure><p>So recently, one of my friends planned to use Ngrok to expose their local server to the internet. But they didn’t fully understand what Ngrok does — or that it’s mainly used for <strong>testing</strong> and <strong>development</strong>, not as a permanent production tool.</p><p>Since I’d used Ngrok many times, I offered to explain. But halfway through, I realized I didn’t fully grasp what’s going on “under the hood” myself. That led me down the rabbit hole… and now I’m here to break it all down for you too.</p><h3>🚀 What is Ngrok?</h3><p>Imagine you’re building a web app that only runs on your laptop via localhost:3000. Now you want to <strong>show it to a friend across the world</strong> or <strong>test a webhook integration</strong> that requires a public URL.</p><p>Here’s the problem: localhost isn’t reachable from the internet.</p><p>That’s where Ngrok comes in. It’s like a <strong>magic tunnel</strong> from your laptop to the outside world. It gives you a <strong>temporary public URL</strong> that connects directly to your local server — no need to mess with firewalls, routers, or DNS.</p><h3>🍔 Real-World Analogy: The Secret Restaurant</h3><p>Let’s say you run a <strong>restaurant (your app)</strong> in a <strong>hidden building (your computer)</strong>. No one knows it exists — it’s locked behind fences (your router) and only accessible to you.</p><p>You call Ngrok and say:</p><blockquote><em>“Hey, I need a </em><strong><em>front desk in a big public mall (the internet)</em></strong><em> where people can walk in and place orders. When they do, forward those orders straight to my secret restaurant.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lyFRWAdGdUx2Ou0l5BKIxg.png" /></figure><p>Ngrok sets up a <strong>public URL</strong> (your front desk), and uses a <strong>secure tunnel</strong> (like a private phone line) to connect it directly to your local server.</p><p>When someone visits the URL, it’s as if they’re standing at your restaurant counter — even though you’re tucked away on your own laptop.</p><h3>🧠 Breaking It Down: Real World vs. Technical Terms</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQyYXPT2Fprqe9ywmHn5VA.png" /></figure><h3>🔐 Why Developers Use Ngrok</h3><p>Ngrok is especially useful for:</p><ul><li>🧪 <strong>Testing webhooks</strong> (Stripe, Twilio, WhatsApp API, etc.)</li><li>🔍 <strong>Sharing local projects</strong> with teammates or clients</li><li>📱 <strong>Debugging mobile apps</strong> that need to talk to a server</li><li>🌐 <strong>Instant HTTPS</strong> without setting up certificates</li></ul><p>You don’t need:</p><ul><li>A domain name</li><li>A public IP</li><li>Router port forwarding</li><li>SSL setup</li></ul><p>Just run one command and you’re live:</p><p>ngrok http 3000</p><h3>🛠️ What Happens Under the Hood?</h3><p>Ngrok combines several networking concepts to make the magic happen:</p><h3>1. 🔄 Reverse Tunnel is Created</h3><ul><li>When you run ngrok http 3000, the <strong>Ngrok client</strong> on your machine creates a <strong>persistent encrypted TCP connection</strong> to <strong>Ngrok’s cloud server</strong>.</li><li>Your machine initiates the connection (<strong>outbound</strong>), which makes it <strong>firewall/NAT-friendly</strong>.</li></ul><h3>2. 🌍 A Public Endpoint Is Generated</h3><ul><li>Ngrok provides a public <strong>HTTPS</strong> (or HTTP) URL.</li><li>That URL points to Ngrok’s cloud, which acts as a <strong>reverse proxy</strong> for your local app.</li></ul><h3>3. 🔁 Request Flow Explained</h3><pre>User&#39;s browser    <br>↓ <br>Ngrok Cloud Server (public endpoint)    <br>↓ <br>Secure Tunnel (TCP)    <br>↓ <br>Your local server (e.g., localhost:3000)</pre><h3>4. 🔧 No Port Forwarding Required</h3><ul><li>Traditional port forwarding requires modifying router settings.</li><li>Ngrok skips all that by using an <strong>outbound tunnel</strong> — your machine starts the connection, not the client.</li></ul><h3>🧱 Technologies Behind Ngrok</h3><ul><li><strong>Reverse Proxying</strong> (like Nginx or HAProxy)</li><li><strong>TLS Encryption</strong> (for secure HTTPS)</li><li><strong>Persistent TCP Tunnels</strong></li><li><strong>WebSocket support</strong></li><li>Built in <strong>Go</strong> (the Ngrok client/server)</li></ul><h3>🎯 Final Thoughts</h3><p>Ngrok is an incredible tool that saves developers <strong>time, frustration, and setup hassle</strong> — especially when testing local projects or dealing with external services that expect a public callback URL.</p><p>But remember: it’s designed for <strong>temporary use</strong>, <strong>not production deployment</strong>. For long-term setups, you’d want a proper server or cloud deployment.</p><p>Still, as a dev tool? It’s pure magic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27a4c317af59" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>