<?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 Purnima Gupta on Medium]]></title>
        <description><![CDATA[Stories by Purnima Gupta on Medium]]></description>
        <link>https://medium.com/@dhammapurnima?source=rss-5fd1aedf6f88------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XRI6EwSqQxgqqU6cFb7qPA.jpeg</url>
            <title>Stories by Purnima Gupta on Medium</title>
            <link>https://medium.com/@dhammapurnima?source=rss-5fd1aedf6f88------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:09:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dhammapurnima/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[Software Engineer to Medical Aesthetician: My Journey with CO₂ Laser]]></title>
            <link>https://medium.com/@dhammapurnima/software-engineer-to-medical-aesthetician-my-journey-with-co%E2%82%82-laser-9d7fa62d69c1?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d7fa62d69c1</guid>
            <category><![CDATA[skin-treatment]]></category>
            <category><![CDATA[skin]]></category>
            <category><![CDATA[skincare]]></category>
            <category><![CDATA[acne-scar-removal]]></category>
            <category><![CDATA[fractional-co2-laser-cost]]></category>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Sun, 28 Sep 2025 10:52:47 GMT</pubDate>
            <atom:updated>2025-09-29T06:23:04.080Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*j6VwMgegRt6i-LJIYeFIqA.png" /><figcaption>Indication of CO2 laser</figcaption></figure><p>I’m a former software professional turned medical aesthetician. I’ve always been passionate about skincare — not just for beauty, but for the science of creating healthy, glowing skin. Honestly, my skin was considered “good” by dermatologists — no major acne, scars, or pigmentation issues.</p><p>But there was one thing that bothered me: <strong>open pores</strong>.</p><p>They weren’t massive, but they weren’t tiny either. Most people wouldn’t even notice, but I’m the kind of person who loves <strong>clean, clear, glass-like skin</strong>. Maybe it’s an obsession. Maybe it’s just me.</p><p>So, I started my quest for solutions. I visited at least four dermatologists. The advice I got varied:</p><ul><li>Some suggested a <strong>CO₂ laser</strong></li><li>Others recommended <strong>fillers</strong> to “fill in” the pores</li><li>A few advised a <strong>combination of fillers + CO₂</strong></li><li>Others said <strong>microneedling with PRP</strong> would help</li></ul><p>After all the consultations, I chose the fractional CO₂ laser.</p><p>Why?</p><p>Because unlike fillers, which add volume but don’t rebuild the skin’s foundation, CO₂ penetrates deeper, tightens tissue, and — most importantly — stimulates collagen production. Collagen is the real scaffolding of youthful, healthy skin, and most treatments (CO₂, microneedling, PRP) work by remodelling it. The difference lies in depth, heat, skin type, and the specific concern being treated.</p><p>If you’re an aspiring medical aesthetician — or simply curious but skeptical about CO₂ — let’s break down the science, parameters, benefits, risks, and aftercare in simple terms. I’ve seen patients not given protective eyewear — a huge red flag since it can damage the eyes. Always choose your practitioner wisely.</p><p>Three sessions later, were my pores gone? No. Did they look tighter and smoother? A little — but not dramatically. That gap between “realistic” and “perfect” drove me into the physics, parameters, and protocols behind the beam.</p><p>This guide is the result of that curiosity — so a new medical aesthetician (or any curious learner) can:</p><ul><li>Explain <strong>why</strong> CO₂ helps pores/texture/scars beyond buzzwords.</li><li>Pick parameters (fluence, density, pulse width, stacking) with intention — not habit.</li><li>Set expectations honestly (collagen remodelling is a months-long story).</li><li>Keep patients safe (HSV prophylaxis, plume evacuation, proper eyewear, PIH prevention).</li></ul><h3>Part 2 — The science</h3><p><strong>What it is (in simple words):</strong><br> A CO₂ laser is a gas laser that uses a mix of carbon dioxide, nitrogen, and helium. When it’s excited by electricity, the gases interact and release energy at a wavelength of <strong>10,600 nm</strong> — in the mid-infrared range. Water in the skin absorbs this wavelength very strongly. Since our skin is mostly water, this makes the laser excellent for <strong>precise ablation (removing tissue)</strong> and <strong>coagulation (sealing blood vessels for hemostasis)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*qu6nvFiI9viB8J1Egfh6Ng.png" /><figcaption>CO2 Laser Deoth of Penetration by Wavelength</figcaption></figure><h4>Why Water Matters</h4><p>The CO₂ laser emits light at a <strong>wavelength of 10.6 micrometers (µm)</strong>. This describes the “color” of the light in the <strong>mid-infrared range</strong> (though invisible to our eyes).</p><p>What’s unique about this wavelength is how strongly it’s absorbed by <strong>water</strong> — and since our skin is about 70% water, that makes it the perfect target. At 10.6 µm, water soaks up the energy almost immediately, so it only penetrates around <strong>15–20 µm deep</strong> before being absorbed.</p><p>Think of it like <strong>sunlight hitting shallow water at the beach</strong>. The light doesn’t travel very far before it’s scattered and absorbed at the surface — but that little burst of energy still stirs up currents underneath.</p><p>That’s exactly what happens in the skin:</p><ol><li><strong>At the surface</strong> → the laser precisely vaporizes thin layers (ablation).</li><li><strong>Just below the surface</strong> → heat creates controlled “thermal zones” that trigger <strong>collagen contraction and remodeling</strong>.</li></ol><p>So even though the CO₂ laser is absorbed very superficially, the real “wow factor” comes from the <strong>deep collagen changes</strong> it sets in motion — which is why it improves pores, scars, and texture over time</p><h4>How Deep Does It Go (clinically)?</h4><p>When we talk about CO₂ lasers, the depth isn’t fixed — it depends on the <strong>settings you choose</strong> and how many passes you make.</p><ul><li><strong>Typical single pass:</strong> removes (ablates) about <strong>50–150 µm</strong> of skin.</li><li><strong>Thermal/coagulation zone:</strong> adds another <strong>~80–200+ µm</strong> of controlled heating below that.</li><li><strong>Stacking or multiple passes:</strong> lets you go deeper, reaching into the <strong>upper to mid-dermis</strong> — which is why this approach is especially helpful for <strong>acne scars, burn scars, or surgical scars</strong>.</li></ul><p>Here’s the key: you don’t “shoot the laser deeper” like a drill. Instead, you <strong>build depth</strong> by adjusting parameters:</p><ul><li><strong>Energy/fluence</strong> → how strong each pulse is.</li><li><strong>Pulse duration</strong> → how long the pulse lasts.</li><li><strong>Density</strong> → how close together the laser spots are.</li><li><strong>Stacking</strong> → how many times you hit the same spot.</li></ul><p>🔍 <strong>Analogy:</strong> Think of it like peeling layers off an onion. One gentle pass removes just the outer layer. If you go over the same spot again with more intensity, you gradually work deeper—but always in a controlled, layer-by-layer way.</p><h4>CO₂ vs Er: YAG vs Nd: YAG (why CO₂ for texture/pores/scars):</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pFpKuehfvtT8feycL9Sn2g.png" /><figcaption>CO2 vs Erbium Laser vs Nd:yag Laser</figcaption></figure><p>CO₂ leaves more <strong>residual thermal damage</strong> than Er:YAG (up to ~200 µm vs ~50 µm in classic histology), which is exactly why it tightens and remodels more, but with longer recovery.</p><p>Nd: YAG excels for pigment/vascular work (532/1064 nm Q-switched or long-pulsed variants).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ceZeiI-Y4preg3LQwcgFFA.png" /><figcaption>CO2 builds Collagen</figcaption></figure><h3>Part 3 — The Clinic Playbook (indications, parameters, safety, evidence)</h3><h4>Indications (where it helps)</h4><p>Fractional CO₂ <strong>smooths surface texture</strong> and tightens pores by stimulating collagen.</p><h4>Scars</h4><p>Effective for:</p><ul><li>Acne scars</li><li>Surgical scars</li><li>Traumatic scars</li><li>Burn scars</li></ul><h4>Benign Lesions</h4><p>Treats:</p><ul><li>Seborrheic keratoses (SKs)</li><li>Warts</li><li>Xanthelasma (yellow eyelid cholesterol deposits)</li><li>Epidermal nevi (noncancerous birthmarks)</li><li>Rhinophyma (overgrown nasal tissue from rosacea)</li></ul><h4>Laser-Assisted Drug Delivery</h4><p>Fractional micro-channels allow <strong>topical medications</strong> to penetrate deeper for better efficacy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*j6VwMgegRt6i-LJIYeFIqA.png" /><figcaption>Function of CO2 Laser</figcaption></figure><h4>Different Modes of CO₂ Laser:</h4><p>CO₂ lasers can be utilised in various ways, depending on the <strong>treatment goal</strong>. Understanding the mode is essential because it determines the depth of the laser penetration, the amount of downtime patients experience, and the conditions it treats most effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wq3Wl53CNrzE8cUewY07Fg.png" /><figcaption>Fully Ablative CO2 Laser versus Fractional CO2 Laser</figcaption></figure><h4>Laser Parameters That Actually Change Outcomes</h4><p>When you’re working with a CO₂ laser, results don’t just come from “turning it on.” They depend on the <strong>parameters you choose</strong>. Each setting changes how deep the laser goes, how much thermal effect there is, and ultimately how the skin heals.</p><p>Think of parameters as the <em>recipe</em>: change one ingredient, and the whole dish tastes different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ylCuTiWOBqchvz9PhrOhEQ.png" /><figcaption>Energy vs Density vs Pulse Width vs Stacking vs Spot Size</figcaption></figure><h4>Starting “Recipes” (Always Individualise)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KYU-GCl9N1ZpBEGFi5uf3A.jpeg" /><figcaption>Common Parameters starting Point</figcaption></figure><p>📌 <strong>Histology confirms:</strong> deeper MTZs are achieved with higher energy, denser patterns, and stacking. Always do a <strong>test spot</strong> and follow the <strong>manufacturer’s guidelines</strong>.</p><h4>Who Should Be Cautious / Contraindications</h4><ul><li>Recent isotretinoin, active infection, impaired healing → high risk</li><li>Unrealistic expectations → CO₂ improves, doesn’t perfect</li><li>Darker skin (Fitz IV–VI) → lower energy, strict UV protection, consider pigment prep</li><li>Smoking → slower healing, worse results; advise cessation</li></ul><h4>Side Effects and Downtime (What Patients Should Know)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*to1teAinyhA_wO2uJgJMzg.png" /></figure><p><strong>Possible Risks (Less Common but Important to Mention):</strong></p><ul><li>PIH (esp. darker skin), milia/acne flare, infections (HSV), prolonged erythema, rare scarring. Antiviral ± antibiotic prophylaxis is common for high-energy/full-face work.</li></ul><p>➡️ Because of these risks, many clinicians prescribe <strong>antiviral medication</strong> (and sometimes antibiotics) before high-energy or full-face treatments as a preventive step.</p><h4>Pre-op, Intra-op, Post-op Checklist (fractional CO₂)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATIv5gGX1A9rLZ-hCIsf4w.png" /><figcaption>Pre-Op, Intra-Op, Post-Op checklist For Fraction Laser</figcaption></figure><p><strong>HSV Prophylaxis Explained:</strong><br> Preventive antiviral medication (acyclovir/valacyclovir) is given to reduce cold sore activation. CO₂ laser creates controlled skin injury, which can reactivate dormant HSV.</p><p><strong>Eye Protection:</strong></p><ul><li>Patient: wavelength-specific metal shields</li><li>Operator &amp; Assistants: OD-rated 10,600 nm goggles</li></ul><blockquote><em>Never skip eye protection; laser can cause permanent blindness.</em></blockquote><h4>Evidence You Can Quote</h4><ul><li><strong>Acne scars:</strong> Fractional ablative CO₂ is among the most effective treatments (meta-analyses, PMC)</li><li><strong>Combination with PRP:</strong> Higher improvement scores, shorter crusting/healing vs CO₂ alone</li><li><strong>Photoaging &amp; texture:</strong> Supported with proper patient selection and aftercare</li><li><strong>Large pores:</strong> Outperforms non-ablative lasers for reduction, not disappearance</li></ul><h3>🧾 Part 4 — Counselling, Expectations &amp; FAQs</h3><h4>1. Setting the Right Expectations</h4><ul><li>No “glass skin” promise: Fractional CO₂ can shrink pores and smooth texture, but it will not erase pores completely. Patience is key: Results improve gradually over months as collagen remodels.</li><li>Often needs multiple sessions: One session helps, but a series of treatments is usually needed for best results.</li><li>Boosting outcomes: Combining with microneedling, PRP, or topical serums delivered through the laser’s microchannels can enhance results.</li></ul><h4>2. Skin of Colour (Phototypes IV–VI)</h4><ul><li>Yes, CO₂ can be done safely in darker skin tones — but: Use conservative settings. Ensure rigorous prep and aftercare.</li><li>Emphasise strict photoprotection (SPF is non-negotiable).</li><li>Consider pigment-control strategies before/after treatment.</li><li>Allow longer gaps between sessions to reduce PIH risk.</li></ul><h4>3. Safety Pearls Every Aesthetician Must Follow</h4><ul><li><strong>HSV prophylaxis</strong> when needed (especially full-face, high-energy, or perioral treatments).</li></ul><blockquote>⚠️ Did You Know? — HSV Prophylaxis</blockquote><blockquote>HSV prophylaxis means giving a preventive antiviral medicine (like acyclovir or valacyclovir) before the laser session.</blockquote><blockquote>Purpose: to stop the herpes simplex virus (cold sores) from flaring up.</blockquote><blockquote>Why: CO₂ laser treatments create controlled injury to the skin, which can reactivate dormant HSV (especially around the lips).</blockquote><blockquote>Result: prophylaxis keeps healing smooth and avoids painful complications.</blockquote><ul><li><strong>Eye protection:</strong> Everyone in the room must wear <strong>OD-rated goggles for 10,600 nm CO₂</strong> — regular goggles are not safe.</li></ul><blockquote>Laser beam can cause <strong>irreversible eye injuries</strong>, including corneal burns and even permanent vision loss.</blockquote><blockquote>Protective Eyewear Guidelines</blockquote><blockquote>Role Protection Type Why It’s Important Patient Wavelength-specific metal eye shields Direct + reflected beam protection Doctor/Operator Laser safety goggles (10,600 nm rated) To block scattered/reflected laser energy Assistants Same as operator Lasers scatter off walls, instruments, skin</blockquote><blockquote><strong>Key Point:</strong></blockquote><blockquote>No shield → no treatment.</blockquote><blockquote>Laser rooms should have <strong>warning signs</strong>, <strong>door interlocks</strong>, and <strong>no reflective surfaces</strong>.</blockquote><blockquote>I always tell new aestheticians: <em>If your provider ever forgets or dismisses eye shields, stop the procedure immediately</em>. Your eyes are irreplaceable.</blockquote><ul><li><strong>Plume evacuation:</strong> Always use a <strong>smoke evacuator with HEPA/ULPA filter</strong> close to the skin surface; plume can contain viruses and harmful particles.</li><li><strong>Documentation is key:</strong> Record test spots, chosen parameters, visible endpoints, pain management, aftercare advice, and obtain <strong>photo-consent</strong> before treatment.</li></ul><h3>🔬 Nerd Notes (for clinicians)</h3><ul><li><strong>Depth per pass:</strong> ~50–150 µm</li><li><strong>Stacking:</strong> increases penetration depth safely</li><li><strong>Wavelength:</strong> 10,600 nm CO₂ is absorbed by water, driving ablation + collagen remodeling</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TjOQXKYZHm0JEbqkFOoKKQ.png" /><figcaption>Collagen Remodelling Phase</figcaption></figure><h3>🌟 Final Take — Honest &amp; Actionable</h3><p>From both my own journey and the research, here’s the truth: <strong>fractional CO₂ laser works beautifully for shrinking pores, softening scars, and smoothing skin texture</strong> — but it will not give you “glass skin.”</p><p>The <strong>best results</strong> typically occur when fractional CO₂ is combined with other advanced treatments, such as <strong>PRP, microneedling, or topical actives delivered through the laser’s microchannels (MTZs)</strong>. These should be spaced at the right intervals and paired with <strong>careful aftercare</strong> to protect and maximise the outcome.</p><p>If you’re the aesthetician holding the handpiece, remember that your real advantage lies in:</p><ul><li><strong>Precision with parameters</strong></li><li><strong>Uncompromising safety practices</strong></li><li><strong>Clear, realistic expectation setting with patients</strong></li></ul><p>That’s where the artistry of medical aesthetics meets science. For more in-depth guides like this, follow me on Medium, where I break down advanced aesthetic treatments in simple, practical terms for both enthusiasts and budding medical aestheticians.</p><h3>Sources you can click and keep handy</h3><ul><li><strong>Guides/overviews &amp; technique:</strong> StatPearls (ablative resurfacing, Er:YAG, point-of-care). (<a href="https://www.ncbi.nlm.nih.gov/books/NBK557474/?utm_source=chatgpt.com">NCBI</a>, <a href="https://www.statpearls.com/point-of-care/24071?utm_source=chatgpt.com">StatPearls</a>)</li><li><strong>Optical depth &amp; thermal injury:</strong> JAMA Dermatology (Er:YAG vs CO₂ residual thermal damage). (<a href="https://jamanetwork.com/journals/jamadermatology/fullarticle/477802?utm_source=chatgpt.com">JAMA Network</a>, <a href="https://pubmed.ncbi.nlm.nih.gov/10206045/?utm_source=chatgpt.com">PubMed</a>)</li><li><strong>Parameter effects &amp; stacking:</strong> clinical comparisons and device studies. (<a href="https://jamanetwork.com/journals/jamadermatology/fullarticle/189500?utm_source=chatgpt.com">JAMA Network</a>, <a href="https://www.rp-photonics.com/co2_lasers.html?utm_source=chatgpt.com">RP Photonics</a>)</li><li><strong>Drug delivery through MTZs:</strong> fractional laser-assisted delivery review. (<a href="https://www.cdc.gov/niosh/docs/hazardcontrol/hc11.html?utm_source=chatgpt.com">CDC</a>)</li><li><strong>PIH / skin of color considerations:</strong> reviews and guidance. (<a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC9843402/?utm_source=chatgpt.com">PMC</a>)</li><li><strong>Plume &amp; eye safety:</strong> NIOSH / CDC-linked resources; eyewear OD for 10.6 µm. (<a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC12282845/?utm_source=chatgpt.com">PMC</a>, <a href="https://link.springer.com/article/10.1007/s10103-023-03855-6?utm_source=chatgpt.com">SpringerLink</a>, <a href="https://pubmed.ncbi.nlm.nih.gov/20166154/?utm_source=chatgpt.com">PubMed</a>)</li><li><strong>Benign lesion &amp; rhinophyma use:</strong> guidelines and clinical outcomes. (<a href="https://ijdvl.com/standard-guidelines-of-care-co-2-laser-for-removal-of-benign-skin-lesions-and-resurfacing/?utm_source=chatgpt.com">IJDL</a>, <a href="https://medicaljournalssweden.se/actadv/article/view/41335?utm_source=chatgpt.com">Medical Journals Sweden</a>)</li><li><strong>Acne scars (CO₂ ± PRP):</strong> meta-analyses and comparative trials. (<a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC8112111/?utm_source=chatgpt.com">PMC</a>)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d7fa62d69c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Days of Silence: The War Inside That No One Talks About]]></title>
            <link>https://medium.com/@dhammapurnima/10-days-of-silence-the-war-inside-that-no-one-talks-about-26a863ed1281?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/26a863ed1281</guid>
            <category><![CDATA[meditation]]></category>
            <category><![CDATA[vipassana]]></category>
            <category><![CDATA[war]]></category>
            <category><![CDATA[sprituality]]></category>
            <category><![CDATA[fear]]></category>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Fri, 04 Jul 2025 11:07:58 GMT</pubDate>
            <atom:updated>2025-07-04T11:21:52.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ha-OzMuskevUW6hbvqfuyA.jpeg" /><figcaption>Sri Ramana Maharishi on Service</figcaption></figure><p>So this was my fifth time going for the 10-day Vipassana silence retreat in 2025. Ever since Covid hit the world, I had been longing to go back. Meditation became a daily part of my life, especially after I completed my second retreat as a server. Something changed in me after that one. My discipline got sharper. My determination became steel-like. I could suddenly sit cross-legged for one hour without moving, not even an inch. I was literally a statue. Me — someone who used to fidget 30 times in an hour. No exaggeration. That number might sound comical, but believe me, it’s real.</p><p>During Covid, since courses were not happening, I used to attend these online group meditation Sanghas over Zoom. Around 20–30 people would join, meditate for an hour, and then whoever had questions would stay back to ask. One of them suggested something that lit me up — if one could maintain noble silence, isolate themselves completely, and follow all rules sincerely, you could do your own retreat at home. I was so excited I nearly jumped off my chair. I planned it, did it. The last two days were a bit relaxed — I took a nap in the afternoon and didn’t meditate every single hour, but I followed all the group sittings. And it was beautiful.</p><p>Finally, in 2023, I got a confirmation email to serve. I felt like a kid who just got permission to go on a school trip. I was so excited to go and serve people — to be there for someone else’s journey. I genuinely feel that service is deeply aligned with who I am. But when I told my family, they weren’t thrilled. They wanted me to focus on building a career and earning money. Lol. It’s not like I’m becoming a monk! (Although… I’ve thought about it. Next life maybe? Wink wink.)</p><p>So I cancelled it. Just like that. The one thing that makes me feel alive — I couldn’t do it. Because of this constant pressure to “do something else.” Something more normal, more productive. Something I’m not even remotely interested in. <em>It is what it is.</em></p><p>Fast forward to 2025 — finally, I went again. This time as a server. And this time, I didn’t ask for anyone’s approval. Not even a whisper. I was going. Period.</p><p>Before every course, I always get this feeling like I’m heading for some grand vacation. Like it’s a luxurious world trip or something. I know it’s not glamorous — I’m just packing my kurta-pajamas and getting ready to give up talking, reading, writing, phones, eye contact… basically everything — but the excitement is REAL. This practice follows me around like a shadow if I don’t do it. Just like when I skip workouts, I feel off. My inner self knows when I’ve gone off-track.</p><p>I was happy. And nervous. And determined.</p><p>But I also knew I’d want to run away at some point. Just like the first time.</p><h3>Even the Fifth Time Feels Like the First</h3><p>People assume that if you’ve done something multiple times, it gets easier. Hahaha. No. If you take a gap of a couple of years, your mind will greet you at the gate with, “Let’s do this chaos all over again.”</p><p>When I reached the registration office, I sat on the chair and looked around. Most of the people were much older — late 40s to 80s. I suddenly felt weirdly trapped. My mind started its monologue:</p><blockquote><em>“Why am I here again?”<br> “No one forced you. You chose this. You wanted this. Remember?”</em></blockquote><p>I nodded to myself like a crazy person. The mental chatter had begun, and the course hadn’t even started.</p><p>There were four servers this time instead of two. At first, I thought, “Oh great! More hands, less work.” But no. It became a silent negotiation of who does what. This is where your inner personality really shows up. Even if your intention is to help, there will be moments where you go, <em>“Why am I the only one doing this?”</em> And then your wiser self gently smacks you and says, <em>“You’re not here for comfort. You’re here to serve. Shut up and keep going.”</em></p><p>And yes, I laughed at myself often. Service has this way of putting a magnifying glass on all your petty thoughts and reactions. It shows you how impatient or self-important you can be, and how often you fall into comparison. But also, how beautiful it is to shift, breathe, and keep doing the work.</p><h3>The Sleep That No Doctor Could Prescribe</h3><p>As servers, we would wrap up the day with Metta meditation after everyone had gone to bed. By the time we reached our rooms, it was 10:30 p.m. I would then shower, wash my clothes, and finally get into bed by 11:30 p.m. And then? Blissful sleep.</p><p>I usually have trouble falling asleep — some nights are just endless tossing and turning. But there? I was OUT. The kind of deep, undisturbed sleep that felt like a luxurious gift. And again, the inner voice: <em>“Maybe insomnia doesn’t need a doctor. Maybe it needs silence.”</em></p><h3>Meditation Means War (with Yourself)</h3><p>Every sit brought its own drama. The moment I closed my eyes and planned to observe sensations… boom! Inner theatre activated. The suppressed thoughts, the repressed anger, the unnecessary sadness — it all came up. Magnified. Raw.</p><p>Actually, it wasn’t magnified. It was <em>always there</em>. I was just finally noticing it.</p><p>And then, there’s the fan. Oh yes, the infamous fan. They slow them down to avoid interfering with subtle sensations. Which makes sense. But tell that to my dripping, sweaty body. I wanted to scream. My inner dialogue in those moments:</p><blockquote><em>“</em><strong><em>Why can’t we have one good thing — just one?”</em></strong><em><br> “</em>Calm down. Heat is also a sensation.<em>”<br> “</em><strong><em>This is just pure torture.” Again, why am i doing this?</em></strong><em><br> “</em>sshhhh just observe. Don’t react. This is what you’re here for — to observe every pain, every ache , with compassion and equanimity.<em>”<br> “</em><strong><em>Easy for you to say, wise version of me. YOU are not sweating. You’re releasing</em></strong><em>”</em></blockquote><p>This is real. Meditation doesn’t make you stoic in a day. But the intensity of reactions comes down. And slowly, very slowly, you start choosing different thoughts. Less breeding of negativity. More awareness. That’s progress.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*gLmD2IySg8DcrNUpMMjJ3Q.png" /><figcaption>The Mother on Fear</figcaption></figure><h3>Of Fruits, Determination, and Strong Will</h3><p>Now let me talk about something funny: <strong>the fruit situation.</strong></p><p>At Vipassana, old students get fruits in the morning. New students get fruits in the evening. That’s the guideline. And yet — oh, the temptation. Some people were taking fruits <em>both</em> times. I watched this in silence, my inner dialogue raging:</p><blockquote><em>“Why are they doing this?”<br> “This is not allowed!”<br> “Is this really bothering you?”<br> “Apparently, yes. Deeply.”</em></blockquote><p>I had to remind myself — this whole system is built to test your willpower. To strengthen it. You can take however much food you want, no one’s stopping you. But are you choosing to respect the rule? That’s the question. That’s the real game. Can you restrain even when no one is watching?</p><p>This reminded me of a book I read: <strong>“The Causal Body and the Ego” by Arthur E. Powell.</strong> Here’s a quote that really stuck with me:</p><blockquote><em>“The will is a far higher faculty than the intellect, for it is nearer to the Spirit. Will is a spiritual power, and it can be used for the highest purposes. Intellect is limited to the field of form; it can deal only with the external. The affection is stronger than the intellect, and love can often move people where argument fails; but the will, when rightly directed, is even stronger than love.”</em></blockquote><p>Intellect &lt; Affection &lt; Will Power</p><p>He also writes about how pets living with humans absorb their qualities and, through the power of affection and exposure, can often be reborn as human beings in their next life. It’s not guaranteed, but the possibility is strong. All of this is beautiful — but still, nothing supersedes a strong-willed being.</p><p>Affection can uplift. Intellect can argue. But it is <strong>will</strong> that carries the soul forward.</p><p>That’s the kind of will you need when you decide not to eat fruit twice a day. 😂</p><h3>Ramana Maharshi on Ego, Siddhis, and Real Power</h3><p>This experience also brought me back to the teachings of <strong>Sri Ramana Maharshi</strong>, especially from <em>Be As You Are</em>, compiled by David Godman.</p><p>Ramana says:</p><blockquote><em>“Siddhis denote extended powers. A man is possessed of limited powers and is miserable. Because of this he wants to expand his powers so he may be happy. But consider if it will be so. If with limited perceptions one is miserable, with extended perceptions the misery must increase proportionately. Occult powers will not bring happiness to anyone, but will make one all the more miserable. Moreover, what are these powers for? The would-be occultist desires to display the siddhis so that others may appreciate him. He seeks appreciation, and if it is not forthcoming he will not be happy. There must be others to appreciate him. He may even find another possessor of higher powers. That will cause jealousy and breed unhappiness.”</em></blockquote><p>And then comes the most profound part:</p><blockquote><em>“Which is the real power? Is it to increase prosperity or bring about peace? That which results in peace is the highest perfection [siddhi].”</em></blockquote><p>This is the truth. And it’s something I want everyone to sit with. So many people spend their lives chasing — like rats on a wheel — for powers, money, influence. Always looking for ways to inflate the ego.</p><p>But real power?</p><p>It’s quiet. It’s still. It brings peace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*z5z0n3VOQElQQ6XGl3UVRw.jpeg" /><figcaption>Alan Watts on Meaning of Life</figcaption></figure><h3>The Ego Burns, and Something Subtler Rises</h3><p>One of the days, I developed a severe allergic reaction on my feet that crept up my legs. It was itchy, hot, and painful. I got sad looking at it. They got me medicine, but it didn’t help much. I had a gut feeling — it was from internal heat. Anger maybe. Repressed emotions finding their way out through the body.</p><p>I told the teacher. She smiled gently and said, <em>“Just observe. Where do you feel it in the body?”</em> I nodded. I knew what she meant. This too had to be seen — not reacted to.</p><p>Then there were students breaking silence, giggling, making eye contact, taking fruits twice… you name it. And every time, it tested me. My irritation was a mirror. A big, bold one.</p><p>But I stayed calm on the outside. Because that’s the practice. And honestly? When you stop talking to people, your inner voice gets louder. You talk to yourself more. You reflect more. You see more.</p><p>And that is such a <em>powerful thing</em>.</p><p>We spend so much of life blaming others. I’ve done it too — relying on others to make decisions for me, then feeling lost. But I finally asked myself: <em>Why am I scared of making my own decisions? What will really happen if I fail?</em></p><p>I imagined myself sitting on my deathbed someday, haunted by the thought: <em>“What if I had just taken that one step? What if I had done the thing my soul longed for?”</em></p><p>I don’t want that. I don’t want to live my life haunted by the things I didn’t do. We can’t do everything, sure — but there are a few rare, deeply personal things that matter to each of us. And if we don’t honor those, they become ghosts that follow us.</p><p>So I made a vow: <em>No regrets.</em> I will choose. I will decide. Even if it fails. Because at least it’s mine.</p><p>I recently came across something the Mother said on 14 March 1951 that struck me right in the gut:</p><blockquote><strong><em>Why does one feel afraid?</em></strong></blockquote><blockquote>I suppose it is because one is egoistic. There are three reasons. First, <strong>an excessive concern about one’s security.</strong> Next, what one does not know always gives an <strong>uneasy feeling </strong>which is translated in the consciousness by fear. And above all, one doesn’t have the habit of a <strong>spontaneous trust </strong>in the Divine. If you look into things sufficiently deeply, this is the true reason. There are people who do not even know that That exists, but one could tell them in other words, “You have no faith in your destiny” or “You know nothing about Grace” — anything whatever, you may put it as you like, but the root of the matter is a <strong>lack of trust</strong>. If one always had the feeling that it is the best that happens in all circumstances, one would not be afraid.</blockquote><h3>What It Really Means to Serve Dhamma</h3><p>Goenka ji says: <strong>Don’t serve if you’re arrogant, rigid, or easily irritated.</strong></p><p>Serving requires deep compassion, flexibility, and patience. You are, in a way, representing Dhamma. People learn from how you walk, talk, move — even when you’re not “teaching.”</p><p>Some days, I felt I wasn’t doing a good job serving. I got lazy. I judged. I struggled. But then, on the last day, some of the older students came to me and said, <em>“Thank you. You really did a good job.”</em></p><p>I went to my room and almost cried.</p><h3>Gratitude, Guilt, and the Goodbye</h3><p>Every day felt like ten. Every sit felt like a battleground. My mind wanted to run. My body wanted to rest. But I stayed. I showed up. I meditated. I served.</p><p>And even though I didn’t feel like something huge had shifted in me, when I came back, people told me, <em>“You look peaceful. You seem lighter.”</em></p><p>Maybe that’s what healing is. Not a dramatic transformation, but the silent dissolving of something heavy inside you.</p><p>And now, I can say this: <strong>The trauma I’d been carrying for the past year… doesn’t sting anymore.</strong></p><p><strong>Don’t go expecting bliss. Go expecting war. With yourself. And stay anyway.</strong></p><p>That’s where the real magic begins.</p><p>And before you go — please reflect on this:</p><blockquote><em>What are you chasing?<br> Power, recognition, wealth, validation?</em></blockquote><p>Are you inflating your ego in the name of self-growth?</p><p>Or are you choosing peace, even when it’s silent and invisible?</p><p>The world doesn’t need more power. It needs more peace.</p><h4>Further read if you’re interested.</h4><p><a href="https://incarnateword.in/compilations/fear-its-cause-and-cure">The Incarnate Word</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26a863ed1281" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Confused why your friend’s laser worked, but yours didn’t?]]></title>
            <link>https://medium.com/@dhammapurnima/understanding-fluence-settings-in-laser-hair-removal-80aace1b257d?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/80aace1b257d</guid>
            <category><![CDATA[laser-hair-removal]]></category>
            <category><![CDATA[fluence]]></category>
            <category><![CDATA[skincare]]></category>
            <category><![CDATA[nd-yag-laser]]></category>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 11:13:30 GMT</pubDate>
            <atom:updated>2025-06-08T10:14:31.081Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*zKupFMc4-9csgQd_byBLQA.png" /><figcaption>Select laser based on skin tone</figcaption></figure><p>In this blog, I’ll break down one of the most misunderstood aspects of laser hair removal: <strong>how to choose the correct fluence settings based on skin and hair color</strong>. Many practitioners make critical errors by not fully understanding the role of <strong>melanin</strong>, <strong>wavelengths</strong>, and <strong>cooling systems</strong>. Let’s simplify this with science-backed insights.</p><h4>Imagine this.</h4><p>Two people walk into the same laser clinic.<br>Same technician. Same machine. Same settings.<br>But they don’t walk out the same.</p><p>One feels nothing more than a warm flicker.<br>The other leaves with a sting, a burn, and the silent question — <br> <em>“Did something go wrong with my skin?”</em></p><p>It didn’t.<br>Their skin didn’t fail them. The treatment did.</p><p>Because under every skin tone lies a different relationship with light.<br>And darker skin, with all its strength and beauty, holds more melanin — <br>which means more heat, more risk, and more care required.</p><p>When clinics don’t account for that — <br> when they turn the <em>energy down</em> to play it safe,<br> or worse, don’t cool the skin enough — <br> they’re not just compromising results.<br> They’re compromising trust.</p><p>Laser isn’t just about zapping hair.<br>It’s about knowing who’s in front of you.<br>It’s about understanding the science <em>and</em> the soul inside that skin.</p><p>Because every tone deserves safety. Every client deserves confidence.<br> And no one should walk out wondering if their skin was the problem.</p><h3>The Science: Melanin &amp; Temperature</h3><ul><li><strong>Melanin</strong> is the pigment that gives skin its color.</li><li>When laser light hits the skin, <strong>melanin absorbs the energy</strong>, converting it into <strong>heat</strong>.</li><li>This <strong>temperature rise</strong> is <strong>directly proportional</strong> to the amount of <strong>melanin</strong> in the <strong>epidermis</strong>.</li></ul><blockquote><strong>More melanin = More absorption = Higher temperature = More pain &amp; risk of epidermal damage.</strong></blockquote><h3>⚖️ Melanin Distribution in Different Skin Types</h3><p>When laser energy enters the skin, <strong>melanin</strong> — the pigment that gives skin its color — becomes the key absorber.</p><blockquote>More melanin → More heat in the epidermis → Less energy reaches the follicle</blockquote><h4>Skin Tone Reactions Summary:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__VdrGCwovm-I4zzbbSYDA.png" /><figcaption>Skin Tone reactions to lasers</figcaption></figure><h3>🎯 Key Concept: Where the Energy Goes</h3><ul><li>In <strong>lighter skin</strong>, most laser energy reaches the <strong>hair follicle</strong>.</li><li>In <strong>darker skin</strong>, much of the energy is absorbed in the <strong>epidermis</strong>, leading to:</li></ul><blockquote><strong>- Higher pain</strong></blockquote><blockquote><strong>- Risk of burns or hyperpigmentation</strong></blockquote><blockquote><strong>- Less energy reaching the follicle</strong></blockquote><h3>So, What Affects Fluence and Cooling?</h3><h4>1. Fluence (Laser Power) → Based on Hair</h4><ul><li>Dictated by the <strong>depth and thickness</strong> of the <strong>hair follicle</strong>.</li><li><strong>Thicker &amp; deeper hair</strong> (like in underarms or bikini area) = <strong>Higher fluence needed</strong>.</li></ul><p>❗️<strong>Fluence is about the hair — not the skin color!</strong></p><h4>2. Cooling → Based on Skin</h4><ul><li><strong>Darker skin requires more cooling</strong> due to increased melanin.</li></ul><p><strong>Cooling prevents damage and reduces pain</strong> in the upper skin layers (epidermis).</p><p>Correct logic:</p><ul><li>Deep follicle (like bikini, underarms) → More fluence needed</li><li>Dark skin → More cooling required</li></ul><p>Turning down fluence for darker skin compromises results. Instead, mitigate risk by increasing <strong>cooling</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*qXrrYKHWkVk5T00NlELIxA.png" /><figcaption>Cooling requirements for different skin tones</figcaption></figure><h3>📉 Wavelength &amp; Melanin Absorption</h3><p>Laser wavelength affects how much is absorbed by melanin:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNnff4BJaKUn4_uz7csh3w.png" /><figcaption>How different wavelength affects how much energy is absored by melanin</figcaption></figure><blockquote>⚠️ <strong>Lower wavelengths = More melanin absorption = Higher epidermal temperature.</strong></blockquote><h3>🧊 The Role of Skin Cooling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*qXrrYKHWkVk5T00NlELIxA.png" /><figcaption>How much cooling is needed for different skin tones</figcaption></figure><p>The <strong>most pain</strong> during laser hair removal doesn’t come from the follicle — it comes from <strong>overheating the epidermis</strong>.</p><h3>📍 Why Deep Areas Need More Fluence</h3><p>Areas like the <strong>bikini line and underarms</strong> have:</p><ul><li><strong>Deeper follicles</strong></li><li><strong>Coarser hair</strong></li></ul><p>This means:</p><ul><li>You must use <strong>higher fluence</strong> to ensure the laser reaches deep enough to destroy the hair root and germ cells.</li><li>Lower fluence may only weaken the follicle — not destroy it — leading to <strong>regrowth as finer hair</strong>.</li></ul><p><strong>Bottom Line:</strong><br> Don’t lower fluence to “play it safe”.<br> Choose fluence by hair type, and cooling by skin type.</p><h3>🚫 Common Myth: “Reduce Fluence for Darker Skin”</h3><p>It sounds safe. But it’s incorrect.</p><p><strong>Fluence (energy/cm²)</strong> is chosen based on:</p><ul><li>Depth of the follicle</li><li>Thickness and density of the hair</li></ul><p>When fluence is dropped <strong>just</strong> to protect the skin:</p><ul><li>You risk <strong>not reaching the follicle</strong></li><li>Results are <strong>incomplete</strong></li><li>Hair grows back <strong>finer but persistent</strong></li></ul><blockquote><strong><em>Note:</em></strong><em> Areas like the </em><strong><em>bikini line and underarms</em></strong><em> often require </em><strong><em>higher fluence</em></strong><em> due to deep follicles. Skipping this leads to temporary thinning — not permanent removal.</em></blockquote><h3>❄️ Cooling: The Skin’s Protective Armor</h3><p>Cooling isn’t cosmetic — it’s <strong>critical</strong>.</p><p>Use all tools at your disposal:</p><ul><li>Contact tips</li><li>Cold air sprays</li><li>Chilled gels</li></ul><p>You’re not just reducing pain. You’re preventing <strong>burns</strong>.</p><h3>🧪 Final Tips &amp; Patch Testing</h3><ul><li>Always perform a <strong>patch test</strong>, especially on <strong>darker skin</strong>.</li><li>For very dark skin, <strong>avoid Alexandrite (755 nm)</strong> — it may generate too much heat and cooling may not be enough.</li><li><strong>Cooling is critical</strong> — use cold air, contact cooling tips, or gel.</li><li>Educate your clients: More pigment = more heat, not more hair treated.</li></ul><h3>📌 How to Choose the Right Fluence</h3><h3>1. Identify the Area:</h3><ul><li>Bikini, underarms, chin → Deep follicles → <strong>Higher fluence</strong> needed</li></ul><h3>2. Assess Hair Type:</h3><ul><li>Coarse and dark hair → Absorbs more energy → Responds better</li></ul><h3>3. Choose Wavelength Based on Skin:</h3><ul><li>Light skin → Alexandrite or Diode</li><li>Medium to dark skin → Diode or Nd:YAG</li></ul><h3>4. Never Lower Fluence Just for Skin Tone:</h3><ul><li>Increase <strong>cooling</strong>, not decrease power</li></ul><h3>5. Patch Test for Safety:</h3><ul><li>Especially with new settings, lasers, or darker skin</li></ul><h3>Formula Summary:</h3><ul><li><strong>Deeper &amp; Coarser Hair = Higher Fluence</strong></li><li><strong>Darker Skin = Stronger Cooling + Longer Wavelength</strong></li></ul><h3>Still Confused? Just remember these formulas</h3><h3>📐 Laser Formulas You Should Know</h3><p>These simplified formulas help understand the science behind the settings:</p><ol><li><strong>Heat Generation</strong>:<br> Temperature ∝ Melanin Concentration</li><li><strong>Pain Sensation</strong>:<br> Pain ∝ Temperature in Epidermis</li><li><strong>Laser Absorption by Skin</strong>:<br> Absorption ∝ Melanin × (1 ÷ Wavelength)</li></ol><blockquote>➤ Lower wavelength = Higher melanin absorption<br> ➤ <strong>Alexandrite (755 nm) &gt; Diode (808 nm) &gt; Nd:YAG (1064 nm)</strong></blockquote><p><strong>4. Fluence Selection</strong>:<br> Fluence ∝ Depth of Hair Follicle</p><p><strong>5. Cooling Requirement</strong>:<br> Cooling ∝ Melanin in Skin</p><p><strong>6. Important Rule</strong>:<br> Fluence ≠ f(Skin Color)<br> Fluence = f(Hair Depth &amp; Hair Type)</p><h3>✍️ Conclusion</h3><p>Choosing the right fluence is about understanding <strong>hair</strong>, not skin. But managing <strong>cooling</strong> is all about the <strong>skin</strong>.</p><p>Master these two principles, and you’ll perform <strong>safe</strong>, <strong>effective</strong>, and <strong>pain-managed</strong> laser hair removal on any skin type.</p><h3>🔗 Follow Me</h3><p>If you found this helpful, follow me on Medium and <a href="https://www.instagram.com/getreadywithpurnima/">Instagram</a>, where I share more educational content around <strong>cosmetology</strong>, <strong>skin care</strong>, and <strong>laser aesthetics</strong>.</p><p>Let’s continue spreading knowledge and improving client safety in aesthetic practice!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80aace1b257d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Multiple Laser Hair Removal Sessions Didn’t Work for Me — And What I Learned]]></title>
            <link>https://medium.com/@dhammapurnima/why-multiple-laser-hair-removal-sessions-didnt-work-for-me-and-what-i-learned-c943786a0899?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/c943786a0899</guid>
            <category><![CDATA[laser-hair-reduction]]></category>
            <category><![CDATA[hair-removal-treatment]]></category>
            <category><![CDATA[skin-treatment]]></category>
            <category><![CDATA[laser-hair-removal]]></category>
            <category><![CDATA[medical-aesthetics]]></category>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Mon, 10 Mar 2025 12:34:42 GMT</pubDate>
            <atom:updated>2025-03-10T18:01:20.206Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Why Multiple Laser Hair Removal Sessions Didn’t Work for Me — And What I Learned</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*YOf5YzZ9jfxWKJBZl_09Cw.jpeg" /><figcaption>Laser targets hair in Anagen Phase</figcaption></figure><h3>Laser Targets Hair in the Anagen Phase</h3><p>Despite undergoing more than <strong>15 laser hair removal sessions</strong> on my underarms, I saw <strong>minimal improvement in hair reduction</strong>. Yes, you heard that right. I couldn’t help but wonder — <strong>why wasn’t it working?</strong> Were underarm hairs naturally resistant to laser treatment, or were the practitioners using incorrect settings?</p><p>Frustrated with the lack of results, I visited <strong>two other clinics</strong>, only to realize something shocking — <strong>none of them inquired about my previous sessions or the laser settings that had been used</strong>. Instead, they all started from the lowest energy levels, as if I were a first-time patient. This made me question: <strong>Why are so many clinics hesitant to use the correct energy </strong>settings necessary to effectively target and destroy hair follicles at the root?</p><p>Driven by curiosity and a desire to understand laser technology in depth, I pursued a <strong>Medical Diploma in Aesthetics (Hair and Laser Reduction)</strong> along with other certifications from <strong>IICAD</strong>. Through my studies and hands-on experience, I realized that <strong>laser hair removal is highly effective — but only when performed with the right parameters tailored to the individual’s skin and hair type</strong>. While complete hair removal may not always be possible, <strong>the correct laser settings can significantly reduce hair growth</strong> to the point where only fine, barely noticeable hairs remain.</p><p>This blog is inspired by my personal journey — one filled with <strong>frustration, unanswered questions, and eventually, knowledge</strong> that allowed me to understand what went wrong. My goal is to <strong>educate others on choosing the right aesthetician</strong> and avoiding costly mistakes due to improper treatment settings.</p><p>Now, let’s dive into some of the most <strong>common mistakes</strong> that can hinder laser hair removal results.</p><h3>1. The Science Behind Laser Hair Removal: Understanding Why It Works</h3><p>Laser hair removal (LHR) targets <strong>melanin (pigment) in hair follicles</strong>. The intense heat energy damages the follicle, <strong>preventing future hair growth</strong>. However, laser treatment only works when the hair is in the <strong>Anagen (active growth) phase</strong>.</p><h3>Why?</h3><p>In the <strong>Anagen phase</strong>, the hair is <strong>directly connected to the follicle</strong>, making it vulnerable to laser energy.</p><h4>What Research Says About Hair Growth Cycles &amp; Laser Effectiveness</h4><p>A study published in the <strong>Journal of Dermatological Science (2001)</strong> explains that:</p><p>✔ Only <strong>10–15% of hairs</strong> are in the Anagen phase at a given time. <em>Surprised?</em> 🙂 I was too when I first discovered this during my research!<br> ✔ This is why <strong>multiple sessions (6–12) are required</strong>.<br> ✔ If <strong>sessions aren’t timed correctly</strong>, hair won’t be effectively targeted.</p><p><strong>Clinical Study:</strong> A 2014 study by Nisticò et al. found that patients who <strong>followed incorrect treatment intervals</strong> had a <strong>30–40% reduction in effectiveness</strong>.</p><p><strong>Key Takeaway:</strong> ✔ If your treatments are <strong>not properly spaced</strong>, laser hair removal <strong>won’t work efficiently</strong>. Guess what? Even your hair has a <strong>strict timeline</strong> 😆 — too bad it didn’t send me a <strong>Google Calendar invite!</strong></p><h3>2. Why Your Hair Isn’t Reducing Despite Multiple Sessions</h3><h3>Issue 1: Incorrect Laser Settings — Energy Too Low!</h3><p>If the <strong>fluence (J/cm²) and pulse duration (ms) are too low</strong>, the laser won’t generate enough heat to <strong>destroy the follicle</strong>. Instead, it may only <strong>weaken the hair</strong>, leading to temporary shedding but no long-term reduction.</p><h4>Study on Laser Settings &amp; Hair Reduction</h4><p>A <strong>2018 study in Lasers in Medical Science Journal</strong> compared different laser fluences on <strong>100 patients</strong> over <strong>12 sessions</strong>: ✔ Patients with <strong>higher fluences (20–30 J/cm²)</strong> saw <strong>&gt;85% hair reduction</strong>.</p><p>✔ Patients treated with <strong>lower fluences (&lt;15 J/cm²)</strong> only had <strong>40–50% reduction</strong>.</p><p>✅ <strong>Solution:</strong> If hair is still growing, <strong>ask your technician about the fluence settings!</strong></p><h3>Issue 2: Incorrect Treatment Intervals — Poor Timing Affects Hair Reduction</h3><p>Laser works when the hair is in the <strong>Anagen phase</strong>, but if sessions are scheduled <strong>too early or too late</strong>, effectiveness drops.</p><h4>Research on Hair Growth Cycles &amp; Laser Effectiveness</h4><p>A <strong>2012 study by Gorgu et al. in the Journal of Cosmetic Dermatology</strong> analyzed hair growth cycles and optimal intervals: ✔ <strong>Face:</strong> Every <strong>4–6 weeks</strong> for <strong>80% reduction</strong>.<br> ✔ <strong>Body:</strong> Every <strong>6–8 weeks</strong> for <strong>85% reduction</strong>.<br> ✔ <strong>Legs/Back:</strong> Every <strong>8–10 weeks</strong> for <strong>90% reduction</strong>.</p><p>🚫 <strong>Common Mistakes:</strong></p><p>⛔ <strong>Too Soon</strong> (e.g., every 2 weeks): Hair hasn’t entered <strong>Anagen phase</strong> = <strong>ineffective</strong>.<br> ⛔ <strong>Too Late</strong> (e.g., every 12+ weeks): Hair has regrown, requiring <strong>more treatments</strong>.</p><p>✅ <strong>Solution:</strong> <strong>Ensure correct spacing between sessions!</strong></p><h3>Issue 3: Wrong Laser for Your Skin Type &amp; Hair Type</h3><p>Different skin types need <strong>different wavelengths</strong> for safe and effective treatment.</p><h4>Which Laser Works Best for You?</h4><p><strong>Skin Type</strong> <strong>Best Laser</strong> <strong>Wavelength</strong> Fair Skin (Type 1–2) Alexandrite 755 nm Medium Skin (Type 3–4) Diode 810 nm Dark Skin (Type 5–6) Nd:YAG 1064 nm</p><p>📌 <strong>Solution:</strong> If you’re not seeing results, <strong>check if your aesthetician is using the correct laser for your skin &amp; hair type!</strong></p><h3>Issue 4: Hormonal Imbalances Affecting Hair Growth</h3><p>Some patients <strong>won’t see permanent hair reduction</strong> due to hormonal issues like:</p><p>✔ <strong>PCOS (Polycystic Ovary Syndrome)</strong><br>✔ <strong>Thyroid Disorders (Hypothyroidism, Hyperthyroidism)</strong><br>✔ <strong>Testosterone/Estrogen Imbalances</strong></p><p><strong>Research:</strong> A <strong>2016 study in the Journal of Clinical Endocrinology</strong> found that:</p><p>✔ Women with <strong>PCOS had 35% lower laser effectiveness</strong> than those without it.</p><p>✅ <strong>Solution:</strong> If hair regrowth continues despite proper laser settings, <strong>consider a hormone check-up!</strong></p><h3>3. Final Thoughts — How to Ensure Best Results</h3><p>If you’ve had <strong>10+ laser sessions</strong> with minimal reduction, ask these questions:</p><p>✅ Is the <strong>correct fluence &amp; pulse duration</strong> being used?<br> ✅ Are sessions scheduled at the <strong>right intervals</strong>?<br> ✅ Is the <strong>correct laser</strong> being used for my skin type?<br> ✅ Could a <strong>hormonal condition</strong> be affecting results?</p><p>💡 <strong>Laser hair removal is a science. Small mistakes add up.</strong> Work with a skilled aesthetician who understands the <strong>right approach for each client</strong>.</p><h3>Conclusion: Science-Backed Hair Removal for Better Results</h3><p>If your hair <strong>isn’t reducing despite multiple sessions</strong>, don’t lose hope. <strong>Reassess the settings, timing, and medical factors!</strong></p><p>Have you struggled with laser hair removal results? <strong>Share your experience below!</strong> 😊</p><p>📌 In the next session, I’ll break down <strong>key concepts</strong> like <strong>fluence, pulse duration, frequency, spot size, repetition rate</strong>, and cooling mechanisms — so stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c943786a0899" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a Real-time Chat forum using Strapi, Socket.io, React and MongoDB]]></title>
            <link>https://medium.com/@dhammapurnima/how-to-build-a-real-time-chat-forum-using-strapi-socket-io-react-and-mongodb-b9de5887f024?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9de5887f024</guid>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 11:26:17 GMT</pubDate>
            <atom:updated>2023-10-13T11:28:20.104Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xX2Sb-kzHY8t4xjwIaW0Cw.png" /><figcaption>Strapi</figcaption></figure><p>Chat forums are awesome. They allow you to have discussions in real-time with real people, and over time they’ve started to grow in popularity. Many organizations have even considered having announcements and meaningful discussions entirely in the forum software. It’s no surprise that <a href="https://techcrunch.com/2020/12/01/salesforce-buys-slack/">Salesforce, a CRM platform company, acquired Slack</a> — a very popular instant messaging and forum software — for a whopping $27 billion in 2020, making it the company’s largest acquisition to date!</p><p>And there are several other software out there like <a href="https://discord.com/">Discord</a>, <a href="https://www.discourse.org/">Discourse</a>, and <a href="https://telegram.org/">Telegram</a>, which millions of people worldwide are using.</p><p>A lot goes behind building the software that powers these forums. As a programmer, I’ve always been curious to know what it takes to create one! If you’re like me and wondered about the same thing, this tutorial is for you! In this article, I’ll teach you step-by-step how you can build your very own chat forum software that you and your friends can use!</p><h3>What you will build</h3><p>You’ll build a minimal real-time chat forum software built for the modern browser. It will have the following features:</p><ul><li>Upon visiting your forum page, a user can join a room by entering a username and the room number they wish to join. This data will be saved to our Strapi collections which we’ll create later in the tutorial.</li><li>Upon joining the room, the user will be greeted by a welcome message. They will see a list of other users in the room who are also online and read their ongoing conversation.</li><li>Other users in the room will be notified when a new user joins. That way, they’ll be able to start a conversation.</li><li>Likewise, anytime a user leaves the room, other users get notified as well.</li></ul><p>Here’s how the finished application will look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pKcqc7IFKYe19Rpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YaqkF2LVT6GssIzs.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e1yNoiiRqL4bhxoU.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RGIHUiLazkX3aRVM.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gXFxwOSxX_e8vQv9.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zbhHi1l7TZx5dIOw.png" /></figure><p>I hope you’re excited!</p><h3>Pre-requisites:</h3><p>Some knowledge of the MERN stack (<a href="https://www.mongodb.com/">MongoDB</a>, <a href="https://expressjs.com/">Express</a>, <a href="https://strapi.io/integrations/react-cms">React</a>, and <a href="https://strapi.io/integrations/nodejs-cms">NodeJS</a>) is necessary to follow the tutorial. It’ll also help if you have some understanding of how client-server applications work.</p><p><strong>Local Environment Set Up</strong></p><p>Software, Minimum Version, Recommended Version,</p><p>Node.js, 12.x, 14.x,</p><p>npm, 6.x, 6.x,</p><p>MongoDB, 4.4.x, 4.4.2</p><h3>What you will learn</h3><p>To build the forum, you’ll learn to use the following technologies:</p><ul><li>Strapi: An open-source, NodeJS based content management system. You’ll use this for a lot of technical wirings, such as database-related operations and exposing APIs.</li><li>ReactJS: A component-based library for building user-interfaces</li><li>SocketIO: A NodeJS based library for adding web-sockets support in your app, and enabling real-time communication!</li></ul><p><strong>Let’s begin!</strong></p><h4>Strapi</h4><p>Here’s the introduction to Strapi, from the official docs:</p><p>“Strapi is an open-source, Node. js-based, headless CMS to manage content and make it available through a fully customizable API. It is designed to build practical, production-ready Node.js APIs in hours instead of weeks.”</p><h4>What is a Headless CMS?</h4><p>If you are a software developer, it’s most likely that you must have heard of Content Management Systems or CMS in short. They enable you to quickly create and save content for the web, such as text, images, and videos. You’ll be able to add context-based information, publish, and edit — all in one single place. One of the most popular CMS is <a href="https://strapi.io/wordpress-alternative">WordPress</a>, an open-source platform that powers over <strong>60 million websites</strong> using the PHP programming language.</p><p>WordPress has existed since 2003 and is a traditional CMS. It couples your rendering, and data layer together as a single system. But as web apps evolved over the years, organizations started to look for CMSes that provide more flexibility to create applications. As more robust frameworks like NodeJS and React came in, there is a real need for CMSes to start supporting app development using these frameworks. That is precisely what a <strong>Headless CMS </strong>like Strapi allows you to do! Similar to a traditional CMS, a headless CMS provides you with an editor interface to author content, but with a few crucial differences -</p><ul><li>Majorly, headless CMSes also allow you the freedom to choose your own technology such as React, Angular, or VueJS to create the front-end user interface for your app. So as a developer, you have much more control!</li><li>Once the content is ready, you can build applications that can access this content over APIs provided by the CMS platform. RESTAPIs are pretty convenient for most commonly used CRUD operations.</li></ul><p>Feel free to download the <a href="https://strapi.io/headless-cms-guide">Headless Guide</a> made by the Strapi team.</p><p>What Strapi Offers</p><ol><li>Strapi provides you with an editor interface to quickly write your own content</li><li>The content can be consumed via RESTAPIs or GraphQL endpoints. Yes, strapi supports GraphQL as well!</li><li>It also supports the most commonly used databases out-of-the-box, such as <strong>SQLite, PostgresSQL, MySQL, MariaDB, MongoDB</strong>.</li><li>And lastly, it has very active and thriving community support! Strapi is one of the most popular open-source CMS projects on <a href="https://github.com/strapi/strapi">Github</a> — more than <strong>32,000 stars</strong>!</li></ol><h4>How does Strapi work?</h4><p>You can create data-models/collections for your application using the Strapi admin client. By default, the database that Strapi uses underneath for storing your data models is SQLite.</p><p>If you’ve programmed in NodeJS and Express before, you most likely have written your own REST APIs using app.get, app.post and others. You likely have created data models in MongoDB and connected them to your Express App in your code.</p><p>With Strapi, however, you can create data models from the Strapi Admin panel itself! Once you’re done, it automatically creates the most commonly used REST APIs endpoints that can read and write to your database models! I’ll try to illustrate this with an example:</p><p>If you create a collection in MongoDB called users from your Strapi Admin Panel, it automatically adds the following endpoints that read and write to this collection.</p><pre>To Fetch all the users<br><br>GET http://localhost:1337/users<br><br><br>To Create a new user<br><br>POST http://localhost:1337/users<br><br>{<br>  &quot;id&quot;: 1,<br>  &quot;name&quot;: &quot;Purnima&quot;,<br>  &quot;lastname&quot;: &quot;Gupta&quot;,<br>  &quot;country&quot;: &quot;India&quot;<br>}</pre><p>You can find more examples from the Strapi documentation <a href="https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html">here.</a></p><h4>Where does the data get stored?</h4><p>Whenever you save any data to your collections, It’s saved to your database which you selected while installing Strapi. For this tutorial, you’ll use MongoDB.</p><p>Login to your mongo shell by running the command mongo in your terminal. Next,</p><p>To see a list of databases:</p><pre>&gt; show dbs<br><br>chat-backend-with-strapi 0.001GB<br>config                    0.000GB<br>local                     0.000GB</pre><p>My database name is chat-backend-with-strapi. This is where all your collections will be created and data will be stored.</p><p><strong>To switch to a database</strong></p><pre><br>use chat-backend-with-strapi</pre><p><strong>To see all the collections</strong></p><pre><br>show collections<br><br>core_store<br>messages<br>strapi_administrator<br>strapi_permission<br>strapi_role<br>strapi_webhooks<br>upload_file<br>users<br>users-permissions_permission<br>users-permissions_role<br>users-permissions_user</pre><p>To see the data inside users collections.</p><pre>&gt; db.users.find({}).pretty()<br>{<br>        &quot;_id&quot; : ObjectId(&quot;5fdc68360d3bbc1b86e5c14b&quot;),<br>        &quot;username&quot; : &quot;purnima&quot;,<br>        &quot;room&quot; : &quot;11&quot;,<br>        &quot;status&quot; : &quot;ONLINE&quot;,<br>        &quot;socketId&quot; : &quot;RyqPsKoBe09h2g-UAAAV&quot;,<br>        &quot;published_at&quot; : ISODate(&quot;2020-12-18T08:28:38.565Z&quot;),<br>        &quot;createdAt&quot; : ISODate(&quot;2020-12-18T08:28:38.572Z&quot;),<br>        &quot;updatedAt&quot; : ISODate(&quot;2020-12-18T08:28:38.572Z&quot;),<br>        &quot;__v&quot; : 0<br>}</pre><p>Now, since you are building a chat application, you’ll use a Socket.IO, a NodeJS library that adds web-sockets support to your app!</p><p><strong>What are web sockets and how are they different from HTTP?</strong></p><p>In a traditional HTTP request, the client first initiates a request in the form of a GET, POST, PUT, or DELETE method. This establishes a connection, and once the server fulfills the request, the connection gets closed. The server can never initiate and push information to a client on its own — it can only serve requests that originate from a client.</p><p>For a chat application, you’ll need to provide the server with the ability to push information out to a client. Let’s examine why, with an example:</p><p>If two users John and Jane are chatting with each other, this is how the flow of data might look like:</p><ol><li>User John writes a message “hello” and hits <em>send.</em> This message is sent to the server. along with the details of the sender and the intended recipient</li><li>Once the server receives the message data, and in turn, broadcasts it to the intended recipient (to the user Jane)</li><li>User Jane receives the message “hello”.</li></ol><p>For this to work, both clients must maintain a <strong>persistent connection</strong> with the server. OR in other words, the connection is kept open even when the request has been fulfilled by the server and later server can notify/send messages to other open connections(clients/browsers) <strong>without</strong> making them explicitly request that information.</p><p>Here are a couple of <a href="https://ably.com/topic/socketio">excellent</a> <a href="https://blog.booleanhunter.com/how-to-build-your-own-uber-for-x-app-part-2/#why-do-you-need-web-sockets-and-how-do-they-work">articles</a> that describe web-sockets in more detail.</p><p><strong>Now that you have a brief understanding of what web sockets are, it’s time to start building the application.</strong></p><h3>Backend set-up</h3><h3>#1: Install Strapi</h3><p>You can either use yarn or npx to create your Strapi project.</p><p>Install using npx package: To quickly install strapi, run the following command.</p><pre><br>npx create-strapi-app strapi-socket-backend</pre><p>Install using yarn package:</p><pre><br>yarn create strapi-app my-project --quickstart</pre><p>Once you run this command, it will ask you to choose your database. Select “MongoDB” as your database and for every other field, we’re gonna keep the default values so leave all the fields blank.</p><pre><br>? Choose your installation type Custom (manual settings)<br>? Choose your default database client mongo<br>? Database name: strapi-socket-backend<br>? Host: 127.0.0.1<br>? +srv connection: false<br>? Port (It will be ignored if you enable +srv): 27017<br>? Username: <br>? Password: <br>? Authentication database (Maybe &quot;admin&quot; or blank): <br>? Enable SSL connection: No</pre><p>Once it’s done, cd into your strapi-socket-backend directory, which by default will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/0*9BfiEJdz2qM0eYow.png" /></figure><p>Each directory has a <a href="https://docs.strapi.io/developer-docs/latest/plugins/plugins-intro.html#file-structure">special purpose</a> that Strapi utilizes internally. You don’t need to know all of them, but for this tutorial, you’ll mainly use the /config/functions/bootstrap.js file. It allows you to execute any logic that you want to run immediately after starting the strapi server.</p><h3>#2: Start and test the Strapi Server</h3><p>You can now start Strapi server by running:</p><pre>npm run develop <br><br>OR<br><br>yarn run develop</pre><p>It might take a couple of seconds to build your admin UI panel. Once you run the command, it will automatically open the admin registration page like the one below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L-fm50ML_mFPwdbZ.png" /></figure><p>After creating your admin account, you will see this admin panel where you would create the collections later that are needed for this tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iUVE3kXvTwF3268Q.png" /></figure><h3>#3: Install and configure SocketIO</h3><p>Run npm i socket.io. Once it’s finished installation, you’ll need to integrate it with your strapi server. Go to the file /config/functions/bootstrap.js and write the following code:</p><pre><br>module.exports = () =&gt; {<br>    var io = require(&#39;socket.io&#39;)(strapi.server, {<br>        cors: {<br>          origin: &quot;http://localhost:3000&quot;,<br>          methods: [&quot;GET&quot;, &quot;POST&quot;],<br>          allowedHeaders: [&quot;my-custom-header&quot;],<br>          credentials: true<br>        }<br>    });<br>    io.on(&#39;connection&#39;, function(socket) {<br>          socket.on(&#39;join&#39;, ({ username, room }) =&gt; {<br>              console.log(&quot;user connected&quot;);<br>              console.log(&quot;username is &quot;, username);<br>              console.log(&quot;room is...&quot;, room)<br>          })<br>      });<br> };</pre><p>Your frontend and backend servers are running on different ports — the frontend server on port 3000, and the backend Strapi server on Port 1337. Hence, we need to configure a cors policy for our application. The origin option is used to determine what URLs are allowed to send requests to your backend. By providing our frontend server URL, we’re telling socket.io to allow the incoming request from this URL.</p><h3>Frontend</h3><p>For the client-side of your app, you’ll use <a href="https://reactjs.org/docs/create-a-new-react-app.html#create-react-app">create-react-app</a> to bootstrap your project. Head over to <a href="https://github.com/strapi-blog/strapi-blog-ui-starter">this github link</a>, clone the repository, and run npm install to install all the front-end related dependencies. This will scaffold a front-end project will all the necessary React files that you’ll use to build the application.</p><p>Here are some of the major npm modules that you’ll use:</p><ul><li>react</li><li>react-router-dom</li><li>antd</li><li>styled-components</li><li>socket.io-client</li></ul><p>Some of the components have already been defined for you so that you may focus more on the logic and less on the styles for the project.</p><h3>#1: Add socket.io support</h3><p>Go to your root folder strapi-chat-ui and create a new folder named config. Next, add a new file called web-sockets.js inside this folder:</p><pre>import io from &#39;socket.io-client&#39;;<br>let STRAPI_ENDPOINT;<br><br>if (process.env.NODE_ENV !== &#39;production&#39;) {<br>    STRAPI_ENDPOINT = &#39;http://localhost:1337&#39;;<br>} else {<br>    STRAPI_ENDPOINT = process.env.REACT_APP_SERVER_URL<br>}<br><br>export const socket = io(STRAPI_ENDPOINT);</pre><h3>App UI Routing logic:</h3><ol><li>Upon loading the application in the browser, you will render a JoinRoom component at the route <a href="http://localhost:3000/join">http://localhost:3000/join</a>. In this screen, the user shall enter their username and a room number to join. Say if they entered room number 10, the app will redirect to the URL <a href="http://localhost:3000/chat/rooms/10">http://localhost:3000/chat/rooms/10</a>.</li><li>At <a href="http://localhost:3000/chat/rooms/10">http://localhost:3000/chat/rooms/10</a>, you’ll render a ChatRoom component. This will be the chat screen itself, that displays other online users and the ongoing conversation.</li></ol><p>Hopefully, this all makes sense. Next, you’ll set up the routes for rendering these components.</p><h3>#2: Set-up component routes</h3><p>For this, you’ll make use of react-router-dom and the history modules. Create a file /src/config/network.js and write the following code snippet. We’re exporting history object which our React Router would need.</p><pre><br>import { createBrowserHistory } from &#39;history&#39;<br>export const history = createBrowserHistory();</pre><p>This sets up a history object and exports it. You’ll import it at the entry point of your application. Paste the following inside the src/index.js file:</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br>import &#39;antd/dist/antd.css&#39;;<br>import &#39;font-awesome/css/font-awesome.min.css&#39;;<br>import reportWebVitals from &#39;./reportWebVitals&#39;;<br>import {<br>  Router,<br>  Route,<br>} from &#39;react-router-dom&#39;;<br><br>import App from &#39;./App&#39;;<br>import { history } from &#39;./config/network&#39;;<br><br>const router = (<br>  &lt;Router history={history}&gt;<br>      &lt;Route component={App}/&gt;<br>  &lt;/Router&gt;<br>)<br>ReactDOM.render(<br>  &lt;React.StrictMode&gt;<br>      {router}<br>  &lt;/React.StrictMode&gt;,<br>  document.getElementById(&#39;root&#39;)<br>);</pre><p>Next, you’ll set-up the routes for the JoinRoom and ChatRoom components inside your main App.js component:</p><pre><br><br>import React, { useState } from &#39;react&#39;;<br>import {<br>    Route,<br>    Switch,<br>    Redirect<br>} from &quot;react-router-dom&quot;;<br>import JoinRoom from &#39;./screens/JoinRoom&#39;;<br>import ChatRoom from &#39;./screens/ChatRoom&#39;;<br><br>import { history } from &#39;./config/network&#39;;<br><br>function App() {<br>    const [username, setUsername] = useState(&#39;&#39;);<br>    const [room, setRoom] = useState(&#39;&#39;);<br>    const [joinData, setJoinData] = useState({});<br><br>    function onJoinSuccess(data) {<br>        setJoinData(data);<br>        setUsername(data.userData.username);<br>        setRoom(data.userData.room);<br>        history.push(`/chat/rooms/${data.userData.room}`);<br>    }<br>    return (<br>        &lt;div className=&quot;App&quot;&gt;<br>             &lt;Switch&gt;<br>                &lt;Route <br>                    path=&quot;/join&quot; <br>                    component={() =&gt; &lt;JoinRoom onJoinSuccess={onJoinSuccess}/&gt;}<br>                /&gt;<br>                &lt;Redirect <br>                    from=&quot;/&quot; <br>                    to=&quot;/join&quot; <br>                    exact <br>                /&gt;<br>                &lt;Route <br>                    path=&quot;/chat/rooms/:roomNumber&quot; <br>                    component={() =&gt; <br>                        &lt;ChatRoom <br>                            username={username} <br>                            room={room} <br>                            joinData={joinData}<br>                        /&gt; <br>                    } <br>                /&gt;<br>            &lt;/Switch&gt;<br>        &lt;/div&gt;<br>    );<br>}<br>export default App;</pre><p>This tells the App component to load the JoinRoom component when a user is in the route /join, and to render the ChatRoom the component in the route <strong>/chat/rooms/:roomNumber</strong>.</p><h3>#3: Create a component that allows a user to join a chat room</h3><p>Now, you’ll create the JoinRoom component UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/0*G3E8TVcwybUmJYKs.png" /></figure><p>Create a file JoinRoom.js inside<strong> /src/screens</strong> directory and add the following code:</p><pre><br>import React, { useState } from &quot;react&quot;;<br>import styled from &#39;styled-components&#39;;<br>import { Input, Card, Button } from &#39;antd&#39;;<br>import { socket } from &#39;../config/web-sockets&#39;;<br>function JoinRoom(props) {<br>    const [username, setUsername] = useState(&#39;&#39;);<br>    const [room, setRoom] = useState(&#39;&#39;);<br>    const [error, setError] = useState(&#39;&#39;);<br>    const onUsernameChange = (e) =&gt; {<br>        const inputValue = e.target.value;<br>        setUsername(inputValue);<br><br>    }<br>    const onRoomChange = (e) =&gt; {<br>        const roomNo = e.target.value;<br>        setRoom(roomNo);<br>    }<br>    const onClick = () =&gt; {<br>        if(username &amp;&amp; room) {<br>            socket.emit(&#39;join&#39;, { username, room }, (error) =&gt; {<br>                if(error) {<br>                    setError(error)<br>                    alert(error);<br>                } else {<br>                    socket.on(&#39;welcome&#39;, (data) =&gt; {<br>                        props.onJoinSuccess(data);<br>                    });<br>                }<br>            }); <br>        }<br>    }<br>    socket.on(&#39;welcome&#39;, (data) =&gt; {<br>        console.log(&quot;Welcome event inside JoinRoom&quot;, data);<br>        props.onJoinSuccess(data);<br>    });<br>    return (<br>        &lt;StyledCard&gt;<br>            &lt;label htmlFor=&quot;username&quot;&gt;<br>                Enter your name<br>                &lt;Input<br>                    name=&quot;username&quot;<br>                    placeholder=&quot;Enter your username&quot;<br>                    maxLength={25}<br>                    value={username}<br>                    onChange={onUsernameChange}<br>                /&gt;<br>            &lt;/label&gt;<br>            &lt;label htmlFor=&quot;room&quot;&gt;<br>                Enter room number of your choice<br>                &lt;Input<br>                    name=&quot;room&quot;<br>                    placeholder=&quot;Enter your room number&quot;<br>                    maxLength={25}<br>                    value={room}<br>                    onChange={onRoomChange}<br>                /&gt;<br>            &lt;/label&gt;<br>            &lt;StyledButton <br>                type=&quot;primary&quot; <br>                size={&quot;large&quot;}<br>                onClick={onClick}<br>            &gt;<br>                Join the Chat Room<br>            &lt;/StyledButton&gt;<br>        &lt;/StyledCard&gt;<br>    )<br>};<br><br>export default JoinRoom;<br><br>const StyledCard = styled(Card)`<br>    width: 581px;<br>    height: 210px;<br>    margin: 30vh auto;<br>    box-shadow: 2px 3px 3px 2.8px #d7d7e4;<br>    text-align: center;<br>`<br>const StyledButton = styled(Button)`<br>    margin-top: 10px;<br>`</pre><p>Run the server using npm start</p><p><strong>Here’s how the UI logic works:</strong></p><ol><li>You save the username and room information to the React state using the onChange event.</li><li>When someone clicks on the “join the chat room” button, you’ll then use socket to emit a join event to your Strapi server.</li><li>First, we need username and room the number for our chat forum so that we can send a “greeting message” to the user in that particular room.</li></ol><p>Let’s test this out!</p><h3>#4: Run the Servers</h3><p>Run your backend and frontend servers, and head over to your browser at <a href="http://localhost:3000/join"><strong>http://localhost:3000/join</strong></a>. This will render the JoinRoom component - an Antd Card with two input boxes and a button, as shown in the screenshot earlier. On this UI enter your username and room number and click on the “join” button. You should see something like this on your Strapi terminal:</p><pre>.....<br>To access the server ⚡️, go to:<br>http://localhost:1337<br><br>user connected<br>username is  purnima<br>room is... 11</pre><p>Great! Now our frontend and backend are listening to each other.</p><h3>Creating data-models using the Strapi Admin Interface</h3><p>Let’s go to the admin panel<strong> </strong><a href="http://localhost:1337/admin/"><strong>http://localhost:1337/admin/</strong></a><strong>.</strong> You will see this page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4U3oNSVgFhqtkkPz.png" /></figure><p>For starters, you’ll just create a single collection where you can store users.</p><p>Click on <em>CREATE YOUR FIRST CONTENT-TYPE</em> button to create our first <em>users</em> collection. Give it a name users and click <em>next</em>. You’ll be asked to add a field for this collection and define its data-type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/0*0yXnJLOLsQOmV3zk.png" /></figure><p>Let’s create 4 fields for the users collection:</p><ol><li>username - text</li><li>status - text</li><li>room - text</li><li>socketid - number</li></ol><p>Once you’re done adding these fields, click on <em>S</em>AVE<em>.</em> Your collection will have four fields now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0DGyfAaExGfD35Jx.png" /></figure><h3>Fetching data from Strapi APIs</h3><p>Once you’ve added a collection, Strapi automatically creates the most commonly used REST APIs endpoints that read and write to your database models. So what happens if you type<strong> </strong><a href="http://localhost:1337/users"><strong>http://localhost:1337/users</strong></a><strong> </strong>in your browser?</p><p>You will see that this request is “forbidden” with the status “403”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/0*WfebIYfTHWe3jjUR.png" /></figure><p>This is a security feature from Strapi. In order to expose the GET /users endpoint, you’ll have to modify permissions for the users collection.</p><ol><li>Go to <em>Settings</em> on the left-hand side</li><li>Click on <em>Roles</em> under <em>USERS &amp; PERMISSIONS PLUGIN</em></li><li>Select all the permissions</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/0*VbJ_5EPs8ZlxqZqM.png" /></figure><p>This will expose the APIs for the users collection. Now try going to <a href="http://localhost:1337/users">http://localhost:1337/users</a> once again. This time, you should see a JSON response returned. It’ll be an empty array since you haven’t added any data yet!</p><p>Let’s begin with the first set of features:</p><h3>Feature #1: Enable a user to join a room</h3><p>Here’s what you’ll do in order to make this work:</p><ol><li>Once the user clicks on “join” after entering their details, the front-end emits a socket event to the backend server with the username and room details.</li><li>The backend server, upon receiving the socket event, checks if the username already exists in your MongoDB users collection. If it doesn’t, you’ll add a new entry in the users collection, or you’ll throw an error.</li><li>Upon adding a new entry, you’ll send a success response to the front-end. The front-end will then join the room using SocketIO’s join api.</li><li>Once the user has landed into the chat-room, you’ll use SocketIO to emit a welcome event.</li><li>Once again, the backend-server upon receiving the welcome event, will broadcast to all other connected clients in the same room informing them that a new user has joined the chat.</li></ol><p>Next, let’s write some code to create a new user in the database. We will also send “welcome message” when the user joins the chat and notify others “user has joined”.</p><h3>Backend</h3><p>You’ll create a file called database.js inside /config/functions/utils. In this file, you’ll have two functions:</p><ol><li>findUser()- To check if the user exists in the database or not.</li><li>createUser() - To create a new user entry in our database. Once the new user has been created, it’ll appear in the users collection in your Strapi admin panel.</li></ol><p>Database.js File</p><pre><br>async function findUser(username, room) {<br>    try {<br>        const userExists = await strapi.services.users.find({ username, room });<br>        return userExists;<br>    } catch(err) {<br>        console.log(&quot;error while fetching&quot;, err);<br>    }<br>}<br>async function createUser({ username, room, status, socketId }) {<br>    try {<br>        const user = await strapi.services.users.create({<br>            username,<br>            room,<br>            status: status,<br>            socketId<br>        });<br>        return user;<br>    } catch(err) {<br>        console.log(&quot;User couldn&#39;t be created. Try again!&quot;)<br>    }<br>}<br>module.exports = {<br>    findUser,<br>    createUser<br>}</pre><p>Next, you’ll import the above functions within /config/functions/bootstrap.js file. Modify the file with the following code:</p><p><strong>bootstrap.js</strong></p><pre>&#39;use strict&#39;;<br>const {<br>    findUser, <br>    createUser<br>} = require(&#39;./utils/database&#39;);<br><br>module.exports = () =&gt; {<br>    var io = require(&#39;socket.io&#39;)(strapi.server, {<br>        cors: {<br>          origin: &quot;http://localhost:3000&quot;,<br>          methods: [&quot;GET&quot;, &quot;POST&quot;],<br>          allowedHeaders: [&quot;my-custom-header&quot;],<br>          credentials: true<br>        }<br>    });<br>    io.on(&#39;connection&#39;, function(socket) {<br>        socket.on(&#39;join&#39;, async({ username, room }, callback) =&gt; {<br>            try {<br>                const userExists = await findUser(username, room);<br><br>                if(userExists.length &gt; 0) {<br>                    callback(`User ${username} already exists in room no${room}. Please select a different name or room`);<br>                } else {<br>                    const user = await createUser({<br>                        username: username,<br>                        room: room,<br>                        status: &quot;ONLINE&quot;,<br>                        socketId: socket.id<br>                    });<br><br>                    if(user) {<br>                        socket.join(user.room);<br>                        socket.emit(&#39;welcome&#39;, {<br>                            user: &#39;bot&#39;,<br>                            text: `${user.username}, Welcome to room ${user.room}.`,<br>                            userData: user<br>                        }); <br>                        socket.broadcast.to(user.room).emit(&#39;message&#39;, {<br>                            user: &#39;bot&#39;,<br>                            text: `${user.username} has joined`,<br>                        });<br><br>                    } else {<br>                        callback(`user could not be created. Try again!`)<br>                    }<br>                }<br>                callback();<br>            } catch(err) {<br>                console.log(&quot;Err occured, Try again!&quot;, err);<br>            }<br>        })<br>    });<br>};</pre><pre><em>Note: When user refreshes the page, socket’s disconnect event gets fired. Keep that in mind for now. We’ll discuss it more later. One more bit that we need to keep in mind is that whenever you restart the backend server, your previous socket connection will be lost. And if you try to send messages after restarting your server, your messages will not be sent since there’s no socket connection is established. This is why we need to ask the user to log in again for this tutorial.</em></pre><h3>Frontend</h3><p>Next, you’ll build the ChatRoom component. The ChatRoom page consists of the following components:</p><ul><li>A Header the component that displays the Room number, a green icon that indicates you’re online, and a close icon that will log-out the user upon clicking it.</li><li>A List component on the left that displays a list of other users who are also currently present in the room</li><li>A Messages the component that displays the conversations between the users.</li><li>An Input component to type in a message</li><li>A Send button.</li></ul><p>Let’s first display messages. You’ll write the core logic for this inside <strong>/src/screens/ChatRoom.js</strong>. Some of the components have already been defined and imported for you to use so that you may focus more on the logic and less on the presentation.</p><p><strong>ChatRoom/index.js</strong></p><pre><br>import React, { useEffect, useState } from &#39;react&#39;;<br>import styled from &#39;styled-components&#39;;<br>import { socket } from &#39;../config/web-sockets&#39;;<br>import Header from &#39;../components/Header&#39;;<br>import Messages from &#39;../components/Messages&#39;;<br>import { history } from &#39;../config/network&#39;;<br>import {<br>  ChatContainer,<br>  StyledContainer,<br>  ChatBox,<br>  StyledButton,<br>  SendIcon<br>} from &#39;./styles&#39;;<br><br>function ChatRoom(props) {<br>    const {username, room, joinData } = props;<br>    const [messages, setMessages] = useState([]);<br>    const [users, setUsers] = useState([]);<br><br>    useEffect(() =&gt; {<br>        if( Object.keys(joinData).length &gt; 0) {<br>            setMessages([joinData])    <br>            socket.on(&#39;message&#39;, (message, error) =&gt; {<br>                setMessages(msgs =&gt; [ ...msgs, message ]);<br>            });<br>        } <br>        else {<br>            history.push(&#39;/join&#39;)<br>        }<br>     }, [joinData])<br><br>       return (<br>        &lt;ChatContainer&gt;<br>            &lt;Header room={room} /&gt;<br>            &lt;StyledContainer&gt;<br>                &lt;ChatBox&gt;<br>                    &lt;Messages <br>                        messages={messages} <br>                        username={username}<br>                    /&gt;<br>                &lt;/ChatBox&gt;      <br>            &lt;/StyledContainer&gt;<br>        &lt;/ChatContainer&gt;<br>    )<br>};<br>export default ChatRoom;</pre><p>Next, you’ll write the logic to render each individual message in the UI inside the Messages component. You’ll iterate over the messages array and display the message along with the user who sent it:</p><p><strong>Messages/index.js</strong></p><pre><br>import React from &#39;react&#39;;<br>import ScrollToBottom from &#39;react-scroll-to-bottom&#39;<br>import Message from &#39;./Message&#39;;<br>import styled from &#39;styled-components&#39;;<br><br>function Messages(props) {<br>    const { messages, username } = props;<br>    return (<br>        &lt;StyledMessages&gt;<br>            &lt;ScrollToBottom&gt;<br>                {<br>                    messages.map((message, i) =&gt; <br>                        &lt;div key={i}&gt;<br>                            &lt;Message <br>                                message={message} <br>                                username={username}<br>                            /&gt;<br>                        &lt;/div&gt;<br>                    )<br>                }<br>            &lt;/ScrollToBottom&gt;<br>        &lt;/StyledMessages&gt;<br>    );<br>}<br>export default Messages;<br>const StyledMessages = styled.div`<br>    padding: 5% 0;<br>    overflow: auto;<br>    flex: auto;<br>`</pre><p>Now try opening two different tabs on your browser at <a href="http://localhost:3000/join"><strong>http://localhost:3000/join</strong></a><strong>. </strong>Enter 2 different usernames on each of those tabs on the Join page, (with a common room number). You should then see this displayed on your screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xJZ_FsQPCXUnJtEG.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hLvN34USCKk40hcm.png" /></figure><h3>Feature #2: Conversations</h3><p>Here’s what you’ll do in order to make this work:</p><ol><li>On the ChatRoom page, once the user types a message and hits <em>SEND,</em> you’ll emit an sendMessage event using SocketIO along with the user’s ID and the message.</li><li>On the backend, the server listens for an sendMessage event. When it receives one, it’ll check if the user exists in the collection.</li><li>If the user exists, then it broadcasts the message to the room that the user belongs to. Else, it throws an error message.</li></ol><p>Sounds straightforward right?</p><h3>Backend</h3><ul><li>See if the user already exists in our database:</li></ul><p>Begin by first writing the function that checks for the user based on their ID. On your backend code, open database.js and add a userExists method and export it:</p><p>database.js</p><pre><br>async function userExists(id) {<br>    try {<br>        const user = strapi.services.users.findOne({ id: id });<br>        return user;<br>    } catch(err) {<br>        console.log(&quot;Error occured when fetching user&quot;, err);<br>    }<br>}<br><br>module.exports = {<br>    findUser,<br>    createUser,<br>    userExists,<br>}</pre><ul><li>Listening for “sendMessage” Event</li></ul><p>Next, you’ll import this method within the bootstrap.js file. You’ll then write the logic to listen for any sendMessage events:</p><pre><br>io.on(&#39;connection&#39;, function(socket) {<br>  ......<br>  ......<br>socket.on(&#39;sendMessage&#39;, async(data, callback) =&gt; {<br>            try {<br>                const user = await userExists(data.userId);<br>                if(user) {<br>                    io.to(user.room).emit(&#39;message&#39;, {<br>                        user: user.username,<br>                        text: data.message,<br>                    });<br>                } else {<br>                    callback(`User doesn&#39;t exist in the database. Rejoin the chat`)<br>                }<br>                callback();<br>            } catch(err) {<br>                console.log(&quot;err inside catch block&quot;, err);<br>            }<br>  });<br>})</pre><p>The “sendMessage” event will be emitted when the user clicks on the send button inside the ChatBox Page.</p><h3>Frontend</h3><ul><li>Adding Input and Send button:</li></ul><p>On the UI, you’ll add an Input component and a <em>Send</em> button. Add the following code inside the ChatRoom component, right after the Messages component:</p><pre><br>&lt;Input<br>  type=&quot;text&quot;<br>  placeholder=&quot;Type your message&quot;<br>  value={message}<br>  onChange={handleChange}<br>/&gt;<br>&lt;StyleButton<br>  onClick={handleClick}<br>&gt;<br>  &lt;SendIcon&gt;<br>    &lt;i className=&quot;fa fa-paper-plane&quot; /&gt;<br>  &lt;SendIcon&gt;<br>&lt;StyledButton&gt;</pre><ul><li>Save message and add logic when someone clicks on a “Send” button:</li></ul><p>Next, you’ll add the handleChange function and the handleClick function that will in-turn call a method sendMessage. Add the following right after useEffect:</p><pre><br>const handleChange = (e) =&gt; {<br>  setMessage(e.target.value);<br>}<br><br>const handleClick = (e) =&gt; {<br>  sendMessage(message);<br>}<br> const sendMessage = (message) =&gt; {<br>        if(message) {<br>            socket.emit(&#39;sendMessage&#39;,{ userId: joinData.userData.id, message }, (error) =&gt; {<br>                if(error) {<br>                    alert(error)<br>                    history.push(&#39;/join&#39;);<br>                }<br>            });<br>            setMessage(&#39;&#39;)<br>        } else {<br>            alert(&quot;Message can&#39;t be empty&quot;)<br>        }<br>}</pre><p>You should now be able to send and receive messages between 2 different users on the Tabs that you opened earlier!</p><p>Moving on to the final feature -</p><h3>Feature #3: Show which users are online</h3><p>Here’s the flow:</p><ol><li>In the backend, when a new user joins a room, you’ll fetch a list of users belonging to the room from the users collection. Then, you’ll use SocketIO to broadcast a roomInfo event to all the users within that room, and send all the users info.</li><li>On the UI, your ChatRoom component will listen for roomInfo event, and once it receives the user list, you’ll save it in the state and display them using a List component.</li></ol><h3>Backend</h3><ul><li>Get all the users in a particular room:</li></ul><p>Add a method getUsersInRoom that returns a list of users for a given room:</p><pre><br>async function getUsersInRoom(room) {<br>    try {<br>        const usersInRoom = await strapi.services.users.find({ room })<br>        return usersInRoom;<br>    } catch(err) {<br>        console.log(&quot;Error.Try again!&quot;, err);<br>    }<br>}<br><br>module.exports = {<br>    findUser,<br>    createUser,<br>    userExists,<br>    getUsersInRoom,<br>}</pre><ul><li>Sending users&#39; data in a particular room</li></ul><p>Next, you’ll import this method inside bootstrap.js. Add the following right after the part where you broadcast the message event:</p><pre><br>io.to(user.room).emit(&#39;roomInfo&#39;, {<br>    room: user.room,<br>    users: await getUsersInRoom(user.room)<br>});</pre><h3>Frontend</h3><ul><li>Emitting “roomInfo” event when the component mounts:</li></ul><p>This will get us all the existing users in the room as soon as page loads.</p><p>Add the following code inside your ChatRoom component, right inside the useEffect method:</p><pre><br>socket.on(&quot;roomInfo&quot;, (users) =&gt; {<br>    setUsers(users);<br>});</pre><p>This adds to the list of users in the users state upon receiving the roomInfo event. Now you just need to display them. Add the following code, right before ChatBox:</p><p>&lt;List users={users.users}/&gt;</p><p>And that’s it! We just have one final thing to do:</p><h3>Feature #4: Notify users if someone leaves the chat room</h3><h3>Backend</h3><p>SocketIO has an inbuilt disconnect event that gets called automatically when someone leaves the room, or if they close their browser window or refresh the page. You’ll use the user’s socketId to delete the user from the database, and then notify all the other users in the room that the user has left the chat!</p><p>Add a method deleteUser that removes a user using their socketId:</p><p>database.js</p><pre><br>async function deleteUser(socketId) {<br>    try {<br>        const user = await strapi.services.users.delete({ socketId: socketId });<br>        return user;<br>    } catch(err) {<br>        console.log(&quot;Error while deleting the User&quot;, err);<br>    }<br>}<br>module.exports = {<br>    findUser,<br>    createUser,<br>    userExists,<br>    getUsersInRoom,<br>    deleteUser<br>}</pre><p>Next, import this method in bootstrap.js file and add the following:</p><pre><br>io.on(&#39;connection&#39;, function(socket) { <br>  // earlier code ...<br>  // ...<br>  socket.on(&#39;disconnect&#39;, async(data) =&gt; {<br>            try {<br>                console.log(&quot;DISCONNECTED!!!!!!!!!!!!&quot;);<br>                const user = await deleteUser( socket.id);<br>                console.log(&quot;deleted user is&quot;, user)<br>                if(user.length &gt; 0) {<br>                    io.to(user[0].room).emit(&#39;message&#39;, {<br>                        user: user[0].username,<br>                        text: `User ${user[0].username} has left the chat.`,<br>                    });  <br>                    io.to(user.room).emit(&#39;roomInfo&#39;, {<br>                        room: user.room,<br>                        users: await getUsersInRoom(user[0].room)<br>                    });<br>                }<br>            } catch(err) {<br>                console.log(&quot;error while disconnecting&quot;, err);<br>            }<br>    });<br>}</pre><h3>And we’re done. Watch your app in <a href="https://strapi-chat.purnimagupta.com/">action!</a></h3><p>I hope this tutorial helped you understand how you can integrate and use Strapi in your own application.</p><h3>Next Steps</h3><p>What if a new user wanted to see ongoing conversations in a room as soon as they joined?</p><blockquote><em>Hint: We aren’t storing really saving user messages in the database!</em></blockquote><p>I leave this feature for you to implement as an exercise. Feel free to comment in case you have any questions!</p><p>Thanks for reading!</p><blockquote><em>Please note: Since we initially published this blog, we released new versions of Strapi and tutorials may be outdated. Sorry for the inconvenience if it’s the case, and please help us </em><a href="https://github.com/strapi/community-content/issues/new/choose"><em>by reporting it here</em></a><em>.</em></blockquote><p>Get started with Strapi by creating a project using a <a href="https://strapi.io/starters">starter</a> or trying our <a href="https://strapi.io/demo">live demo</a>. Also, consult our <a href="https://forum.strapi.io/">forum</a> if you have any questions. We will be there to help you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9de5887f024" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to traverse a tree using JavaScript]]></title>
            <link>https://levelup.gitconnected.com/how-to-traverse-a-tree-using-javascript-c9a79826e819?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9a79826e819</guid>
            <category><![CDATA[trees]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Tue, 16 Jun 2020 08:06:28 GMT</pubDate>
            <atom:updated>2020-07-05T13:13:18.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZCjnKmA6IQEKdpGdkr8SPA.jpeg" /><figcaption>Photo by Frédéric Perez</figcaption></figure><p><em>Originally published at </em><a href="https://blog.purnimagupta.com/traverse-binaryTree/"><em>https://blog.purnimagupta.com</em></a><em>.</em></p><p>Welcome to the 2nd part of my programming tutorial series on Binary Trees! In this article, you’ll learn the concepts behind Tree traversal. You’ll understand some popular tree-traversal techniques and how do they work, and you’ll also learn to implement them using JavaScript.</p><ul><li>A basic understanding of what is a binary tree. If you’re new to this concept or would like a refresher, do read the first part of this series <a href="https://medium.com/swlh/implement-binary-search-tree-in-javascript-897dcbcc5616">here</a>, and visit this article later!</li><li>Some basic understanding of JavaScript</li></ul><h3>Over the next 20 minutes, here’s what you’re going to learn:</h3><h4>#1: Commonly used tree-traversal techniques</h4><p>Breadth-first Search (BFS) and Depth-first Search (DFS)</p><h4>#2: Deep dive into Depth-first search algorithms:</h4><ul><li>Inorder traversal</li><li>Preorder traversal</li><li>Postorder traversal</li></ul><p>You’ll learn about Breadth-first Search in the next tutorial.</p><p>Ready? Let’s go!</p><p><strong>Here’s what </strong><a href="https://en.wikipedia.org/wiki/Tree_traversal"><strong>Wikipedia </strong></a><strong>says</strong></p><blockquote><em>In Computer Science, tree traversal (also known as tree search and walking the tree) is a form of graph traversal and refers to the process of </em>visiting (checking and/or updating) each node<em> in a tree data structure, </em><strong><em>exactly once</em></strong><em>. Such traversals are classified by the </em><strong><em>order</em></strong><em> in which the nodes are visited.</em></blockquote><p>Tree traversal algorithms can be broadly classified into two types:</p><ul><li><strong>Breadth-First Search</strong></li></ul><p>This technique works by first visiting all nodes in a level once, before proceeding to the next levels. The reason it is called “breadth-first”, is because this search <strong>widens</strong> or goes broad in its search strategy.</p><ul><li><strong>Depth-First Search</strong></li></ul><p>A depth-first search, on the other hand, works by going “deeper” into one part of the graph and visiting all of its nodes all the way to the end. Once it has no further nodes to visit for that sub-tree, it <strong>backtracks</strong> to the latest point where it could make a different choice, then explores out from there.</p><p>For a binary-tree, this method is usually done in a left to right order. That is, the search evaluates the left-most branch/sub-tree of the tree, and then it proceeds to the one to the right of it, and so on until all the branches are visited.</p><p><strong>T</strong>rees are a special case of a <strong>Graph</strong> data structure. That’s why algorithms like Depth First Search (DFS) and Breadth-First Search (BFS) can be applied to them as well. The important note to remember is that while graph-traversals can typically start from <strong>any node/vertex</strong>, a tree-traversal will always start from the <strong>root node</strong>.</p><h3>Applications of Depth-first search tree traversal</h3><p>Before you even begin to deep dive into the implementation details, I feel that it’s always helpful to begin with the question <em>Why?</em> Why do we even need to know these algorithms in the first place, and what are their applications?</p><p>I was very curious to find out as I had only heard of DFS before, and had an idea of how they work, but never really understood where or why they even exist. As it turns out, the number of applications are incredibly huge!</p><p>Here are just a few applications where DFS is often used as a building block:</p><h4>In strategy-based games:</h4><p>Board games like chess, sudoku, alpha-go, board configurations are often represented in the form of a <a href="https://en.wikipedia.org/wiki/Game_tree">game tree</a>. In this scenario, variations of DFS are often used for finding the shortest or the most optimum set of moves.</p><h4><strong>Finding Connected Components:</strong></h4><p>You can use DFS to find connected components in an <strong>Undirected Graph</strong>. I couldn’t find good examples of real-world applications of undirected graphs, so if you do have any specific example for this, I would love to know :)</p><h4><strong>Finding Strongly Connected Components:</strong></h4><ul><li>DFS has applications in a <strong>social graph</strong> as well. One example could be when you want to suggest or advertise certain content specific to people who have liked similar pages or liked similar videos. This could be represented as a strongly connected graph, that uses DFS to search for entities that are similar to each other.</li><li>One other interesting application is the <a href="https://developers.google.com/optimization/routing/vrp">Vehicle Routing Problem </a>which helps in finding the optimal (Minimize total cost) routes for multiple vehicles visiting a set of locations.</li></ul><h4><strong>Finding a Path:</strong></h4><p>It can be used to see if a path exists from vertex u to vertex v.</p><h4><strong>Topological Sorting Algorithm:</strong></h4><p><strong>Directed Acyclic Graphs (DAG)</strong> can be used to maintain <strong>linear ordering</strong> of tasks. For instance, the vertices of the graph may represent tasks to be performed, and the edges may represent constraints that one task must be performed before another. Here are a couple of examples:</p><ul><li>In an ATM transaction, tasks happen in a certain sequence. First, we need to insert ATM, enter the PIN and authenticate yourself, and only later withdraw the amount. You can’t withdraw money before you even insert/scan a card. This order of operations can be represented using a DAG, where you could use topological sorting.</li><li>Turn-based games like chess that use game trees are also another example, where certain moves become available only when the player reaches a certain board config.</li><li>If you’re using Debian-based UNIX system then there’s no escape from using apt-get command, which makes use of topological sorting to determine the best possible way to install or remove packages.</li></ul><blockquote><strong><em>Note</em></strong><em>: It’s important to understand that the search algorithm used in the above applications isn’t strictly speaking or exactly DFS. It’s more accurate to say that these algorithms are a variant of DFS, optimized further to perform better in some tasks than others.</em></blockquote><blockquote><em>Some of them are even used in conjunction with traditional BFS (breadth-first search) algorithms as well, such as </em><a href="https://en.wikipedia.org/wiki/Iterative_deepening_depth-first_search"><em>Iterative Deepening Depth First Search </em></a><em>. But more on that later.</em></blockquote><p>Now that we’ve looked at some of the applications, let’s look at some common traversal patterns used in DFS:</p><h3>Common traversal patterns used for DFS:</h3><p><strong>A</strong>s stated earlier, a binary tree can be traversed in a left to right order, and also right to left. But most commonly used traversing techniques that we’ll discuss will proceed in a left to right fashion. These traversals can either use recursive techniques, or they can be done iteratively as well (for which you’ll need to use a stack, a special kind of data-structure).</p><p>For this tutorial, you’ll learn to implement these traversals using <strong>recursion</strong>.</p><h3>Inorder traversal (Left — Root — Right)</h3><p>An inorder traversal works in the following manner:</p><ol><li>We’ll start from the root node and traverse the entire left subtree recursively.</li><li>Access the data value of the root node and do whatever you need to do with it. For the purposes of this tutorial, we’ll just be printing the value.</li><li>Then traverse the entire right subtree recursively.</li></ol><h3>Here’s a gif and a flowchart to help you visualize it:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*gIonhJjvlBE-SBlv.gif" /><figcaption>Inorder Traversal of a tree</figcaption></figure><blockquote><strong><em>Note:</em></strong><em> This traversal always prints the node values in a </em><strong><em>sorted</em></strong><em> order. That’s because the values in the left subtree are </em><strong><em>smaller</em></strong><em> than the root node and values in the right subtree are </em><strong><em>greater</em></strong><em> than the root node.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*67Gf4LaczQXwSorhEaKH-w.png" /><figcaption>Flow Diagram for inorder Traversal</figcaption></figure><p>You’ll continue from the <a href="https://medium.com/swlh/implement-binary-search-tree-in-javascript-897dcbcc5616">last tutorial</a> where you coded a BST in JavaScript, and extend the program to implement DFS. If you need a refresher, do read it once again.</p><h3>Here’s how a JS implementation of an inorder traversal looks like:</h3><pre>function inOrder(root) { <br>   root.left &amp;&amp; inOrder(root.left) <br>   console.log(root.val) <br>   root.right &amp;&amp; inOrder(root.right) <br>} </pre><pre><br>&lt;!-- Call the inorder function. Remember, we&#39;re referring above gif&#39;s BST for reference--&gt; </pre><pre>node.inOrder(node) // 13, 15, 18, 20, 25, 30</pre><p>To be able to understand it clearly, you must know how <em>recursion</em> works. I’ll do my best to elaborate on it.</p><ol><li>We’ll start with the root Node. <a href="https://blog.purnimagupta.com/ec7108953b084ece59a5fecb01cda39a/Inorder-traversal.gif">In our gif</a>, our root node contains the value 20.</li><li>Next, check whether this node has a left child. If yes, then we’ll start our search in the left subtree. This will call the inorder() method again, on the node that contains the value 15.</li><li>Again, it checks if it has a left child. Yes, indeed we have a node with value 13 on the left.</li><li>It calls inorder() on node 13. But it doesn&#39;t have a child node on the left. So the control goes to the next line, and it prints 13 at this point. Finally, we check for the right subtree of the node 13, which doesn&#39;t exist either! So there is nothing more to do, and the program returns to the parent inorder function that called it, on the node with value 15.</li><li>This way, the entire left subtree of the node 15 has been traversed when we called inOrder(root.left). Next,15 gets printed, and then the program proceeds to evaluate the right subtree for the node.</li><li>And the same process repeats all over again until the entire tree has been covered!</li></ol><p>Hopefully, you were able to follow all of that! If you didn’t, go watch this<a href="https://www.youtube.com/watch?v=kepBmgvWNDw"> video on recursion.</a></p><p>Moving on to the next traversal pattern:</p><h3>Preorder (Root — Left — Right)</h3><p>Here’s how it works, starting from the root node just like inorder:</p><ol><li>First, access the current node value, to say, print it out.</li><li>Then, we do the preorder traversal on the left subtree.</li><li>And finally, do the same with the right subtree.</li></ol><p>Basically, we print the parent node first and then the left node and lastly right node. Rinse and repeat, until we’ve covered the whole tree.</p><h3>Here’s a visual followed by a flow diagram:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*PaTE01wN4ToA40Co.gif" /><figcaption>PreOrder Traversal of a tree</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*O-OXxr9eRpP9AqR8c5W95w.png" /><figcaption>Flow Diagram for Preorder Traversal</figcaption></figure><h3>So the JavaScript implementation would look something like this:</h3><pre>preOrder(node) { <br>  console.log(node.val) <br>  node.left &amp;&amp; this.preOrder(node.left) <br>  node.right &amp;&amp; this.preOrder(node.right) <br>} </pre><pre>&lt;!-- Call the preorder function. We&#39;re referring above gif for reference --&gt; </pre><pre>node.preOrder(node) // 20, 15, 13, 18, 25, 30</pre><h3>Postorder(Left — Right — Root)</h3><p>This traversal works this way:</p><ol><li>First, traverse the left subtree recursively.</li><li>Then traverse the right subtree recursively.</li><li>Then finally, access the current node value and print it.</li></ol><h3>Here’s how it looks like:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*najybdVtx7wCsu_u.gif" /><figcaption>PostOrder Traversal of a tree</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*Rk8uf95dsepPr90cgK7LJA.png" /><figcaption>Flow Diagram for postOrder Traversal</figcaption></figure><h3>And here’s the program:</h3><pre>postOrder(node) { <br>  node.left &amp;&amp; this.postOrder(node.left) <br>  node.right &amp;&amp; this.postOrder(node.right) <br>  console.log(node.val); <br>} </pre><pre>&lt;!-- Call the postorder function. We&#39;re referring above gif for reference --&gt; </pre><pre>node.postOrder(node) // 13, 18, 15, 30, 25, 20</pre><blockquote><strong><em>Note:</em></strong><em> As you might have noticed, these traversal patterns don’t vastly differ from one another in their actual code. However, there will be situations where it might be preferable to use one kind of traversal over others.</em></blockquote><h3>Some uses of DFS tree traversal patterns:</h3><h4>Serialization and De-serialization</h4><p>Here’s the Wikipedia <a href="https://en.wikipedia.org/wiki/Serialization">definition.</a>:</p><blockquote><em>In computing, serialization is the process of translating data structures or object state into a format that can be </em><strong><em>stored</em></strong><em> (for example, in a file or memory buffer) or </em><strong><em>transmitted</em></strong><em> (for example, across a network connection link) and </em><strong><em>reconstructed</em></strong><em> later (possibly in a different computer environment).</em></blockquote><blockquote><em>When the resulting series of bits is reread according to the serialization format, it can be used to create a semantically </em><strong><em>identical clone</em></strong><em> of the original object.</em></blockquote><p>In the context of Binary trees, you can think of serialization as converting the tree structure into a <strong>string</strong> or an <strong>array</strong> format. So for example, a postorder traversal gave us this output: 13, 18, 15, 30, 25, 20. This can be stored as a string or in an array (serialization), and it can be used later to construct a new identical BST (de-serialization).</p><p>You can create a BST using these combinations:</p><ul><li>Both preorder and postorder traversals can be used to create (de-serialize) an original BST.</li><li>You can also use postorder and inorder in conjunction to create a BST.</li><li>You can use preorder and inorder together to create a BST.</li><li>You can just use postorder alone to create a BST.</li></ul><h4>Here are some more further applications:</h4><h3>Pre-order traversal:</h3><p>It can be used to make a prefix expression ( <strong>Polish Notation</strong>) from expression trees. If you don’t know, I would suggest reading this artcle on <a href="https://en.wikipedia.org/wiki/Polish_notation">Wikipedia.</a></p><p><strong>For example:-</strong></p><p>This infix expression <strong>A - (B + C) + (D + E)</strong> can be converted to prefix expression as <strong>&quot;+ * A - B C + D E&quot;</strong>. This conversion makes it extremely easy for compilers to evaluate arithmetic/algebraic equations with prefix/postfix expressions than inorder expression.</p><p>Humans are really good at scanning things and remembering the conventional associativity and precedence rules and then we evaluate the equation. We just have to eyeball it. But for a compiler, it will be more complex as it has to take into account the associativity and precedence rules when evaluating the equation. This could be an unnecessary overhead.</p><p>So it’s recommended to convert your inorder expression to either postfix or prefix before the compiler parses the expression since then it wouldn’t need to know the precedence of operators for these two expressions.</p><p>Prefix expressions are evaluated from <strong>right to left</strong>, and they use a stack data structure.</p><h3>Post-order traversal:</h3><p>Just like how preorder traversal is used to generate a prefix expression from a tree, we use postOrder traversal to generate a postfix expression <a href="https://en.wikipedia.org/wikiReverse_Polish_notation"><strong>Reverse Polish Notation</strong></a>. For example, this infix expression<strong>A - (B + C) + (D + E)</strong> can be converted to a postfix expression <strong>&quot;A B C - * D E + +&quot;</strong> using a stack data structure.</p><p>A Post-order traversal is also used when you want to explore <strong>leaf nodes first</strong>. For example — when you need to <strong>delete</strong> a node, it’ll be necessary to access and delete its children nodes first to free up memory, before you delete the node itself!</p><p>Postfix expressions are read from <strong>left to right</strong>, and they also use the stack data structure while evaluating.</p><h3>Inorder traversal:</h3><p>This is one of the most commonly used traversal techniques for binary search trees because it returns the values in the <strong>same order</strong> which was used to create the tree in the first place. So if you need to access the values in sorted order, you will use inorder traversal.</p><p>Graph-based data structures and algorithms are numerous and we’ve just scratched the surface here! In the next tutorial, we’ll cover Breadth-first Search.</p><p>If you have any feedback do let me know in the comments or reach out to me on <a href="https://twitter.com/pooyax14">Twitter</a>.</p><p>If you liked the tutorial, do give it a thumbs up 🙂. See you soon!</p><p><strong>If you want to do further reading, go check out these tutorials.</strong></p><p><strong>#1. DEPTH FIRST SEARCH</strong></p><ul><li><a href="https://brilliant.org/wiki/depth-first-search-dfs/">Brilliant</a></li><li><a href="https://www.hackerearth.com/practice/algorithms/graphs/depth-first-search/tutorial/">Hackerearth</a></li><li><a href="https://en.wikipedia.org/wiki/Depth-first_search">Wikipedia</a></li></ul><p><strong>#2. TREE TRAVERSAL</strong></p><ul><li><a href="https://en.wikibooks.org/wiki/A-level_Computing/AQA/Paper_1/Fundamentals_of_algorithms/Tree_traversal">Wikibooks</a></li><li><a href="https://opendsa-server.cs.vt.edu/ODSA/Books/CS3/html/BinaryTreeTraversal.html">ODSA book on Binary Tree traversal</a></li></ul><p><strong>#3. BOOKS ON ALGORITHMS</strong></p><ul><li><a href="https://www.oreilly.com/library/view/algorithms-in-a/9780596516246/ch07s02.html">Oreilly</a></li><li><a href="https://www.coursera.org/learn/algorithms-part2#syllabus">Coursera</a></li></ul><p><strong>#4. APPLICATIONS OF DFS</strong></p><ul><li><a href="https://www.geeksforgeeks.org/applications-of-depth-first-search/?ref=lbp">Applications of Depth First Search on geeksforgeeks</a></li></ul><h3>Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9a79826e819" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-traverse-a-tree-using-javascript-c9a79826e819">How to traverse a tree using JavaScript</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement Binary Search Tree in JavaScript]]></title>
            <link>https://medium.com/swlh/implement-binary-search-tree-in-javascript-897dcbcc5616?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/897dcbcc5616</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Sat, 02 May 2020 16:30:11 GMT</pubDate>
            <atom:updated>2020-05-06T15:18:29.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BHxp_MMqksBo84wF.jpg" /><figcaption>Photo by Frédéric Perez</figcaption></figure><blockquote>Originally published on my <a href="https://blog.purnimagupta.com/implement-binarySearchTree/">tech blog</a></blockquote><h3>Table of Contents</h3><ol><li><a href="https://blog.purnimagupta.com/implement-binarySearchTree/#what-is-a-binary-tree">What is a Binary Tree</a></li><li><a href="https://blog.purnimagupta.com/implement-binarySearchTree/#types">Properties of binary tree</a></li><li><a href="https://blog.purnimagupta.com/implement-binarySearchTree/#insert">Insert a node in Binary Search Tree</a></li><li><a href="https://blog.purnimagupta.com/implement-binarySearchTree/#search">Find a node</a></li></ol><h3>What is a Binary Tree?</h3><p>To answer this question, you need to know what is a <em>tree</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*UYpFb3WSzeB_tFnO.png" /></figure><h3>No, not that one.</h3><p><strong>Here is the Wikipedia definition of a tree:</strong></p><blockquote>In computer science, a “tree” is a tree data structure which allows us to represent the hierarchial data in a graphical form. It’s named a “tree structure” because it resembles a biological tree, but with the upside down form, with the “root” being at the top and the “leaves” at the bottom.</blockquote><p><em>Root at the top and leaves like at the bottom.</em> So like this?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*mo4T_olJ3HqkeuzN.png" /></figure><h3>Hmm, close enough. It’s more like this:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*5NTnSrB6uYVVhtrj.png" /></figure><p>So trees are <strong>data structures</strong>. What’s more interesting is that, they are also <strong><em>recursive</em></strong><em> data structures</em> — because within a tree is there is another tree (sub-tree), and within that sub-tree is another sub-tree…all the way down!</p><p><strong>There are lots of applications of a tree data structure, and some of them are:</strong></p><ul><li>operating system(directory structure)</li><li>management(hierarchical organizational structures)</li><li>biology(evolutionary tree)</li></ul><p>And when we discuss a tree within the context of programming, we often represent it in this way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*9MlEdvFZgOklbtx4.png" /></figure><p>Now, in this post, I’ll focus on a special kind of tree, called a <em>Binary Tree</em>.</p><blockquote>A Binary Tree is a tree data structure in which each node has at the most, 2 children. There can be a child on the left, and a child on the right.</blockquote><p>The tree elements are called nodes. And each node can have atmost 2 children. That means it can have either 0, 1, or 2 children.</p><p>Here are some examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*a-IkuhwcilsayFAF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*BvZdN6gMNMbY3Gck.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*eJpW93vo5MgoangN.png" /></figure><h4>Binary trees are very useful because they help you store, sort and retrieve data very efficiently.</h4><h3>Binary trees can be of many types as well:</h3><ul><li><strong>Full/Proper/Strict Binary Tree</strong></li></ul><p>Every node has exactly two children except leaf nodes. Leaf nodes have zero children.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*HCxlNcwqOckz5kVx.png" /><figcaption>Valid Full Binary Tree</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*UOKFH6sTy8nRdaG0.png" /></figure><ul><li><strong>Complete Binary Tree</strong></li></ul><p>All levels are completely filled except the last level and last level has nodes as left as possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*etT-QVCWIqCkrhbe.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*Jiq77SKq3911f_JQ.png" /></figure><ul><li><strong>Perfect Binary Tree</strong></li></ul><p>All the internal nodes have 2 children and all the leaves are at the same level. A Perfect binary tree is also a complete binary tree and full binary tree, but the reverse is not true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*lONuED85QMiBK269.png" /></figure><ul><li><strong>Degenerate Binary Tree</strong></li></ul><p>All internal nodes have exactly one node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*fhM65x_SyLTwqJg7.png" /></figure><p>Now that you’ve seen how different binary trees can look like, let’s look at some of their properties</p><h3>Properties of a binary tree</h3><ul><li>Maximum number of nodes possible at any level <strong>i = 2^i</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Hp2KQiXpOmLt16vH.png" /></figure><ul><li>Maximum number of nodes at height h would be <strong>2^h-1</strong>nodes if the height of the root node is 1. But if you consider the height of the root node as 0, then the formula would be slightly changed and can be written like this<br><strong>2^(h+1) — 1</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_AVMFafYKJg_aBMX.png" /></figure><ul><li>Minimum height h = Math.ceil(log(n+1)). It can be derived from the equation above.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Rur0U0ADq9vpOezi.png" /></figure><ul><li>Minimum number of nodes in a Binary tree of height h would be <strong>n = h+1</strong>. Here, we’re considering the height 0 for the root Node.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_YaFdqkKBcLCf4Na.png" /></figure><ul><li>You can easily derive from equation n=h+1 that maximum height at node n is <strong>h = n-1</strong></li></ul><h3>What is a Binary Search Tree?</h3><p>According to Wikipedia, binary search trees (BST), is a data structure that stores “items” (such as numbers, names etc.) in memory. It keeps their keys on sorted order so that lookup and others can use the principle of binary search.</p><p>In simple words, a binary search tree is a binary tree that has the following properties:</p><ul><li>The left subtree of a node is less than or equal to it’s parent node’s key</li><li>The right subtree of a node is greater than or equal to it’s parent node’s key</li></ul><h3>Logical representation of a Binary Search Tree</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*r1wA7b5zYCXVoe0v.png" /><figcaption>Logical representation of BST Tree</figcaption></figure><h3>Let’s write some code now!</h3><p>In the following tutorial, you’ll learn to build a binary search tree. You’ll learn how to write create and insert integer nodes into the tree, and how to efficiently search for some data value.</p><blockquote>Note: The coding tutorial will be in JavaScript, so some basic knowledge of programming in JS will be useful.</blockquote><p>So if you notice carefully in the diagram above, we know that a node would require three fields:</p><ul><li>a <em>data</em> field to store a value or some information like an integer for example.</li><li>a <em>left</em> field to store the left subtree</li><li>a <em>right</em> field to store the right subtree</li></ul><p>So first, create a class called BST:</p><pre>class BST {<br>  constructor(val) {<br>    this.val = val;<br>    this.left = null;<br>    this.right = null;<br>  }<br>}</pre><p>In the beginning, you’ll create an instance of this class when you add your first root node. It’s a BST with 1 node, and since that node does not have any subtrees below it, its <em>left</em> and <em>right</em> nodes would be null.</p><pre>let rootNode = new BST(10);<br>console.log(rootNode) // Node { val: 10, left: null, right: null }</pre><p>Next, let’s write a function to insert a node.</p><h3>Insert a node</h3><h4>LET’S VISUALIZE IT THROUGH A FLOW DIAGRAM</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/0*3XZhOMYKHW1UdsNy.png" /></figure><p>This is how the logic of the insert function would look like:</p><pre>insert(val) {<br>  if(val &lt; this.val &amp;&amp; !this.left) {<br>    this.left = new Node(val);<br>  }<br>  else if(val &lt; this.val &amp;&amp; this.left) {<br>    this.left.insert(val)<br>  }<br>  else if(val &gt; this.val &amp;&amp; !this.right) {<br>    this.right = new Node(val)<br>  } <br>  else if(val &gt; this.val &amp;&amp; this.right) {<br>    this.right.insert(val)<br>  }<br>}</pre><p>Now, if you insert rootNode.insert(8), and print the root node, then the output would be:</p><pre>Node {<br>  val: 10,<br>  left: Node { val: 8, left: null, right: null },<br>  right: null <br>}</pre><p><strong>What happened?</strong></p><p>In the beginning, the value of the root node is 10. Then, you tried to insert 8. 8 is less than 10, so the first condition holds true - and it inserts a new Node with a value of 8 to the left of the Node 10.</p><p>If we insert again rootNode.insert(6) then what do you think will happen? Think for a while and proceed below to check the output.</p><pre>Node {<br>  val: 10,<br>  left:<br>   Node {<br>     val: 8,<br>     left: Node { val: 6, left: null, right: null },<br>     right: null <br>  },<br>  right: null <br>}</pre><p>This time the 2nd condition holds true, because 6 is less than 10 and the left subtree exists (because it already contains 8!) So it’ll call the insert function again, but this time within the left sub-tree (i.e, the Node that contains 8). Now the 1st condition will again hold true, and a new Node with the value 6 will be inserted to the left of the Node with the value 8.</p><p>Let’s move on now.</p><h3>Search if some value exists in the tree</h3><p>Think for a moment how we’ll write the logic for this bit. Let’s divide it into subtasks that we would need.</p><ul><li>if the value is equal to the root Node itself then we can return true (meaning that the value exists).</li><li>if the value is less than the root Node and the left node exists, then search in the left subtree.</li><li>if the value is bigger than the root Node and the right node exists, then search in the right subtree.</li></ul><h4>LET’S VISUALIZE IT THROUGH A FLOW DIAGRAM</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/0*2poWU_ielD_ASqmx.png" /></figure><pre>search(element) {<br>  if(this.val === element) {<br>    return true<br>  } else if(this.val &gt; element &amp;&amp; this.left){<br>    return this.left.search(element)<br>  } else if(this.val &lt; element &amp;&amp; this.right) {<br>    return this.right.search(element)<br>  }   </pre><pre>  return false // element does not exist in the tree <br>}</pre><p>AND WE’RE DONE!</p><h3>Here is how the final program will look like:</h3><pre>class Node {<br>  constructor(val) {<br>    this.val = val;<br>    this.left = null;<br>    this.right = null;<br>  }</pre><pre>  insert(val) {<br>    if(val &lt; this.val &amp;&amp; !this.left) {<br>      // create a new node at the left of the tree<br>      this.left = new Node(val);<br>    }<br>    else if(val &lt; this.val &amp;&amp; this.left) {<br>      this.left.insert(val)<br>    }<br>    else if(val &gt; this.val &amp;&amp; !this.right) {<br>      this.right = new Node(val)<br>    } <br>    else if(val &gt; this.val &amp;&amp; this.right) {<br>      this.right.insert(val)<br>    }<br>  }</pre><pre>  search(element){   <br>    if(this.val === element) {<br>      return true<br>    } else if(this.val &gt; element &amp;&amp; this.left){<br>      return this.left.search(element)<br>    } else if(this.val &lt; element &amp;&amp; this.right) {<br>      return this.right.search(element)<br>    }<br>    return false<br>  }<br>}</pre><pre>// create a bst with 3 nodes. (Root node contains the value 10)<br>let bst = new Node(10);<br>bst.insert(9)<br>bst.insert(6)</pre><pre>console.log(bst)<br>console.log(bst.search(9)) // prints true</pre><h3>Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=897dcbcc5616" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/implement-binary-search-tree-in-javascript-897dcbcc5616">Implement Binary Search Tree in JavaScript</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Vipassana experience]]></title>
            <link>https://medium.com/@dhammapurnima/my-vipassana-experience-2c35bdbc75b9?source=rss-5fd1aedf6f88------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c35bdbc75b9</guid>
            <category><![CDATA[spirituality]]></category>
            <category><![CDATA[meditation]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[mindfulness]]></category>
            <category><![CDATA[personal-development]]></category>
            <dc:creator><![CDATA[Purnima Gupta]]></dc:creator>
            <pubDate>Fri, 17 Jan 2020 09:05:10 GMT</pubDate>
            <atom:updated>2025-03-15T17:24:41.156Z</atom:updated>
            <content:encoded><![CDATA[<h3>Serving in Silence: My 10-Day Vipassana Experience Behind the Scenes as a Server</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tQdpUjNE0CtBzh8y9ojO6A.jpeg" /><figcaption>Photo by Lesly Juarez</figcaption></figure><p>It was the beginning of January 2018, my second time. A 10-day rigorous retreat, during which you’d live your life as an ascetic and do nothing but mindfulness meditation.</p><p>I went to this meditation retreat as a <em>dhamma</em> server. As servers, it was our duty to serve meditators — by making sure the kitchen is clean and food is prepared before lunchtime, and helping them by providing any necessary things that they might have forgotten to bring. Thus, making sure they get the best out of the course without any difficulties and issues.</p><p>Along with me was one more server. We had to share our responsibilities equally, taking turns to do things. After all, being a server is a challenge — and at the same time, a very fulfilling experience. You might ask — <em>what makes it challenging</em>?</p><p>Well, there’s the waking up at 4 A.M part, for the next 10 days. And that’s just the beginning, heh. Once awake, we servers would need to go around the dormitory, ringing bells. The students would wake up hearing the bells and be ready by 4:30 am, to begin their first meditation hour of the day.</p><p>Now I’m not an early morning person, so waking up at 4 a.m required lots of motivation to get out of bed. To my surprise, I didn’t find it very hard to wake up this early even when I am not used to.</p><p>Most of the students were pretty serious about it and didn’t create any chaos. They woke up in time and were there soon in the meditation hall. Hardly any rules were broken. The usual ones were a handful that you had to adhere to — observe complete silence, make no sort of gestures, avoid eye contact, no touching, no lies, no use of any electronic devices, pen or paper.</p><p>Basically, you will be prohibited from doing anything other than meditation, sleep, food, bathing. I know it might feel very intimidating at first since we’re so used to checking our social media accounts.</p><blockquote>You can survive 10 days without using your phone. Trust me.</blockquote><p>Although I gotta tell you — these 10 days are gonna be your longest 10 days ever. HAHA. You’ll feel like as if you are stuck here forever. Time runs at a sluggish pace! One feels like running away from there to return to home, back to the chaos which we all know so well and love.</p><p>It’s a strange thing, really. In the chaos, the mind longs for peace and solitude. But it has long forgotten how solitude and silence can feel like. To an untrained mind, it can feel almost overwhelming, too much to bear. And before long, we want to return to the world of wildness.</p><blockquote>“Madness, as you know, is like gravity. All it takes is a little push.” — The Dark Knight</blockquote><p>This is not for everyone. Only the strongest of minds will be able to bear the excruciating pain that they go through in this duration.</p><p>No, no one is going to torture you there. It’s your mind that will make you go crazy when you’re meditating. Thoughts will engulf you, overpower you, and will take you down to the rabbit hole. And if you are not mindful, you might stay there very long, until your mind comes back to the present moment and reminds you to focus on breathing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*UGR7ncLDlONcJ8le.png" /></figure><p>Though there are different types of meditations catering to different needs of people, I have only practised the Vipassana technique. This method was rediscovered by Gautama Buddha almost 2500 years ago. The goal of this meditation is the <em>purification of the mind</em>.</p><p>After my second 10 day retreat, I went on to meditate every day for over a year. So I know a thing or two about it.</p><h3>What is Vipassana meditation</h3><p>(<a href="https://www.dhamma.org/en-US/about/vipassana">https://www.dhamma.org/en-US/about/vipassana</a>)</p><p>I got introduced to Vipassana for the first time in 2015 which is when I attended my first 10 day course. This form teaches you to see things as they are. No contemplating, no manipulating, no illusion, no delusion. Accepting reality as it is, not as you would like it to be. As you work with the truth moment by moment, one is eventually bound to experience the <a href="https://www.dictionary.com/browse/nirvanic"><strong>nirvanic</strong></a> peace within.</p><h3>The technique</h3><p>This meditation works with the physical sensations in the body. One will observe the bodily sensations starting from the top of their head, scanning part by part every inch of the body. As you scan them, you check for sensations if any are present at that moment. Most important of all, remain equanimous when you feel any sensations — itching, pain, throbbing, pulsating, free flow etc.</p><p>Whenever you work with sensations, you are working with the deepest level of your mind — the <strong><em>subconscious mind</em></strong>. Our gross mind is not subtle enough to feel the sensations which are present throughout our body every moment. Here, we work with sensations, thus, working with the subconscious mind. Lastly, don’t react to it with the understanding that this is also impermanent.</p><p>This meditation purifies the mind, helping it get rid of any mind related problems or psychosomatic diseases to go away. But one should not practice it for the sake of curing their ailments. Vipassana is more than that.</p><blockquote>Key: Be aware of your sensations, remain equanimous.</blockquote><h3>The vast virtues of Vipassana —</h3><p>There are benefits of Vipassana if practised properly — and plenty of them have been researched in science as well. Though it takes time to tame our untrained mind, the results are inevitable —</p><h4>HEIGHTENED SENSITIVITY AND AWARENESS</h4><p>You will start observing small things that might never have caught your attention like rising up and down your tummy belly when you breathe. You also become aware of positive and negative emotions that manifest themselves from time to time due to some reason or the other.</p><h4>EQUANIMITY</h4><p>You start observing your sensations with equanimity — maintaining composure and remaining calm. Yes, that makes all the difference, because soon it starts manifesting itself into other areas of your life. Why?</p><p>Because you’re training yourself to remain objective. It will become your habit to observe any negativity as soon as it arises, and recognize it for what it is. That way, you will have more control over your actions, rather than blindly reacting to it.</p><p>It might be a little difficult to observe your sensations when you’re engulfed by your emotions/pain/anger/hatred/ego. Definitely, but not impossible. It just needs more practice, just like any other activity.</p><h4>CHANGING THOUGHT PATTERNS AND PERSPECTIVES</h4><p>If you’ve been practising it consistently and as the technique want you to practice it without any dogma. One will definitely start seeing changes in their thought patterns.</p><p>It will give you a fresh new perspective on your relationships with your parents, colleagues, partner and with everyone around you. Your shallow views on relationships and friendships change, as you’re able to look at things objectively.</p><h4>SELFLESSNESS AND GRATITUDE</h4><p>You don’t now expect favours from someone whom you helped or want to help. You become more compassionate and kind to oneself and to every living being — visible or invisible. You start wishing good for others — and even more so if they are your enemy. You will see you start developing more compassion for people who have hurt you, betrayed you.</p><h4>SELF-LOVE</h4><p>Self-love is different from “selfish” love. It is the kind of love that compels you to accept yourself with all the flaws that have been eating you alive. You understand that self-hatred doesn’t do any good to yourself. Instead, you focus your energy on things which actually matters.</p><p>Some of the other benefits are even physiological. There are studies that indicate that regular practitioners have increased pain tolerance, lower blood pressure levels, and enjoy better health than non-meditators, when accounted for lifestyle and other factors.</p><p>The scriptures also talk about benefits that go beyond the “physical” reality, and into the metaphysical. On how you can break the cycle of karmic debt. On matters related to existence, and how you can expand your own consciousness. After all, Buddha attained “enlightenment” by this very technique! Who really knows what that is?</p><p>These things might not even make any sense to you at this point — and sound too good to be true. And that’s okay — it’s not at all necessary to believe in things that don’t make any sense to you at this point in time. In Gautama Buddha’s very beautiful words —</p><blockquote>“Do not believe in anything simply because you have heard it. Do not believe in anything simply because it is spoken and rumored by many. Do not believe in anything simply because it is found written in your religious books. Do not believe in anything merely on the authority of your teachers and elders. Do not believe in traditions because they have been handed down for many generations.</blockquote><blockquote>But after observation and analysis, when you find that anything agrees with reason and is conducive to the good and <strong>benefit</strong> of one and all, then accept it and live up to’’</blockquote><p>The key points here being <strong>observation</strong> and <strong>analysis</strong>. The theory will only take you so far, and some things you’ll have no other choice but to see for yourself. Until then, it’s important to have trust in the process. Doubt can be powerful, but it can also become a hindrance in your exploration.</p><h3>Concluding Thoughts (Or dare I say Equanimous?) 😜</h3><p>As I said earlier, this is going to be difficult. But aren’t all activities that lead to personal growth usually are? This is a spiritual path and not some cool activity that you do to show off to your friends.</p><p>Just like you can’t build bigger muscles without going through a painful ordeal in the gym, in the same way, you can’t build a better mind without going through this trial of mental fortitude and will.</p><blockquote>Knowing yourself is the beginning of all wisdom — Aristotle</blockquote><p>Go forth, and know thyself, my friend!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c35bdbc75b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>