<?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 Manish Chaulagain on Medium]]></title>
        <description><![CDATA[Stories by Manish Chaulagain on Medium]]></description>
        <link>https://medium.com/@manishchaulagain?source=rss-dab38b023dea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*icXuNHqWAvgiAT2kZ6khPA@2x.jpeg</url>
            <title>Stories by Manish Chaulagain on Medium</title>
            <link>https://medium.com/@manishchaulagain?source=rss-dab38b023dea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:45:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manishchaulagain/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[Multi-Tenancy using Row Level Security in Postgres]]></title>
            <link>https://medium.com/@manishchaulagain/multi-tenancy-using-row-level-security-in-postgres-2ebfd6871539?source=rss-dab38b023dea------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ebfd6871539</guid>
            <category><![CDATA[multi-tenant]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[row-level-security]]></category>
            <dc:creator><![CDATA[Manish Chaulagain]]></dc:creator>
            <pubDate>Fri, 25 Oct 2024 03:43:23 GMT</pubDate>
            <atom:updated>2024-10-30T22:06:27.155Z</atom:updated>
            <content:encoded><![CDATA[<p>Monitoring and managing multiple tenants can add operational complexity, especially for small teams with limited resources.</p><p>To balance the need for rapid feature development with the benefits of multi-tenancy, one common approach is to use a shared database model with application-level tenancy control. However, relying on developers to manually add WHERE tenant_id=&lt;&gt; to every SQL query is highly risky and prone to errors. Perhaps, there is a better way?</p><h4>Row Level Security</h4><p>PostgreSQL enables you to <a href="https://www.postgresql.org/docs/current/ddl-rowsecurity.html">assign row-level security policies</a>, allowing you to control which rows are returned by queries based on the privileges defined in the policy. This is an effective method to ensure queries only return tenant-specific data. By defining policies that grant access to a single tenant at a time, you shift the responsibility for data access control from the application to the database, significantly reducing the risk of data leakage.</p><p>Before we proceed, you must be aware that the Row-Level Policies do not apply to the table owner. Therefore, we must create a different user to enforce privileges.</p><ol><li>Create a new ROLEwith login access such that we can use it in our application.</li></ol><pre>CREATE ROLE dev WITH LOGIN PASSWORD &#39;supersecret&#39;;</pre><p>2. Create tenanttable that contains the unique tenant_idthat we will use the filter with RLS.</p><pre>CREATE TABLE app.tenant (<br>    id INTEGER PRIMARY KEY,<br>    name VARCHAR(255) NOT NULL<br>);<br><br>/** Seed some dummy data **/<br>INSERT INTO app.tenant(id, name) VALUES (1, &#39;one&#39;), (2, &#39;two&#39;);</pre><p>3. Create product table that we will use to demonstrate enforcing RLS</p><pre>CREATE TABLE app.product (<br>    id SERIAL PRIMARY KEY,<br>    tenant_id INTEGER,<br>    name VARCHAR(255) NOT NULL<br>);<br><br>/** Seed some dummy data **/<br>INSERT INTO app.product (tenant_id, name) <br>VALUES <br>    (1, &#39;Product A1&#39;),<br>    (1, &#39;Product A2&#39;),<br>    (2, &#39;Product B1&#39;),<br>    (2, &#39;Product B2&#39;),<br>    (1, &#39;Product C1&#39;),<br>    (1, &#39;Product C2&#39;);</pre><p>4. Grant privileges to our newly created tables for our dev ROLE</p><pre>GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dev;<br>GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO dev;</pre><p>5. Enable Row Level Security in product . Then, create a policy tenant_isolation_policy such that we check the app.current_tenant value to add the correct filter.</p><pre>ALTER TABLE product ENABLE ROW LEVEL SECURITY;<br><br>CREATE POLICY tenant_isolation_policy ON product <br>USING (tenant_id = current_setting(&#39;app.current_tenant&#39;)::INTEGER);</pre><p>Done 🎉 That’s all there is. Now let’s see it in action.</p><h4>Demonstration</h4><ol><li>Logging in with the role devand running SELECT * FROM product; will return ERROR: unrecognized configuration parameter “app.current_tenant” . This is expected since we haven’t configured app.current_tenant it yet.</li><li>SET app.current_tenant using SET command</li></ol><pre>/** You can run SHOW app.current_tenant to verify<br>the current value **/<br>SET app.current_tenant=1;</pre><p>3. Now running SELECT * FROM product; will return only tenant 1 specific rows. 🆒</p><pre>id  | tenant_id |    name    <br>----+-----------+------------<br>  1 |         1 | Product A1 <br>  2 |         1 | Product A2 <br>  5 |         1 | Product C1 <br>  6 |         1 | Product C2 </pre><p>4. Try changing the value app.current_tenant to something else and see how Postgres automatically filters the row based on our tenant_isolation_policy. In our application layer, we can leverage this by dynamically setting the value of this configuration parameter to achieve our desired single database multi-tenancy. 🎉</p><p>For a full demonstration of how we can achieve this in Golang by dynamically setting and getting them tenant_idin the request context, you can check the repo here: <a href="https://github.com/Eddie023/multi-tenancy-with-RLS">https://github.com/Eddie023/multi-tenancy-with-RLS</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ebfd6871539" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reflecting  on personal development]]></title>
            <link>https://medium.com/@manishchaulagain/reflecting-on-personal-development-33811e32ee11?source=rss-dab38b023dea------2</link>
            <guid isPermaLink="false">https://medium.com/p/33811e32ee11</guid>
            <category><![CDATA[grit]]></category>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[motivation]]></category>
            <dc:creator><![CDATA[Manish Chaulagain]]></dc:creator>
            <pubDate>Sat, 13 Jun 2020 13:36:15 GMT</pubDate>
            <atom:updated>2020-06-14T07:09:56.457Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reflecting on personal development</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tnM-it8tb-ayNKEfQAqcYw.jpeg" /><figcaption>A picture I painted roughly 10 years back</figcaption></figure><p>Last year, I re-painted a picture that I had once drawn 10 years back. This picture, at that time, was something I was so proud of. It was one of my first good looking watercolor painting. When I completed redrawing the same picture 10 years later, I could see how far I had come as a hobbyist watercolor-painter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*YcGMUYtY8thJkKhw8uPTrA.jpeg" /><figcaption>The same picture re-painted 10 years later</figcaption></figure><p>Back in those days, when my parents were fed up with me and wanted me to study, I would lock myself in my room, pick up my watercolor brush, my sketchbook and start to paint. For me, painting was a way out of reality. I used to escape into my own world, leaving behind all the troubles, and anxieties of a teenager. Now it seems like all those years of misguided techniques, shakey strokes, and experimental mix of colors had made me more confident at the craft of watercolor painting.</p><p>These days as a full-time software developer, regrettably, I don’t get to paint that often. But every time I get stuck on some programming problem, I remember this specific piece of painting and what difference there was between the same picture painted at two different time frames. That success in life lies in the mix of <a href="https://www.youtube.com/watch?v=H14bBuluwB8">practice, patience, and perseverance.</a></p><p>Perhaps, one day I will have a similar kind of epiphany regarding my career as a software developer. All the mistakes I made along the way, all obstacles I overcame to become a better problem solver will accumulate to making me a better programmer. Friedrich Nietzsche was spot on when he said <a href="https://www.brainpickings.org/2014/10/15/nietzsche-on-difficulty/">fulfilling life requires embracing rather than running from difficulty</a>.</p><p>Funny how making such a simple painting of rustic scenery taught me about life and how that journey made me who I am today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33811e32ee11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[POCD — a proven framework to build your new venture]]></title>
            <link>https://medium.com/@manishchaulagain/pocd-a-proven-framework-to-build-your-new-venture-1fc3ccaed016?source=rss-dab38b023dea------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fc3ccaed016</guid>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[entreprenuership]]></category>
            <category><![CDATA[harvard-business-school]]></category>
            <category><![CDATA[startup-lessons]]></category>
            <category><![CDATA[homestay]]></category>
            <dc:creator><![CDATA[Manish Chaulagain]]></dc:creator>
            <pubDate>Sat, 09 May 2020 11:22:37 GMT</pubDate>
            <atom:updated>2020-05-10T17:19:07.627Z</atom:updated>
            <content:encoded><![CDATA[<h3>POCD — a proven framework to build your new venture</h3><p>On April 16, 2020, I completed the business lessons provided by Harvard Business School. This article is my takeaways from one of those invaluable lessons — Entrepreneurship Essentials.</p><p><a href="https://online.hbs.edu/courses/entrepreneurship-essentials/">Entrepreneurship Essentials course </a>was taught by William Sahlman, professor at HBS who had developed the POCD framework himself. It’s a proven framework for building and financing new ventures.</p><h3><strong>What is POCD framework?</strong></h3><p>As an entrepreneur, who is looking to grab the opportunity, it is most productive to look at it as an interconnected combination of four elements: people, context, (business) opportunity, and deal. The right combination i.e the degree of fit among them means a high-potential opportunity. A bad combination, or the lack of any single element, is a recipe for failure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/1*VXiT-haj2dJpMH1dhexFbQ.gif" /><figcaption>Fig: Components of POCD Framework</figcaption></figure><p>Let’s looks at them individually.</p><p><strong>People:</strong> They are the individual who will have an important impact on a venture, whether or not they are actual employees. It can include founders, investors, key suppliers, and in some cases clients as well.</p><p>E.g: Are the people capable, experienced, and trustworthy?</p><p><strong>(Business) Opportunity</strong>: It is an intended product or service for which customers are willing to pay more than the required investment and operating cost.</p><p>E.g: Is the opportunity attractive? For an outsourcing company in Nepal, the opportunity is attractive because it can provide equivalent service to companies overseas by charging significantly low cost than the competition there, due to the low cost of labor in Nepal.</p><p><strong>Context</strong>: They refer to the factors that affect the outcome of the opportunity but are generally outside management direct control. This category includes interest rates, regulations, macroeconomic activity, technology, and some industry variables like competition or relative business bargaining power.</p><p>Eg: Is the context favorable? Sticking with the example of an outsourcing company in Nepal, the context is favorable because they can pay a competitive salary (in the context of Nepal). Nepal also has a huge number of tech graduates every year that can be trained and employed.</p><p><strong>Deals</strong>: They are the implicit and explicit contractual relationships between the venture and all resource providers. Deals allocate cash and risk and therefore affect the venture’s value. Examples of deals range from investment contracts to the terms of employment for managers. Ventures also strike important deals with customers and vendors.</p><p>Eg: Are the deals legal, comprehensible, and coherent?</p><p><em>The degree of fit</em> among these components is what separates the winning opportunity from losers. Do we have the right people that understand the context properly? Is the context well fitted to grab the opportunity? Can we create good deals to attract the right people? Are the people well experienced to understand the opportunity?</p><p>Keeping all these in mind, let’s try out the POCD framework.</p><h3><strong>Idea: </strong>Digitalizing Homestay in Nepal</h3><p>5 years back, in the second year of my university studies, I had participated in a local Hackathon under the theme “Rural Development”. My team had an awesome idea to uplift the Homestay Industry by promoting and modernizing the Homestay culture in Nepal. We had the grand vision of empowering the economy of local communities by bringing the foreign revenues to their doorstep. So, in 24 hours we contrived whatever web development we knew and created a Proof of Concept(POC) website-portal for local communities to sign up for their Homestay Makeover.</p><p>After a caffeine-filled sleepless night of coding and answering some tough questions from the judges, we went home first place.</p><p>Unbeknownst to me, at that moment to realize what it actually takes to run a successful venture. In a retrospect, definitely a lot more than an untested idea and a silly certification of validation.</p><p>So, knowing what I know now, below is my attempt to rethink the whole process in the POCD framework.</p><ol><li><strong>The inception of the idea:</strong></li></ol><p>There was this one talk where one of the well-known local entrepreneurs said — “one way to succeed as a venture in Nepal is to look at what the USA did 10 years ago and try to replicate it”. This has been the success recipe for many e-commerce behemoths like Daraz, Sastodeal who were inspired by Amazon. Tootle who modeled after Uber and other various outsourcing companies. I was very much inspired by this and had at that time recently read about Airbnb and was in awe knowing how it has taken over the world’s hotel industry without owning a single hotel.</p><p>Since then, “Think globally, act locally” has been my inspiration to find any new opportunities. This also led me into the habit of reading Wall Street Journal, Economist, Wired but that’s a tale for another time.</p><p>So, the idea is to try replicating Airbnb but something that’s more catered to the Nepali market.</p><p><strong>2. Evaluating the opportunity:</strong></p><p>POCD framework clearly shows that we need to focus more on the opportunity rather than the idea. One solid approach would be to start by asking the right questions, doing the required market research thoroughly, and running small scale tests to validate before fully being committed to the idea.</p><p>Some of the questions that I should be asking myself before being committed to Eddie’s Homestay (EH) could be:</p><ul><li>How big is the relevant market and what share of the market could EH capture?</li><li>Can EH form mutually beneficial, long-term relationships with local communities?</li><li>What is the cost of each homestay acquisition?</li><li>Can EH handle the training, renovating, and maintaining the hospitality for the guests?</li><li>Can EH build an effective digital platform?</li><li>How much money will be required to build an attractive business?</li><li>How much time will be required at each stage of the company building process?</li><li>Can EH raise the money and still have enough ownership left to make it worthwhile?</li><li>Can EH build entry barriers and a sustainable competitive advantage?</li></ul><p>Answering these questions would give me a better understanding of the opportunity and whether or not it&#39;s attractive.</p><p><strong>3. Estimating the market size:</strong></p><p>Estimating the market size is an undeniably difficult thing to pull off but this is where the characteristics of an entrepreneur are defined. This is where you find that niche market.</p><p>I should research the total number of tourists arriving each year. How much on average are they spending on accommodations? What percent of them are more into the culture and heritage rather than fancy services.</p><p><strong>4. Conducting the first test:</strong></p><p>There are still endless possibilities that I haven’t thought which could go wrong.</p><ol><li>Are the tourists interested in a commercialized homestay?</li><li>Do they feel that our purposed “modern homestay” will take away the shine of homestay?</li><li>Do we have a competitive advantage with the local hotels?</li></ol><p>It is evident that running small tests to validate this stuff will filter out the actual opportunity from initially thought out idea.</p><p><strong>5. Finding the right team.</strong></p><p>Businesses are more likely to succeed with more than one founder. Y Combinator — a very successful seed funding for a tech startup has glorified the <a href="https://www.youtube.com/watch?v=CRLzkbtKPGM"><em>benefits of having a co-founder</em></a>. Finding people who have different skillsets than you, and are equally driven with the same passion could be the make or break for many early stages of a startup.</p><p>For Eddie’s Homestay, it would be beneficial to have some local face who is well respected in that community and has good knowledge of hospitality. An amalgam of a business mind, techy, and a person with a background in hospitality would be an ideal situation.</p><blockquote>Remember to always build your venture around people.</blockquote><p><strong>6. Learning and growing (scaling):</strong></p><p>Once the business kickstarts its sales, a massive amount of information like sales patterns, the client’s feedbacks could be analyzed and used for getting insights for a more fine-tuned customer value proposition. To create relevancy in the free market, we need to always have a competitive advantage to sustain the business in the long run.</p><p><strong>7. Business Model</strong></p><p>Business Model is the primary determinant of operating cash flow. Any venture must show that it can generate positive cash flow on a per-customer basis. This might not be true at the beginning but is a must over time. The cumulative cash inflows must exceed the corporate cash outflow.</p><p>Cash Inflow for Eddie’s Homestay could be:</p><ol><li>5% on clients that book from our webpage.</li><li>Provide loans to homestays for renovation and take a small percentage for each client.</li></ol><p>Cash Outflow for Eddie’s Homestay could be:</p><ol><li>Cost of customer acquisition i.e digital marketing, hiring salespeople that can travel to some local community and persuade them.</li><li>Cost of training the homestay owners about hospitality.</li><li>Cost of running a website.</li><li>Operating cost: Office rent, employee salary, etc.</li></ol><p>So, for Eddie’s Homestay to be a great opportunity, it must show that it can create positive cash flow (cash outflow minus cash inflow &gt; 0) for each new customer acquisition.</p><h3><strong>POCD for Eddie’s Homestay</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHNzDm6GDfH4H4LTpTqiUQ.png" /><figcaption>Fig: POCD for Eddie’s Homestay(EH)</figcaption></figure><p>In this way, the POCD framework can help us in thinking about what we should be doing rather than fixating on the “brilliant idea”. In the beginning, I had an idea that could have been turned into a possible opportunity. But now, taking the right steps, adhering with this framework, this could be a viable venture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fc3ccaed016" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>