<?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 Serban Marti on Medium]]></title>
        <description><![CDATA[Stories by Serban Marti on Medium]]></description>
        <link>https://medium.com/@marti.serban?source=rss-4dd540e1f305------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ogjIERTYQ_sRDnlj.jpg</url>
            <title>Stories by Serban Marti on Medium</title>
            <link>https://medium.com/@marti.serban?source=rss-4dd540e1f305------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 08:52:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marti.serban/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[Revisiting NestJS & Prisma 7 w/ Deno 2.5]]></title>
            <link>https://blog.stackademic.com/revisiting-nestjs-prisma-7-w-deno-2-5-c905aea1fee5?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/c905aea1fee5</guid>
            <category><![CDATA[prisma]]></category>
            <category><![CDATA[deno]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Sat, 22 Nov 2025 19:12:06 GMT</pubDate>
            <atom:updated>2025-11-22T19:12:06.949Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qZfo4CZB1urHlrB9UliTww.png" /></figure><p>Last year, I wrote an article about <a href="https://medium.com/stackademic/using-nestjs-with-deno-2-0-861c1b73b90c">running NestJS on Deno 2.0</a>. It was an experiment to see how the two technologies played together. The results were mixed. It worked, but felt fragile. I hesitated to recommend it for real production apps back then.</p><p>Deno 2.5 is out now, bringing more stability. Prisma 7 also just arrived, with better Deno-specific support. It felt like the right time to give this stack another shot and write up a <a href="https://github.com/serbanmarti/deno2_nestjs_prisma7">new sample codebase</a>.</p><p>This post covers the new configuration using Deno 2.5 along with Prisma 7. Is the friction gone, or are we still dealing with compatibility hacks?</p><p>Before moving on, I recommend you read my previous article, as I won’t be going through every little configuration detail already mentioned there.</p><h4>Configuration changes</h4><p>As in the previous article, a configuration change is required to ensure things work correctly at runtime and in the IDE during development.</p><p>In deno.json we need to add the following:</p><pre>{<br>  ...<br>  &quot;compilerOptions&quot;: {<br>    &quot;experimentalDecorators&quot;: true,<br>    &quot;emitDecoratorMetadata&quot;: true<br>  }<br>}</pre><p>If experimentalDecorator is missing, you’ll most likely see errors in your IDE because it can&#39;t resolve the signatures of decorators commonly used in NestJS. Besides that, you’ll also likely see runtime errors like Uncaught SyntaxError.</p><p>If emitDecoratorMetadata is missing. Depending on how you structured your NestJS project/code, you’ll most likely see runtime errors where code isn&#39;t injected properly (the <a href="https://github.com/serbanmarti/deno2_nestjs_prisma7">sample GitHub repository</a> is such a case), leading to undefined properties.</p><h4>Using NestJS specifics</h4><p>You can keep your classic NestJS approach to structuring your project, using <a href="https://docs.nestjs.com/cli/libraries">libraries</a>, but you will have to create them manually to ensure they work correctly with Deno.</p><p>I’ve used libraries to configure Prisma for my <a href="https://github.com/serbanmarti/deno2_nestjs_prisma7">sample project</a>, so I’ll use this as an example of how to set one up.</p><p>In our deno.json configuration file, we’ll need to add a few things:</p><pre>{<br>  ...<br>  &quot;workspace&quot;: [&quot;./libs/prisma&quot;],<br>  &quot;fmt&quot;: {<br>    ...<br>    &quot;exclude&quot;: [&quot;./libs/prisma/generated&quot;]<br>  },<br>  &quot;lint&quot;: {<br>    ...<br>    &quot;exclude&quot;: [&quot;./libs/prisma/generated&quot;]<br>  }<br>}</pre><p>In workspace we add the path of the library we want to use in our code. This directory will contain both our client logic (together with a few small extras) and the auto-generated Prisma code from our schema.</p><p>For fmt and lint we add the auto-generated Prisma code path, so we don’t try to solve issues where we don’t need to.</p><p>Similar to how NestJS automatically creates a tsconfig file when generating new libraries, we’ll need to create a deno.json file inside the Prisma library root directory libs/prisma/deno.json.</p><pre>{<br>  &quot;name&quot;: &quot;@libs/prisma&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;exports&quot;: {<br>    &quot;./module&quot;: &quot;./prisma.module.ts&quot;,<br>    &quot;./service&quot;: &quot;./prisma.service.ts&quot;,<br>    &quot;./client&quot;: &quot;./extras/client.ts&quot;,<br>    &quot;./types&quot;: &quot;./extras/types.ts&quot;<br>  },<br>  &quot;lint&quot;: {<br>    &quot;exclude&quot;: [&quot;./generated&quot;],<br>    &quot;rules&quot;: {<br>      &quot;exclude&quot;: [&quot;no-slow-types&quot;]<br>    }<br>  },<br>  &quot;fmt&quot;: {<br>    &quot;exclude&quot;: [&quot;./generated&quot;]<br>  }<br>}</pre><p>We’ll need to repeat our fmt and lint configurations here as well, but also define the exports we’ll need to use as imports later on in our project code. In the next stage, we’ll discuss what each means/is used.</p><h4>Prisma 7</h4><p>Recently, Prisma released a new major version of its ORM, version 7. It brings a few configuration changes and even better Deno support.</p><p>The prisma.config.ts file:</p><pre>import &quot;dotenv/config&quot;;<br>import { defineConfig, env } from &quot;prisma/config&quot;;<br><br>export default defineConfig({<br>  schema: &quot;prisma/schema.prisma&quot;,<br>  migrations: {<br>    path: &quot;prisma/migrations&quot;,<br>  },<br>  datasource: {<br>    url: env(&quot;DATABASE_URL&quot;),<br>  },<br>});</pre><p>Not much seems to have changed in terms of this configuration file from v6, but we do now need to have the datasource URL defined here, and no longer in the schema.prisma file.</p><p>The schema.prisma file:</p><pre>generator client {<br>  provider = &quot;prisma-client&quot;<br>  output   = &quot;../libs/prisma/generated/client&quot;<br>}<br><br>datasource db {<br>  provider = &quot;postgresql&quot;<br>}<br><br>...<br>// Model definitions go here</pre><p><strong>Defining our Prisma service/client</strong></p><p>A regular v6 service/client implementation looked like this for me:</p><pre>@Injectable()<br>export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {<br>  constructor() {<br>    super({<br>      errorFormat: &#39;minimal&#39;,<br>    });<br>  }<br><br>  async onModuleInit() {<br>    await this.$connect();<br>  }<br><br>  async onModuleDestroy() {<br>    await this.$disconnect();<br>  }<br>}</pre><p>Now with v7, a slightly more complicated approach is required:</p><pre>@Injectable()<br>export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {<br>  private readonly pool: Pool;<br><br>  constructor() {<br>    const pool = new Pool({ connectionString: env(&quot;DATABASE_URL&quot;) });<br>    const adapter = new PrismaPg(pool);<br><br>    super({<br>      errorFormat: &quot;minimal&quot;,<br>      adapter,<br>    });<br><br>    this.pool = pool;<br>  }<br><br>  async onModuleInit() {<br>    await this.$connect();<br>  }<br><br>  async onModuleDestroy() {<br>    await this.$disconnect();<br>    await this.pool.end();<br>  }<br>}</pre><p>We now need to use a PostgreSQL adapter to define our DB connection. For our case here, we’ll use the default recommended pg driver with the @prisma/adapter-pg adapter.</p><p>When we run the deno run --allow-all prisma generate command, the auto-generated code will be created in our defined path. We’ll need access to a few things from there in other parts of our code, including when we define the Prisma service/client.</p><p>To do that, we can create an extra directory in our Prisma library folder. In my case, I went with extras. Inside, I created 2 TypeScript files: one for exporting the generated client and another for exporting the generated types.</p><p>If you look back at our deno.json file we created inside the Prisma library, you’ll see how everything ties together.</p><p>That’s basically it. You can see a full implementation in the <a href="https://github.com/serbanmarti/deno2_nestjs_prisma7">sample project on GitHub</a>. Now you can import the Prisma library/module/service into other parts of the project and start querying.</p><h4>Conclusions</h4><p>The most important question I’d ask myself after this trial is: “Would I use this in production?” My current answer: probably not.</p><p>Even though things have evolved quite a bit since last year, to the point where everything is working, the fact that I need to add hacky configurations to make things work in the first place is a turnoff.</p><p>I will, however, keep a much closer eye on it now, as I feel like it’s almost there.</p><p>I hope you found this article interesting and easy to understand, and that you’ll give Deno a try for anything else you’re building. It’s undoubtedly an exciting alternative to the classic Node.js.</p><p>Please do check out the <a href="https://github.com/serbanmarti/deno2_nestjs_prisma7">sample GitHub project</a> as well! It includes not only a fully working example but also niceties like using Docker to set up a complete local environment with migrations and seeding.</p><h3>A message from our Founder</h3><p><strong>Hey, </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>Sunil</strong></a><strong> here.</strong> I wanted to take a moment to thank you for reading until the end and for being a part of this community.</p><p>Did you know that our team run these publications as a volunteer effort to over 3.5m monthly readers? <strong>We don’t receive any funding, we do this to support the community. ❤️</strong></p><p>If you want to show some love, please take a moment to <strong>follow me on </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>LinkedIn</strong></a><strong>, </strong><a href="https://tiktok.com/@messyfounder"><strong>TikTok</strong></a>, <a href="https://instagram.com/sunilsandhu"><strong>Instagram</strong></a>. You can also subscribe to our <a href="https://newsletter.plainenglish.io/"><strong>weekly newsletter</strong></a>.</p><p>And before you go, don’t forget to <strong>clap</strong> and <strong>follow</strong> the writer️!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c905aea1fee5" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/revisiting-nestjs-prisma-7-w-deno-2-5-c905aea1fee5">Revisiting NestJS &amp; Prisma 7 w/ Deno 2.5</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Brussels Effect Goes Digital: How Europe’s AI Act Will Reshape Global Technology]]></title>
            <link>https://medium.com/@marti.serban/the-brussels-effect-goes-digital-how-europes-ai-act-will-reshape-global-technology-92307d996ff2?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/92307d996ff2</guid>
            <category><![CDATA[regulation]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[european-union]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 19:18:43 GMT</pubDate>
            <atom:updated>2025-07-13T19:18:43.381Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KhdYwzJf5HM5FArLqorWHQ.png" /></figure><h4><strong>The world’s first comprehensive AI regulation is already here, and tech giants need to comply. Here’s what it means for the future of artificial intelligence.</strong></h4><p>Picture this: You’re applying for a job, and an AI system scans your resume in milliseconds, deciding your fate before a human ever sees your application. Or imagine walking down a street where facial recognition cameras powered by artificial intelligence track your every move, building a digital profile of your daily life. Until recently, these scenarios existed in a regulatory gray area — a digital Wild West where innovation moved faster than legislation.</p><p>Not any more. On August 1, 2024, the European Union changed the game forever with the world’s first comprehensive artificial intelligence regulation: the EU AI Act. This landmark legislation doesn’t just affect the 27 EU member states — it’s poised to reshape how AI is developed and deployed globally, continuing Europe’s tradition of setting worldwide standards through what scholars call the “Brussels Effect.”</p><h3><strong>Why the EU AI Act Matters Beyond Europe</strong></h3><p>The EU AI Act represents more than just another piece of legislation. It’s a paradigm shift that recognizes a fundamental truth: artificial intelligence is too powerful and too pervasive to remain unregulated. Unlike the internet’s early days, when governments largely adopted a hands-off approach, the EU has chosen to be proactive rather than reactive.</p><p>The regulation’s extraterritorial scope means that any AI system whose output is used within the EU falls under its jurisdiction, regardless of where the system was developed. This means that a Silicon Valley startup, a Chinese tech giant, or an Indian AI company must all comply with EU rules if they want European customers. It’s GDPR for the AI age — and just as GDPR became the de facto global standard for data protection, the AI Act is positioned to do the same for artificial intelligence.</p><h3><strong>The Risk-Based Revolution: Four Tiers of AI Governance</strong></h3><p>What makes the EU AI Act particularly sophisticated is its risk-based approach. Rather than applying a one-size-fits-all regulatory framework, the legislation categorizes AI systems into four distinct risk levels, each with tailored requirements.</p><h4><strong>Unacceptable Risk: The Banned AI</strong></h4><p>At the top of the risk pyramid are AI applications so dangerous that they’re completely prohibited. These include systems that use subliminal techniques to manipulate behaviour, exploit vulnerable groups, or implement social scoring by governments. Perhaps most controversially, the Act bans real-time facial recognition in public spaces by law enforcement, with only narrow exceptions for serious crimes.</p><p>The ban also extends to AI systems that scrape facial images from the internet to build recognition databases and emotion-detecting AI in workplaces and schools (except for medical or safety purposes). These prohibitions take effect on February 2, 2025 — just months away.</p><h4><strong>High-Risk AI: The Heavily Regulated</strong></h4><p>The most complex category covers high-risk AI systems — those that could significantly impact people’s safety, health, or fundamental rights. This includes AI used in critical infrastructure, education, employment, law enforcement, and healthcare. These systems face the regulatory equivalent of a gauntlet: risk management systems, data governance requirements, technical documentation, human oversight mandates, and mandatory conformity assessments before market entry.</p><h4><strong>Limited Risk: The Transparent AI</strong></h4><p>AI systems that interact with humans — like chatbots — must clearly disclose their artificial nature. Similarly, AI-generated content like deepfakes must be labelled as synthetic. It’s a simple but powerful requirement: users have the right to know when they’re dealing with a machine.</p><h4><strong>Minimal Risk: The Free Zone</strong></h4><p>The vast majority of AI applications — from video game AI to spam filters — face no mandatory requirements, though voluntary compliance with codes of conduct is encouraged.</p><h3><strong>Industry Giants Need to Comply</strong></h3><p>The corporate response to the AI Act has been swift and telling. Major technology companies aren’t just preparing for compliance — they’re positioning themselves as leaders in responsible AI.</p><p>Microsoft has been particularly proactive, publishing comprehensive compliance frameworks and integrating EU AI Act assessment tools directly into their Purview platform. In January 2025, the company outlined their approach to “facilitating AI innovation while ensuring compliance through comprehensive governance.” Their partnership with Denmark to create an AI Act compliance blueprint demonstrates how seriously they’re taking the regulation.</p><p>OpenAI, despite facing early GDPR compliance challenges, published a detailed primer on the AI Act in July 2024, committing to work closely with EU authorities. The company’s response reflects a broader industry recognition that cooperation, not confrontation, is the path forward.</p><p>However, not everyone is enthusiastic about the compliance burden. Meta has voiced concerns about “incredibly high” compliance costs that could limit innovation — a sentiment echoed by many smaller companies lacking the resources of tech giants.</p><h3><strong>The Foundation Model Challenge</strong></h3><p>One of the AI Act’s most forward-thinking aspects is its treatment of general-purpose AI (GPAI) models — the foundation models that power applications like ChatGPT, Claude, and Gemini. The regulation recognizes that these powerful systems require special attention.</p><p>All GPAI providers must meet transparency obligations, including technical documentation and copyright compliance policies. But models with “systemic risk” — those requiring more than 1⁰²⁵ floating-point operations for training — face stricter requirements: model evaluations, systemic risk assessments, incident reporting, and enhanced cybersecurity measures.</p><p>This approach acknowledges a crucial reality: the most powerful AI systems aren’t just products — they’re digital infrastructure that underpins countless other applications.</p><h3><strong>Implementation: A Staggered Rollout</strong></h3><p>The EU AI Act’s implementation follows a carefully planned timeline that gives organizations time to adapt:</p><p>• <strong>February 2, 2025</strong>: Prohibited AI practices become illegal</p><p>• <strong>August 2, 2025</strong>: GPAI model requirements take effect</p><p>• <strong>August 2, 2026</strong>: Most high-risk system requirements apply</p><p>• <strong>August 2, 2027</strong>: Rules for AI safety components in products take effect</p><p>This staggered approach reflects the EU’s understanding that compliance isn’t just about checking boxes — it requires fundamental changes to how AI systems are designed, developed, and deployed.</p><h3><strong>The Enforcement Reality</strong></h3><p>The AI Act isn’t just regulatory theatre. With fines reaching up to €35 million or 7% of global annual turnover for the most serious violations, the financial stakes are enormous. A new European AI Office will oversee implementation, supported by national authorities in each member state.</p><p>These aren’t empty threats. The EU has already demonstrated its willingness to impose significant penalties under GDPR, and there’s every indication that AI Act enforcement will be equally robust.</p><h3><strong>Beyond Compliance: A New Era of AI Governance</strong></h3><p>The EU AI Act represents more than regulation — it’s a vision for how humanity should govern its most powerful technologies. By prioritizing fundamental rights, transparency, and human oversight, the Act embeds European values into the global AI ecosystem.</p><p>Critics argue that heavy regulation could stifle innovation and hand competitive advantages to less regulated jurisdictions. Supporters counter that sustainable AI development requires public trust, and trust requires accountability.</p><p>The reality is likely more nuanced. The AI Act may slow some forms of AI development while accelerating others — particularly those focused on safety, transparency, and human benefit. Just as automotive safety regulations didn’t kill the car industry but made it more responsible, AI regulation could drive innovation in new directions.</p><h3><strong>The Global Ripple Effect</strong></h3><p>As companies build EU-compliant AI systems, many will likely apply the same standards globally, rather than maintaining separate compliance frameworks for different markets. This “Brussels Effect” means that European AI governance principles could become the de facto global standard.</p><p>Other jurisdictions are already taking note. The United States is developing its own AI governance framework, while countries from Canada to Singapore are crafting AI regulations that show clear EU influence.</p><h3><strong>Looking Ahead: The Future of AI Governance</strong></h3><p>The EU AI Act marks the beginning, not the end, of AI governance evolution. As AI capabilities advance and new risks emerge, the regulation will likely require updates and refinements. The Act itself includes provisions for ongoing review and adaptation.</p><p>What seems certain is that the era of unregulated AI development is ending. The question isn’t whether AI will be governed, but how — and the EU AI Act provides a compelling answer. By balancing innovation with responsibility, competition with protection, and efficiency with human dignity, it offers a roadmap for harnessing AI’s benefits while managing its risks.</p><p>For technologists, policymakers, and citizens worldwide, the EU AI Act isn’t just European legislation — it’s a preview of the future of artificial intelligence. And that future, it seems, will be one where technology serves humanity, not the other way around.</p><h3>Sources and Further Reading</h3><p><a href="https://www.whitecase.com/insight-alert/white-case-launches-eu-ai-act-handbook">EU AI Act Handbook</a> — White &amp; Case, May 2025</p><p><a href="https://www.twobirds.com/en/insights/2024/global/european-union-artificial-intelligence-act-guide">European Union Artificial Intelligence (EU AI Act) Guide</a> — Bird &amp; Bird, Nov 2024</p><p><em>The EU AI Act represents one of the most significant technology regulations in decades. As implementation unfolds over the coming years, its impact will extend far beyond Europe’s borders, shaping how we develop, deploy, and live with artificial intelligence.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92307d996ff2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI’s Confidence Gap: We’re Building Our Future on a Foundation of Doubt]]></title>
            <link>https://medium.com/@marti.serban/ais-confidence-gap-we-re-building-our-future-on-a-foundation-of-doubt-58e3e413e3b3?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/58e3e413e3b3</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[workplace]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 05:56:47 GMT</pubDate>
            <atom:updated>2025-07-02T05:56:47.784Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-hBnSnt9-i4l4qBSn-I7A.png" /></figure><h4><strong>We’re adopting it faster than ever, but trust is plummeting. Here’s why.</strong></h4><p>The age of Artificial Intelligence isn’t coming. It’s here. From automating workflows in global corporations to assisting in healthcare, AI is being integrated into all aspects of our society at a speed that makes the internet’s early days look sluggish. A recent PwC report notes that nearly half of tech leaders say AI is already “fully integrated” into their company’s core business strategy.</p><p>And yet, we have a problem. A big one.</p><p>While we’re racing to adopt this world-changing technology, our trust in it is cratering. A comprehensive 2025 global study by KPMG and the University of Melbourne delivered a stark finding: <strong>54% of people are wary about trusting AI systems.</strong> Even more telling, the study revealed that since 2022 — just as tools like ChatGPT exploded into the public consciousness — overall trust in AI has declined while worry has increased.</p><p>This is the great paradox of our time: we are building our future on a technology we fundamentally do not trust. The hype is real, but so is the hesitation. This isn’t just a vague feeling of unease; it’s a rational response to a series of deep, unaddressed cracks in AI’s foundation. And unless we fix them, the full promise of AI may remain unreachable.</p><h4><strong>The Great Disconnect: More Code, Less Confidence</strong></h4><p>The trust deficit isn’t just a public perception issue; it’s a critical business threat. PwC predicts that the ROI for any AI initiative will ultimately depend on establishing Responsible AI. If customers, employees, and regulators don’t trust your AI, they won’t use it, fund it, or approve it.</p><p>So, why are we so sceptical? The data points to several core failures.</p><p>First, AI is often dangerously wrong. We’ve all seen the comical errors, but the stakes can be much higher. A staggering report highlighted by Keragon found that <strong>ChatGPT misdiagnosed 83 out of 100 paediatric medical cases.</strong> When the consequences of error are this significant, “move fast and break things” is not a viable strategy.</p><p>Second is the infamous “black box” problem. Many AI systems arrive at conclusions through processes that are opaque even to their creators. Dario Amodei, the CEO of leading AI firm Anthropic, admitted his team understands “maybe 3% of how they [AI models] work.” This isn’t just a technical curiosity; it’s a fundamental challenge to accountability. A report from Finance Watch explains that our legal and financial systems are built on the principle of causation — a clear link between an action and its consequence. AI, however, operates on correlation, detecting patterns in data without true understanding. When an AI denies someone a loan or flags them for fraud, who is responsible? If you can’t explain the “why,” you can’t establish accountability.</p><p>Third, the risks to privacy and security are no longer theoretical. The KPMG study found that nearly <strong>half of employees admit to uploading sensitive company information</strong> — financial, sales, or customer data — into public AI tools. This “shadow AI” usage creates massive vulnerabilities that organizations are only beginning to grapple with.</p><p>Finally, there’s the human element. A joint survey by McKinsey and the American Nurses Foundation found that nurses’ primary concern with AI wasn’t job loss, but the <strong>loss of human interaction (a top-three concern for 49%)</strong>. People are rightly worried that an over-reliance on AI will erode the essential human connections that define quality care, mentorship, and collaboration.</p><h4><strong>The Blueprint for Believable AI</strong></h4><p>The path forward isn’t to abandon AI, but to build it on a foundation of trust. The research consistently points to four pillars that are essential for closing the trust gap. The problem is, while most organizations acknowledge them, very few are implementing them effectively.</p><p><strong>1. Governance &amp; Responsible AI</strong></p><p>This is the operational blueprint for safety. Microsoft defines it as the processes, controls, and accountability structures for everything from data privacy to ethical development. This includes practices like “red teaming” (emulating cyber-attacks to find weaknesses) and adhering to principles like “Responsible by Design.”</p><p>• <strong>The Gap:</strong> A Deloitte survey found that a staggering <strong>35% of companies take no measures whatsoever to mitigate AI risks.</strong></p><p><strong>2. Explainability (XAI)</strong></p><p>This is the antidote to the black box. As a McKinsey report argues, trust comes from understanding. Explainable AI aims to make algorithmic decision-making transparent and understandable to different stakeholders, from a developer debugging a system to a customer who was denied a service.</p><p>• <strong>The Gap:</strong> While 40% of leaders see explainability as a key risk, <strong>only 17% are actively working to mitigate it.</strong></p><p><strong>3. Regulation &amp; Accountability</strong></p><p>The public is demanding guardrails. The Ipsos and KPMG studies found that <strong>70% of people believe AI regulation is necessary,</strong> yet only 43% think current laws are adequate. This isn’t about stifling innovation; it’s about creating a safe environment for it to flourish. This includes establishing clear legal frameworks for liability when AI systems cause harm — a challenge the Finance Watch report flags as critical.</p><p>• <strong>The Gap:</strong> Most jurisdictions are still in the early stages of designing and implementing meaningful AI regulation, leaving a vacuum of uncertainty.</p><p><strong>4. Human-in-the-Loop</strong></p><p>This pillar ensures that AI remains a tool to augment human intelligence, not replace it. It means designing systems where humans have the final say and can intervene, correct, or challenge AI-generated outputs. The nurses’ survey is a perfect example: their top demand (<strong>73%</strong>) to alleviate concerns was to have direct input into the design and optimization of AI tools.</p><p>• <strong>The Gap:</strong> While a powerful concept, the “human-in-the-loop paradox” exists. In some highly complex fields, the very reason for using AI is that humans can’t effectively monitor the data, making true oversight a profound challenge.</p><h4><strong>The Choice We Face</strong></h4><p>We stand at a crossroads. The evidence is clear: the current strategy of rapid, ungoverned AI adoption is eroding the very trust needed for its long-term success. The path of “hype-driven deployment” is leading to a future of powerful but brittle systems that people are reluctant to embrace.</p><p>The alternative is to deliberately and systematically build the pillars of trust. It requires leaders to move beyond viewing AI as just a tech initiative and treat it as a profound organizational and societal transformation. It means investing in governance as much as in algorithms, prioritizing transparency over speed, and designing systems with human well-being, not just efficiency, as the ultimate goal.</p><p>Trust is not a feature that can be added in a future update. It must be coded into the DNA of every AI system from the very beginning. The choice is ours: to continue building on a shaky foundation of hype and hope, or to do the hard work of creating an AI ecosystem that is not only intelligent, but trustworthy.</p><h4>Sources and Further Reading</h4><p><a href="https://www.hkdca.com/wp-content/uploads/2025/06/trust-attitudes-use-ai-kpmg.pdf">Trust, attitudes and use of artificial intelligence</a> — University of Melbourne &amp; KPMG International, April 2025</p><p><a href="https://www.hkdca.com/wp-content/uploads/2024/09/ai-trust-survey-deloitte.pdf">AI Trust Survey</a> — Deloitte, Q1 2024</p><p><a href="https://www.hkdca.com/wp-content/uploads/2024/09/public-trust-in-ai-ipsos.pdf">Public Trust in AI</a> — Ipsos, September 2024</p><p><a href="https://www.hkdca.com/wp-content/uploads/2025/03/ai-in-finance-how-to-trust-black-box.pdf">Artificial intelligence in finance: how to trust a black box? </a>— Finance Watch, March 2025</p><p><a href="https://www.mckinsey.com/capabilities/quantumblack/our-insights/building-ai-trust-the-key-role-of-explainability#">Building AI trust: The key role of explainability</a> — McKinsey &amp; Co, November 2024</p><p><a href="https://www.mckinsey.com/industries/healthcare/our-insights/the-pulse-of-nurses-perspectives-on-ai-in-healthcare-delivery#/">The pulse of nurses’ perspectives on AI in healthcare delivery</a> — McKinsey &amp; Co, October 2024</p><p><a href="https://www.pwc.com/us/en/tech-effect/ai-analytics/ai-predictions.html">2025 AI Business Predictions</a> — PwC, 2025</p><p><a href="https://arc.net/l/quote/dxlfddny">Building a foundation for AI success: Governance </a>— Susan Etlinger, Microsoft, March 2024</p><p><a href="https://www.keragon.com/blog/ai-in-healthcare-statistics">AI in healthcare statistics</a> — Keragon, June 2024 (updated June 2025)</p><p><a href="https://www.glideapps.com/blog/ai-stats-2025">Top 5 sources for AI stats in 2025</a> — Wren Noble, Glide, March 2025</p><p><em>The choice of how we integrate AI into our lives affects all of us. How are you seeing these issues of trust and transparency play out around you? I’d love to read your thoughts.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58e3e413e3b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Agentic Revolution: How AI is Learning to Think and Act Like Never Before]]></title>
            <link>https://medium.com/@marti.serban/the-agentic-revolution-how-ai-is-learning-to-think-and-act-like-never-before-7432d0e36c46?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/7432d0e36c46</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Thu, 26 Jun 2025 12:13:08 GMT</pubDate>
            <atom:updated>2025-06-26T12:13:08.270Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1aVY08UEjyacO3b2QM8gDA.png" /></figure><h4><em>From passive tools to autonomous teammates — the next chapter of artificial intelligence is already being written</em></h4><p>We’re witnessing a seismic shift in artificial intelligence that’s happening right under our noses. While most of us are still marvelling at ChatGPT’s ability to generate Studio Ghibli style images, a new breed of AI is quietly learning to do something far more profound: <strong>think, plan, and act autonomously</strong>.</p><p>Welcome to the age of <strong>Agentic AI</strong> — where artificial intelligence stops being a sophisticated calculator and starts becoming something closer to a digital colleague.</p><h4><strong>What Makes Agentic AI Different?</strong></h4><p>Traditional AI systems are like incredibly smart but passive assistants. You ask them a question, they give you an answer. You feed them data, they process it. But Agentic AI? It’s the difference between a calculator and a chess grandmaster who can see twenty moves ahead.</p><p>According to recent analysis from leading consulting firms BCG and McKinsey, Agentic AI systems possess three revolutionary capabilities that set them apart:</p><p><strong>1. They Observe Their Environment</strong></p><p>Unlike traditional AI that waits for input, agentic systems constantly monitor their surroundings — whether that’s market data, patient vitals, or customer behaviour patterns. They’re always “watching” and learning.</p><p><strong>2. They Plan Autonomously</strong></p><p>Using advanced language models, these systems can break down complex goals into actionable steps. Need to optimize a global marketing campaign? An agentic AI can devise a multistep strategy involving data analysis, content creation, and platform management — all without human micromanagement.</p><p><strong>3. They Take Action</strong></p><p>Here’s where it gets exciting: these systems don’t just recommend — they execute. They can update databases, send communications, make purchases, or adjust system parameters based on their analysis.</p><h4><strong>The Numbers Don’t Lie: A Market Explosion</strong></h4><p>The growth trajectory is staggering. The global Agentic AI market, valued at just $5.2 billion in 2024, is projected to explode to <strong>$196.6 billion by 2034</strong> — a compound annual growth rate of 43.8%. In healthcare alone, the market is expected to grow at 45.56% annually through 2030.</p><p>But these aren’t just projections. Real companies are already seeing transformative results:</p><p>• A consumer goods company reduced marketing campaign optimization from requiring six analysts per week to just one employee working with an AI agent</p><p>• A global bank cut customer service costs by <strong>10x</strong> using AI virtual agents</p><p>• Lenovo reported 15% productivity improvements in software engineering and double-digit gains in customer support</p><p>• Manufacturing companies are seeing up to 40% productivity increases in IT operations</p><h4><strong>The Anatomy of an AI Agent</strong></h4><p>Think of an agentic AI system as having five core components, much like a human worker:</p><p><strong>Memory</strong>: Both short-term (for immediate context) and long-term (for accumulated knowledge and experiences)</p><p><strong>Profile</strong>: Its role, goals, and behavioural patterns — essentially its “job description”</p><p><strong>Planning Module</strong>: The strategic thinking component that uses large language models to devise action plans</p><p><strong>Interfaces</strong>: The connections that allow it to observe its environment and interact with other systems</p><p><strong>Action Module</strong>: The hands and feet — the APIs and integrations that let it actually do things in the digital world</p><h4><strong>Real-World Applications That Are Already Here</strong></h4><p><strong>Healthcare: The AI Doctor’s Assistant</strong></p><p>Hospitals are deploying agentic AI systems that continuously monitor patient vital signs, predict potential complications, and automatically alert medical staff. These systems don’t just flag problems — they can adjust treatment protocols and coordinate care across multiple departments.</p><p><strong>Finance: The Autonomous Trader</strong></p><p>Financial institutions are using agentic AI for algorithmic trading that adapts strategies in real-time based on market volatility, news events, and economic indicators. Unlike traditional automated trading, these systems can reason through unprecedented market conditions.</p><p><strong>Customer Service: The Empathetic Agent</strong></p><p>E-commerce platforms are deploying AI agents that don’t just answer questions — they understand customer sentiment, adapt their communication style, and can autonomously resolve complex issues by coordinating across multiple business systems.</p><p><strong>Manufacturing: The Predictive Maintenance Expert</strong></p><p>Smart factories use agentic AI to predict equipment failures, automatically schedule maintenance, and optimize production workflows — all while learning from each interaction to improve future predictions.</p><h4><strong>The Technology Behind the Magic</strong></h4><p>The recent breakthroughs enabling this agentic revolution include:</p><p><strong>Advanced Reasoning Frameworks</strong>: Systems like ReAct (Reasoning and Action) that allow AI to think through problems step-by-step, and ReWOO (Reasoning Without Observation) that enables upfront planning to reduce computational costs.</p><p><strong>Tool Integration</strong>: Modern agentic systems can seamlessly interact with existing software tools, APIs, and databases — essentially giving them “hands” to manipulate the digital world.</p><p><strong>Memory Systems</strong>: Sophisticated memory architectures that allow agents to learn from experiences and maintain context across long-term interactions.</p><p><strong>Multi-Agent Coordination</strong>: Systems where multiple specialized AI agents work together, each with their own expertise, collaborating like a human team.</p><h4><strong>The Big Players Making Big Moves</strong></h4><p>The tech giants are racing to dominate this space:</p><p><strong>Microsoft</strong> announced Azure AI Agent Service and major updates to Copilot Studio, enabling businesses to build custom autonomous agents. Their Magentic-One system demonstrates how multiple AI agents can collaborate to solve complex tasks.</p><p><strong>OpenAI</strong> launched “Operator,” an AI agent powered by their new Computer-Using Agent (CUA) model that can actually control computers and perform tasks across different applications.</p><p><strong>Anthropic</strong> introduced “computer use” capabilities in Claude 3.5 Sonnet, allowing the AI to take control of computers to perform useful work — the first major AI model with this capability.</p><p><strong>Google</strong> is preparing “Jarvis,” an AI agent expected to revolutionize how we interact with web browsers and enterprise applications.</p><h4><strong>The Challenges We Must Navigate</strong></h4><p>This technological leap isn’t without its hurdles:</p><p><strong>The Trust Factor</strong>: Despite the capabilities, surveys indicate that even Gen Z users still prefer human interaction for complex customer service issues. Building trust in autonomous AI systems remains a critical challenge.</p><p><strong>Goal Alignment</strong>: Ensuring that AI agents pursue objectives that align with human values and intentions becomes exponentially more complex when the AI can act autonomously.</p><p><strong>Accountability</strong>: When an AI agent makes a decision that leads to negative consequences, who’s responsible? The developer, the deployer, or the user? Legal frameworks are still catching up.</p><p><strong>Security Risks</strong>: Autonomous AI systems present new attack vectors. If compromised, they could cause significant damage, especially in critical infrastructure.</p><h4><strong>What This Means for You</strong></h4><p>Whether you’re a business leader, developer, or simply someone trying to understand where technology is heading, the agentic AI revolution has implications:</p><p><strong>For Businesses</strong>: Start small with well-defined, bounded problems. Focus on areas where the cost of mistakes is low while you build trust and expertise. Companies that master human-AI collaboration early will have significant competitive advantages.</p><p><strong>For Workers</strong>: Rather than replacement, think augmentation. Agentic AI will handle routine, complex tasks, freeing humans to focus on creative, strategic, and interpersonal work. The key is learning to work alongside these digital colleagues.</p><p><strong>For Society</strong>: We need robust governance frameworks, ethical guidelines, and regulatory structures that can keep pace with technological advancement while fostering innovation.</p><h4><strong>The Road Ahead</strong></h4><p>We’re still in the early innings of the agentic AI revolution. Current systems excel in structured environments but struggle with truly open-ended, unpredictable scenarios. The next breakthroughs will likely come in:</p><p>• <strong>Enhanced adaptability</strong> through meta-learning and transfer learning</p><p>• <strong>Better goal alignment</strong> with human values through inverse reinforcement learning</p><p>• <strong>Improved scalability</strong> through decentralized architectures and federated learning</p><p>• <strong>Energy efficiency</strong> innovations to make deployment more sustainable</p><h4><strong>The Bottom Line</strong></h4><p>Agentic AI represents more than just another technological advancement — it’s a fundamental shift in how we think about artificial intelligence. We’re moving from AI as a tool to AI as a teammate, from reactive systems to proactive partners.</p><p>The companies, organizations, and individuals who understand this shift and prepare for it will thrive in the coming decade. Those who don’t risk being left behind by digital colleagues that never sleep, never tire, and continuously learn from every interaction.</p><p>The agentic revolution isn’t coming — it’s here. The question isn’t whether this technology will transform how we work and live, but how quickly we can adapt to work alongside our new AI colleagues.</p><p><em>The future of work isn’t human versus machine — it’s human with machine. And that future is arriving faster than most of us realize.</em></p><h4>Sources and Further Reading</h4><p><a href="https://www.bcg.com/capabilities/artificial-intelligence/ai-agents"><strong>AI Agents</strong></a> — Boston Consulting Group (BCG)</p><p><a href="https://www.mckinsey.com/~/media/mckinsey/featured%20insights/mckinsey%20explainers/what%20is%20an%20ai%20agent/what-is-an-ai-agent.pdf?shouldIndex=false"><strong>What is an AI agent?</strong></a> — McKinsey &amp; Company, March 2025</p><p><a href="https://www.ibm.com/think/topics/ai-agents"><strong>What Are AI Agents?</strong></a> — IBM</p><p><a href="https://www.mckinsey.com/~/media/mckinsey/business%20functions/mckinsey%20digital/our%20insights/why%20agents%20are%20the%20next%20frontier%20of%20generative%20ai/why-agents-are-the-next-frontier-of-generative-ai.pdf?shouldIndex=false"><strong>Why agents are the next frontier of generative AI</strong></a> — McKinsey &amp; Company, July 2024</p><p><a href="https://ieeexplore.ieee.org/document/10849561"><strong>Agentic AI: Autonomous Intelligence for Complex Goals — A Comprehensive Survey</strong></a> — Deepak Bhaskar Acharya, Karthigeyan Kuppan, and B. Divya, January 2025</p><p><a href="https://market.us/report/agentic-ai-market/"><strong>Agentic AI Market Size, Share, Trends</strong></a> — Market.Us, March 2025</p><p><em>What aspects of agentic AI do you find most exciting or concerning? How do you see this technology impacting your industry? Share your thoughts and join the conversation about our AI-augmented future.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7432d0e36c46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The ROI of AI: Why Most Companies Are Still Chasing Returns While Others Strike Gold]]></title>
            <link>https://medium.com/@marti.serban/the-roi-of-ai-why-most-companies-are-still-chasing-returns-while-others-strike-gold-e5be9a831e58?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5be9a831e58</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[investment]]></category>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 18:47:24 GMT</pubDate>
            <atom:updated>2025-06-19T18:47:24.416Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1pzwCo2kaSyAtmsdvIz3yA.png" /></figure><h4><em>A deep dive into the complex reality of artificial intelligence investments in 2025</em></h4><p>The artificial intelligence revolution promised to transform business overnight. Yet as we navigate through 2025, a stark paradox emerges: while some organizations are achieving spectacular returns on their AI investments, the majority are still struggling to demonstrate meaningful ROI. This isn’t just a story about technology — it’s about the fundamental challenge of turning cutting-edge innovation into measurable business value.</p><h4><strong>The Great AI Investment Surge</strong></h4><p>The numbers are staggering. According to recent industry surveys, <strong>70% of organizations plan to spend between $50–250 million</strong> on generative AI initiatives over the next year. Microsoft’s IDC-commissioned study reveals that businesses are achieving an impressive <strong>$3.70 return for every $1 invested</strong> in generative AI. Meanwhile, Goldman Sachs estimates that AI could automate <strong>25% of all work tasks</strong>, potentially raising U.S. productivity by 9%.</p><p>Yet here’s the paradox: despite these promising figures, <strong>only 31% of business leaders anticipate being able to evaluate ROI within six months</strong>, and remarkably, <strong>none report achieving it yet</strong> according to KPMG’s survey.</p><p>This disconnect reveals a fundamental truth about AI adoption in 2025: we’re witnessing a tale of two realities.</p><h4><strong>The Winners: What Success Actually Looks Like</strong></h4><p>Let’s start with the success stories because they’re both inspiring and instructive.</p><p><strong>PayPal’s cybersecurity transformation</strong> stands as a masterclass in AI ROI. By implementing AI-driven fraud detection systems, the company achieved an <strong>11% reduction in losses</strong> while nearly doubling their annual payment volumes from $712 billion to $1.36 trillion between 2019 and 2022. Their AI models can now be trained and deployed within 2–3 weeks, enabling rapid adaptation to new fraud patterns.</p><p>In healthcare, <strong>AI-powered radiology platforms</strong> are delivering a <strong>451% ROI over five years</strong>, jumping to <strong>791% when radiologist time savings are included</strong>. These systems aren’t just cutting costs — they’re enabling faster diagnoses and better patient outcomes.</p><p><strong>SS&amp;C Blue Prism’s Total Economic Impact study</strong> found organizations achieving a <strong>330% ROI with less than six months to payback</strong>, projecting <strong>73% business growth</strong> with an approximate value of $50.5 million over three years.</p><p>But perhaps most telling is the productivity revolution happening at the ground level. Companies successfully implementing AI report that <strong>45% have seen employee productivity at least double</strong>, with some experiencing even more dramatic improvements.</p><h4><strong>The Strugglers: Why Most AI Projects Fail</strong></h4><p>For every success story, there are cautionary tales. Gartner predicts that <strong>30% of generative AI projects will be abandoned after proof of concept by the end of 2025</strong>. The reasons are telling:</p><p><strong>Poor data quality</strong> tops the list, with <strong>85% of leaders citing it as their most significant challenge</strong>. AI is only as good as the data it’s trained on, yet most organizations discover too late that their data infrastructure isn’t ready for prime time.</p><p><strong>Technical debt accumulation</strong> presents another major hurdle. Forrester predicts that <strong>75% of technology leaders will face moderate to severe technical debt by 2026</strong> as rushed AI implementations create operational inefficiencies.</p><p>The <strong>adoption gap</strong> is equally problematic. While organizations are investing heavily in AI tools, <strong>only 24% of workers regularly use AI tools embedded in workflows</strong>. This suggests a fundamental disconnect between AI capability and practical implementation.</p><p>Consider the cautionary tale of <strong>Swell Investing</strong>, a robo-advisor that closed despite significant AI investments. The company struggled with unsustainable customer acquisition costs ($350 per customer initially, dropping to $150) and failed to achieve the scale necessary for profitability, accumulating only $35 million in assets under management across 15,000 clients before shuttering operations.</p><h4><strong>The ROI Measurement Challenge</strong></h4><p>Part of the problem lies in how organizations approach ROI measurement. Traditional financial metrics often fail to capture AI’s multifaceted benefits, leading to three critical mistakes:</p><p><strong>First, discounting uncertainty.</strong> Many organizations perform simplistic ROI calculations that fail to account for AI model errors or the messy reality of production environments. AI models rarely achieve 100% accuracy, and the cost of errors can be far-reaching.</p><p><strong>Second, point-in-time assessment.</strong> Companies often calculate ROI shortly after deployment, typically a few months post-implementation. This approach ignores the fact that machine learning models may degrade over time without proper maintenance.</p><p><strong>Third, treating projects individually.</strong> Organizations evaluate AI projects in isolation, rather than considering the collective impact and synergies of their entire AI portfolio.</p><h4><strong>The New ROI Framework: Beyond Traditional Metrics</strong></h4><p>Successful organizations are adopting a more nuanced approach to ROI measurement that distinguishes between “hard” and “soft” returns.</p><p><strong>Hard ROI</strong> includes quantifiable benefits like:</p><p>• <strong>Time savings</strong> through automation of repetitive tasks</p><p>• <strong>Productivity increases</strong> from enhanced decision-making</p><p>• <strong>Cost reductions</strong> through reduced headcount requirements</p><p>• <strong>Revenue growth</strong> from new AI-enabled services</p><p><strong>Soft ROI</strong> encompasses less tangible but equally important benefits:</p><p>• <strong>Enhanced customer experience</strong> through personalization</p><p>• <strong>Improved employee satisfaction</strong> and retention</p><p>• <strong>Increased business agility</strong> and competitive advantage</p><p>• <strong>Brand strengthening</strong> and market positioning</p><p>The most successful implementations focus on <strong>productivity over profitability</strong> as the primary metric, recognizing that operational efficiency gains typically precede direct financial returns.</p><h4><strong>The Leadership Factor: Why C-Suite Support Matters</strong></h4><p>One of the strongest predictors of AI ROI success is comprehensive C-suite sponsorship. Organizations with robust executive support are <strong>91% likely to report revenue increases of 6% or more</strong>, compared to those without such backing.</p><p>The data shows that when multiple C-suite members share responsibility for AI initiatives, organizations are more likely to report accelerated time-to-market, improved cost efficiency, and faster ROI realization. This isn’t just about budget approval — it’s about creating the organizational alignment necessary for transformative change.</p><h4><strong>The 2025 Reality: Strategic Patience Meets Tactical Urgency</strong></h4><p>As we progress through 2025, a clearer picture emerges of what separates AI winners from losers. Success requires balancing <strong>strategic patience</strong> with <strong>tactical urgency</strong> — investing in foundational capabilities while pursuing quick wins that build momentum and organizational confidence.</p><p>The most successful organizations are:</p><p>1. <strong>Focusing on data quality first</strong>, recognizing that poor data undermines even the most sophisticated AI models</p><p>2. <strong>Starting with high-impact use cases</strong> like customer service and employee productivity tools</p><p>3. <strong>Building AI-ready cultures</strong> through comprehensive change management and training</p><p>4. <strong>Adopting portfolio thinking</strong> rather than evaluating individual projects in isolation</p><p>5. <strong>Preparing for technical debt</strong> by investing in integration and maintenance capabilities</p><h4><strong>Looking Ahead: The Maturation of AI ROI</strong></h4><p>The AI ROI landscape is rapidly maturing. While immediate financial returns remain elusive for many organizations, the strategic imperative is becoming clearer. Companies that invest now in the right foundational capabilities — data infrastructure, workforce readiness, and systematic measurement frameworks — will be positioned to capture the transformative potential that leading organizations are already demonstrating.</p><p>The paradox of AI ROI in 2025 isn’t really a paradox at all. It’s a reflection of a technology and market in transition, where early adopters who approach AI strategically are pulling ahead while those chasing quick fixes struggle to demonstrate value.</p><p>The question isn’t whether AI will deliver ROI — the evidence is mounting that it will. The question is whether your organization will be among those that figure out how to capture that value systematically and sustainably.</p><p>As one executive from a leading transportation technology company noted: “Getting AI to work at an enterprise scale is very hard, but I’m finally seeing some signs of it. I am much more optimistic than before. Over the next two to three years, we’re going to see hundreds of millions of dollars of benefits.”</p><h4>Sources and Further Reading</h4><p><a href="https://tech-stack.com/blog/roi-of-ai/"><strong>Measuring the ROI of AI: Key Metrics and Strategies</strong></a> — Anton Ivanchenko, Techstack, August 2024</p><p><a href="https://www.blueprism.com/resources/blog/measuring-ai-investment-roi-ai/"><strong>Measuring AI Investment: The ROI for AI</strong></a> — Alexis Veenendaal, Blue Prism, February 2025</p><p><a href="https://services.google.com/fh/files/misc/the_roi_of_generative_ai.pdf"><strong>The ROI of Gen AI</strong> </a>— Google, September 2024</p><p><a href="https://www.morganstanley.com/insights/articles/ai-monetization-race-to-roi-tmt"><strong>AI Earns Its Keep</strong></a> — Morgan Stanley, March 2025</p><p><a href="https://the-cfo.io/2025/01/17/the-roi-puzzle-of-ai-investments-in-2025/"><strong>The ROI puzzle of AI investments in 2025</strong></a> — Marina Mouka, The CFO, January 2025</p><p><a href="https://www.pwc.com/us/en/tech-effect/ai-analytics/artificial-intelligence-roi.html"><strong>Solving AI’s ROI problem. It’s not that easy.</strong></a> — Anand Rao, PwC, July 2021</p><p><a href="https://www.sandtech.com/insight/a-practical-guide-to-measuring-ai-roi/"><strong>From Investment to Impact: A Practical Guide to Measuring AI ROI</strong></a> — Asong Suh, Sand Technologies, January 2025</p><p><a href="https://www.gartner.com/en/newsroom/press-releases/2024-07-29-gartner-predicts-30-percent-of-generative-ai-projects-will-be-abandoned-after-proof-of-concept-by-end-of-2025"><strong>Gartner Predicts 30% of Generative AI Projects Will Be Abandoned After Proof of Concept By End of 2025</strong></a> — Gartner, July 2024</p><p><em>The AI ROI revolution is here. The only question is whether you’ll be part of it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5be9a831e58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Dawn of Superagency: Why AI Won’t Replace Us — It Will Amplify Us]]></title>
            <link>https://medium.com/@marti.serban/the-dawn-of-superagency-why-ai-wont-replace-us-it-will-amplify-us-f8c56b86a22a?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8c56b86a22a</guid>
            <category><![CDATA[work]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[innovation]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 08:59:15 GMT</pubDate>
            <atom:updated>2025-06-10T08:59:15.589Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nUc8dQNdU6l9tUHp4Q6CQ.png" /></figure><h3><strong>The Dawn of Superagency: Why AI Won’t Replace Us — It Will Amplify Us</strong></h3><h4><em>How artificial intelligence is creating a new era of human potential, not human obsolescence.</em></h4><p>We’re living through one of those rare historical moments when everything changes. The printing press. The steam engine. The internet. And now, artificial intelligence. But unlike previous technological revolutions that primarily automated physical labour or improved access to information, AI is doing something unprecedented: it’s amplifying human intelligence itself.</p><p>This isn’t just another tech trend. It’s the emergence of what LinkedIn co-founder Reid Hoffman calls “superagency” — a state where AI doesn’t replace human capability, but exponentially enhances it. And the early evidence suggests we’re not heading toward a dystopian future of mass unemployment, but rather toward an era of unprecedented human potential.</p><h4><strong>The Superagency Revolution Is Already Here</strong></h4><p>While people debate AI’s future impact, something remarkable is happening in workplaces around the world. According to new research from McKinsey &amp; Co, employees aren’t waiting for permission — they’re already using AI tools three times more than their leaders realize. Nearly half expect AI to transform at least 30% of their work within the next year.</p><p>This isn’t the story of fearful workers resisting change. It’s the story of human ingenuity finding ways to collaborate with machines to achieve more than either could alone.</p><p>Consider what’s happening right now: A marketing manager uses AI to generate dozens of campaign concepts in minutes, then applies human judgment to select and refine the best ones. A software engineer leverages AI to write boilerplate code, freeing up mental energy for complex architectural decisions. A researcher uses AI to synthesize thousands of papers, then applies human insight to identify novel connections.</p><p>In each case, the human isn’t being replaced — they’re being amplified.</p><h4><strong>Beyond the Automation Anxiety</strong></h4><p>The conventional narrative about AI focuses on job displacement. Yes, the World Economic Forum projects 92 million jobs will be displaced by 2030. But here’s what often gets buried in the headlines: they also project 170 million new jobs will be created.</p><p>This isn’t just creative destruction — it’s creative evolution. AI is creating entirely new categories of work that didn’t exist before.</p><ul><li>AI trainers who teach machines to understand human nuances.</li><li>AI ethicists who ensure systems remain fair and transparent.</li><li>Human-AI collaboration specialists who design workflows that optimize both human creativity and machine efficiency.</li></ul><p>The pattern isn’t replacement; it’s augmentation. AI handles the routine, the repetitive, the computationally intensive. Humans focus on the creative, the strategic, the emotionally intelligent.</p><h4><strong>The Trust Factor: Why Humans Still Lead</strong></h4><p>Here’s a surprising finding from the McKinsey research: 71% of employees trust their employers more than universities, tech companies, or startups to deploy AI responsibly. This trust isn’t misplaced — it reflects something profound about human judgment that no algorithm can replicate.</p><p>Humans understand context in ways that AI cannot. We grasp the subtle implications of decisions, the unspoken cultural dynamics, the ethical nuances that emerge in real-world applications. AI can process vast amounts of data and identify patterns, but humans provide the wisdom to interpret what those patterns mean and how they should be applied.</p><p>This is why the most successful AI implementations aren’t fully automated systems — they’re human-AI partnerships where each party contributes their unique strengths.</p><h4><strong>The Millennial Advantage</strong></h4><p>Interestingly, the research reveals that millennials aged 35–44 are emerging as the superagency generation. They report the highest levels of AI expertise (62% compared to 22% of baby boomers) and are naturally positioned as change champions in their organizations.</p><p>This makes sense. Millennials came of age during the internet revolution, learned to adapt to smartphones, and now find themselves in management positions just as AI is transforming work. They’re digital natives who understand both the potential and the pitfalls of new technology.</p><p>They’re also the generation most likely to see AI as a collaborative partner rather than a threatening replacement. Having grown up with technology as an extension of human capability, they intuitively understand the superagency concept.</p><h4><strong>The Speed vs. Safety Balance</strong></h4><p>One of the most fascinating aspects of the current AI moment is how organizations are navigating the tension between moving fast and staying safe. Nearly half of C-suite leaders say their companies are developing AI tools too slowly, yet employees’ top concerns are cybersecurity, accuracy, and privacy.</p><p>This isn’t a contradiction — it’s a recognition that speed and safety aren’t mutually exclusive. The companies that will thrive in the AI era are those that can move quickly while building robust safeguards. They’re the ones creating what Hoffman calls “responsible innovation” — pushing boundaries while maintaining human oversight and ethical guardrails.</p><h4><strong>What Superagency Looks Like in Practice</strong></h4><p>Superagency isn’t a distant future concept — it’s emerging now in countless small ways:</p><p>• <strong>Creative professionals</strong> use AI to generate initial concepts, then apply human taste and cultural understanding, refining them into compelling final products.</p><p>• <strong>Doctors</strong> leverage AI to analyse medical images and suggest diagnoses, while applying human empathy and clinical judgment to treat the whole patient.</p><p>• <strong>Teachers</strong> use AI to personalize learning materials for each student, while providing the human connection and motivation that inspire real learning.</p><p>• <strong>Entrepreneurs</strong> employ AI to analyse market trends and generate business ideas, while using human intuition to identify which opportunities are worth pursuing.</p><p>In each case, the result isn’t human replacement but human enhancement. People become more capable, more creative, more impactful.</p><h4><strong>The Leadership Challenge</strong></h4><p>The biggest barrier to realizing superagency isn’t technological — it’s organizational. The research by McKinsey &amp; Co found that only 1% of companies consider themselves “mature” in AI deployment, despite 92% planning to increase investments.</p><p>The problem isn’t employee readiness (they’re already using AI) or technological capability (the tools are rapidly improving). It’s leadership alignment and strategic vision.</p><p>The companies that will win in the AI era are those whose leaders can envision and execute transformational change, not just incremental improvement. They’re the ones asking not “How can AI make our current processes 10% more efficient?” but “How can AI enable us to solve problems we couldn’t solve before?”</p><h4><strong>The Human Future</strong></h4><p>As we stand at this inflection point, it’s worth remembering that every major technological revolution has ultimately expanded human potential, rather than diminishing it. The printing press didn’t eliminate storytellers — it created a world where more stories could be told to more people. The internet didn’t replace human connection — it enabled new forms of global collaboration and community.</p><p>AI won’t replace human intelligence — it will amplify it in ways we’re only beginning to understand.</p><p>The future isn’t about humans versus machines. It’s about humans with machines, creating possibilities that neither could achieve alone. It’s about superagency — the extraordinary potential that emerges when human creativity, judgment, and wisdom combine with AI’s computational power and pattern recognition.</p><p>The question isn’t whether this future will arrive. It’s already here. The question is whether we’ll embrace it with the boldness and wisdom it deserves.</p><h4><strong>Sources and Further Reading/Listening</strong></h4><p><a href="https://www.mckinsey.com/capabilities/mckinsey-digital/our-insights/superagency-in-the-workplace-empowering-people-to-unlock-ais-full-potential-at-work"><strong>Superagency in the Workplace: Empowering People to Unlock AI’s Full Potential</strong></a><strong> </strong>— McKinsey &amp; Company, January 2025</p><p><a href="https://www.superagency.ai/"><strong>Superagency: What Could Possibly Go Right with Our AI Future</strong></a><strong> </strong>—<strong> </strong>Reid Hoffman and Greg Beato, January 2025</p><p><a href="https://www.washingtonpost.com/washington-post-live/2025/02/05/futurist-superagency/"><strong>Reid Hoffman on Human Agency in an AI-Powered Future</strong></a><strong> </strong>—<strong> </strong>Washington Post Live, February 2025</p><p><a href="https://www.econtalk.org/why-ai-is-good-for-humans-with-reid-hoffman/"><strong>Why AI Is Good for Humans (EconTalk Podcast)</strong></a><strong> </strong>—<strong> </strong>Reid Hoffman with Russ Roberts, January 2025</p><p><a href="https://www.generalist.com/p/how-ai-will-enhance-human-potential-reid-hoffman"><strong>How AI Will Enhance Human Potential, Not Replace It</strong></a><strong> </strong>—<strong> </strong>The Generalist, April 2025</p><p><a href="https://time.com/charter/7212218/reid-hoffman-ai-superagency-linkedin/"><strong>LinkedIn Co-founder Reid Hoffman Believes AI Agents Will Be an Extension of You</strong></a><strong> </strong>—<strong> </strong>Time, February 2025</p><p><a href="https://www.weforum.org/publications/the-future-of-jobs-report-2025/"><strong>Future of Jobs Report 2025</strong></a><strong> </strong>—<strong> </strong>World Economic Forum, January 2025</p><p><a href="https://podcasts.apple.com/ro/podcast/possible/id1677184070"><strong>Reid Hoffman &amp; Aria Finger Podcast</strong></a><strong> </strong>— Apple Podcasts</p><p><em>The AI revolution is happening now, and it’s more human than you think. The companies and individuals who recognize this will be the ones who shape the future, rather than simply react to it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8c56b86a22a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NestJS WebSockets: Authentication, Authorization & Pipes]]></title>
            <link>https://blog.stackademic.com/nestjs-websockets-authentication-authorization-pipes-f18605e3c393?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/f18605e3c393</guid>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 21:08:58 GMT</pubDate>
            <atom:updated>2025-01-27T05:51:49.588Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QOmXKdU-VSWxTrd3FmkFag.png" /></figure><p>I’ve been wanting to try out and build a NestJS API that is able to transmit real-time data to clients for a few months now. The specific situation I had in mind was related to a project I’m working on, where clients have their own resources, and only they have access to them. I wanted to give them an option to view some of those resources in real-time, as and when they are updated.</p><p>Since I’ve written a number of <a href="https://medium.com/@marti.serban">articles</a> around NestJS already, that’s what I’m continuing here with as well. NestJS, WebSockets and techniques to auth and validate requests.</p><p>As always, this article comes bundled with a full implementation example, which you can find and use over on my <a href="https://github.com/serbanmarti/nestjs-websockets-example">GitHub page</a>. I won’t be going through every single detail over here, just the main sections we need to cover to make this work.</p><h4>TLDR WebSockets</h4><p><a href="https://en.wikipedia.org/wiki/WebSocket">The WebSocket protocol enables full-duplex interaction between a client and a server, with lower overhead than alternatives such as HTTP polling, facilitating real-time data transfer to and from the server.</a></p><h3>Prerequisites</h3><p>To get started, we need to install a few extra packages that allow us to implement WebSockets and the surounding features:</p><pre>yarn add @nestjs/websockets @nestjs/platform-socket.io socket.io zod</pre><h3>Building the Gateway</h3><p>This is where we’ll construct our WebSocket server, which is our main entrypoint. In Nest, a <a href="https://docs.nestjs.com/websockets/gateways">gateway</a> is simply a class annotated with @WebSocketGateway() decorator.</p><p>We’ll build a generic gateway, and name it events. We start the process easily by running:</p><pre>nest g gateway events</pre><p>We’ll get a new gateway ready to go that looks like this:</p><pre>@WebSocketGateway()<br>export class EventsGateway {<br>  @SubscribeMessage(&#39;message&#39;)<br>  handleMessage(client: any, payload: any): string {<br>    return &#39;Hello world!&#39;;<br>  }<br>}</pre><p>At this stage, you can use a tool like Postman to create a Socket.IO connection to your API (e.g. localhost:3000), and send anything to the message event name, as well as listen back to the same event name, and see if you get a response.</p><h3>Authentication</h3><p>Now that we have a simple server running, we’re going to immediately want to configure authorization, before anything else gets more complicated. We’ll start off with a new auth module:</p><pre>nest g module auth</pre><p>We’re going to want to create a <a href="https://docs.nestjs.com/websockets/guards">Guard</a> and a Socket.IO middleware. Normally, the guard should suffice, but they don’t work exactly like we’d need them to for WebSockets in NestJS, and as such, we’re doing both, to ensure we’re protected.</p><h4>Auth Guard</h4><p>For the sake of simplicity, in this article (and GitHub example) I’m not going to build something very extensive or even that safe for that matter. It’ll be up to you to add something more robust like JWT.</p><p>We can construct a new file in our auth module, call it socket.guard.ts. This is the code we need for it:</p><pre>// Hardcoded user tokens for demonstration purposes<br>const VALID_USER_TOKENS = new Map&lt;string, { id: string }&gt;([<br>  [&#39;valid-token-1&#39;, { id: &#39;user_1&#39; }],<br>  [&#39;valid-token-2&#39;, { id: &#39;user_2&#39; }],<br>  [&#39;valid-token-3&#39;, { id: &#39;user_3&#39; }],<br>]);<br><br>export class SocketGuard implements CanActivate {<br>  canActivate(context: ExecutionContext): boolean | Promise&lt;boolean&gt; | Observable&lt;boolean&gt; {<br>    if (context.getType() !== &#39;ws&#39;) {<br>      return false;<br>    }<br><br>    const socket = context.switchToWs().getClient&lt;Socket&gt;();<br>    if (!SocketGuard.validateToken(socket)) {<br>      throw new WsException(&#39;Unauthorized&#39;);<br>    }<br><br>    return true;<br>  }<br><br>  static validateToken(socket: Socket): boolean {<br>    const headerToken = socket.handshake.headers.authorization;<br>    const authToken = socket.handshake.auth.token;<br><br>    const user = VALID_USER_TOKENS.get(headerToken || &#39;&#39;) || VALID_USER_TOKENS.get(authToken);<br><br>    if (user !== undefined) {<br>      socket.data.userId = user.id;<br>      return true;<br>    }<br><br>    return false;<br>  }<br>}</pre><p>Our main point of interest here is the validateToken function, where we take in data either from the request headers or the auth object of the socket connection. We then check that data (tokens) against a source of truth, and if they’re good, we return a positive response. Otherwise… bad luck, try again.</p><p>If it’s a success, we also add the user ID in the socket data, to be used later down the line.</p><h4>Socket.IO Middleware</h4><p>This middleware is what is actually going to be doing the auth work for us (as mentioned previously, Guards are unreliable here). The implementation is really simple, and we’re going to make use of the same validateToken function from above.</p><p>This is what the middleware needs to look like:</p><pre>type SocketIoMiddleware = {<br>  (socket: Socket, next: (err?: any) =&gt; void): void;<br>};<br><br>export const SocketAuthMiddleware: SocketIoMiddleware = (socket, next) =&gt; {<br>  if (!SocketGuard.validateToken(socket)) {<br>    return next(new WsException(&#39;Unauthorized&#39;));<br>  }<br>  return next();<br>};</pre><h4>Adding Auth to the Gateway</h4><p>Now that we have the Guard and Middleware ready, we’re going to add them to our Gateway. Here’s what it needs to look like now:</p><pre>@WebSocketGateway()<br>@UseGuards(SocketGuard)<br>export class EventsGateway implements OnGatewayInit&lt;Server&gt; {<br>  afterInit(server: Server): void {<br>    server.use(SocketAuthMiddleware);<br>  }<br><br>...<br>}</pre><p>For the Guard, we make use of the UseGuards() decorator, and feed it the guard we built.</p><p>For the Middleware, we make sure that our EventsGateway class implements the OnGatewayInit interface, of type Server coming from Socket.IO. This forces us to implement the afterInit function, where we’ll tell our WebSocket server to make use of our middleware.</p><p>And that’s it for auth. If you now try to connect again to your sever using Postman, you’ll see that you get an immediate error response, telling the client they are not authenticated. To make it work again, Authorization header with a correct token in the value, and see it working like a charm. (Postman only allows for headers to be added, not actual WebSocket auth tokens, as of writing this)</p><h3>Authorization</h3><p>To showcase how this will work, we’re going to need an actual “subscribed” function where we can handle it. Keeping in tone with what I initially mentioned about my work, clients having their own resources, I’m going to create a function/event through which they can subscribe to see updates on a “project”. Again, to keep this example simple, we’re hardcoding some things, similarly to the authentication section.</p><p>Here’s the function (added in the gateway class), as well as the hardcoded permissions:</p><pre>// Hardcoded user/project permissions for demonstration purposes<br>const USER_PROJECT_PERMISSIONS = new Map&lt;string, string[]&gt;([<br>  [&#39;user_1&#39;, [&#39;project_one&#39;]],<br>  [&#39;user_2&#39;, [&#39;project_one&#39;, &#39;project_two&#39;, &#39;project_three&#39;]],<br>  [&#39;user_3&#39;, [&#39;project_three&#39;]],<br>]);<br><br>@SubscribeMessage(&#39;join_project&#39;)<br>handleJoinProject(<br>  @MessageBody(new ZodValidationPipe(JoinProjectSchema)) payload: JoinProject,<br>  @ConnectedSocket() client: Socket,<br>): WsResponse&lt;string&gt; {<br>  // Get the user ID from the client data<br>  const userId: string | undefined = client.data.userId;<br>  if (userId === undefined) {<br>    throw new WsException(&#39;Unauthorized&#39;); // This should never happen<br>  }<br><br>  // Check if the user has permissions to join the project<br>  if (!USER_PROJECT_PERMISSIONS.get(userId)?.some((id) =&gt; id === payload.projectId)) {<br>    throw new WsException(&#39;Project not found&#39;);<br>  }<br><br>  // Join the project room<br>  client.join(payload.projectId);<br><br>  return { event: &#39;join_project&#39;, data: `You have joined ${payload.projectId}!` };<br>}</pre><p>A client can send a join_project message, with a payload we’ll discuss in the next topic, with the purpose of joining a room designated for that project.</p><p>Before that happens though, we do any checks we need to validate permissions. Depending on your implementation of the Authentication section, this part could be built in a smarter way, where you don’t need to go “outside” (e.g. a DB) to fetch permissions on each incoming message.</p><p>We make use of WsException to return valid errors that the client can interpret and handle/display.</p><h3>Pipes</h3><p>As you may have noticed in the code snippet above, we make use of Pipes to validate the incoming payload.</p><pre>@MessageBody(new ZodValidationPipe(JoinProjectSchema)) payload: JoinProject</pre><p>We’re able to do this with the help of zod. First step, is to create our custom pipe:</p><pre>@Injectable()<br>export class ZodValidationPipe implements PipeTransform {<br>  constructor(private schema: Schema) {}<br><br>  transform(value: any) {<br>    try {<br>      this.schema.parse(value);<br>    } catch (error) {<br>      throw new WsException({<br>        message: &#39;Validation failed&#39;,<br>        errors: (error as ZodError).errors,<br>      });<br>    }<br>    return value;<br>  }<br>}</pre><p>This is a reusable implementation that can be used in any message handler you need. Next up, we build our zod schema and TS type, to be used in the implementation:</p><pre>const JoinProjectSchema = z.object({<br>  projectId: z.string(),<br>});<br><br>type JoinProject = z.infer&lt;typeof JoinProjectSchema&gt;;</pre><p>With all these put together, if the client tries to send an invalid message payload to our server/handler, they will be met with an exception/error.</p><h3>Wrapping up</h3><p>To finish out this example, we’re going to need the server to actually send some updates to our clients, which have joined some project rooms. Keeping in tone with simplicity, we add a function in our gateway that sends a message to all our defined projects, with the exact date &amp; time, on the chat message.</p><pre>sendGlobalMessages(): void {<br>    this.server.to(&#39;project_one&#39;).emit(&#39;chat&#39;, `Hello, project_one! Time is -- ${new Date().toISOString()} --`);<br>    this.server.to(&#39;project_two&#39;).emit(&#39;chat&#39;, `Hello, project_two! Time is -- ${new Date().toISOString()} --`);<br>    this.server.to(&#39;project_three&#39;).emit(&#39;chat&#39;, `Hello, project_three! Time is -- ${new Date().toISOString()} --`);<br>  }</pre><p>Similarly, you can build functions that are able to send specific pieces of data/types to the clients, when new data is available.</p><p>I hope you found this guide and example useful for your needs, and that you’re left with some valuable information on how to tackle WebSockets with NestJS now. Don’t forget to also check out the full code example on my <a href="https://github.com/serbanmarti/nestjs-websockets-example">GitHub page</a>. Happy coding!</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://cofeed.app/"><strong>Check out CoFeed, the smart way to stay up-to-date with the latest in tech</strong></a> <strong>🧪</strong></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f18605e3c393" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/nestjs-websockets-authentication-authorization-pipes-f18605e3c393">NestJS WebSockets: Authentication, Authorization &amp; Pipes</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using NestJS with Deno 2.0]]></title>
            <link>https://blog.stackademic.com/using-nestjs-with-deno-2-0-861c1b73b90c?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/861c1b73b90c</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[deno]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Sun, 27 Oct 2024 09:09:25 GMT</pubDate>
            <atom:updated>2024-10-28T02:51:34.604Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0NcbtZKpPYsLfNWrHFtQTw.png" /></figure><p>Recently, version 2.0 of Deno was announced and released, bringing numerous improvements and new features with it. This sparked a big interest from me to try it out, see what it can do, and how it compares to just using the standard Node.js.</p><p>In my trials, I wanted to also wanted to give NestJS (my favourite JS framework as of late) a go. This article is meant as a quick run-through of how to make it work (and, as you’d expect from me, with a full example), what sort of issues I encountered and find out if I’d choose to use it in a production environment.</p><p>Disclaimer: NestJS and all its sub-packages, along with almost everything else out there for that matter, aren’t built with support for Deno, and will still run as NPM packages through Node.js compatibility, as of the time of writing this. In this example, I’m trying to build the project in as close of a Deno-only style as possible.</p><h3>Setting up the project</h3><h4>Deno 2.0</h4><p>Since this is a new piece of software, you’ll more than likely not have it installed on your machine already. The installation steps are fairly easy, and you can follow your specific cases through the official documentation <a href="https://docs.deno.com/runtime/getting_started/installation/">here</a>.</p><h4>Creating the project</h4><p>Using the Deno CLI, we can create a new project using the following command:</p><pre>deno init nestjs_deno</pre><p>The above creates the nestjs_deno directory for you, with 3 starter files. If you already have a directory for your project, you can also cd into it and instead run:</p><pre>deno init .</pre><h4>Immediate configuration changes</h4><p>Firstly, since we’re using CommonJS in this project, Deno expects that dependencies will be installed manually and a node_modules directory will be present. It’s best we set &quot;nodeModulesDir&quot;: &quot;auto&quot; in our deno.json to ensure that. When installing our packages, we will then see the classic directory show up in our project.</p><p>Secondly, IDEs don’t yet fully support Deno, and some things, such as decorators, will display errors. To remove that issue, we need to add the following in our deno.json config:</p><pre>{<br>  ...<br>  &quot;compilerOptions&quot;: {<br>    &quot;experimentalDecorators&quot;: true<br>  }<br>}</pre><h4>Adding packages (dependencies)</h4><p>A note before going further: for packages that (preinstall/install/postinstall) scripts, we need to also add the --allow-scripts flag when running our commands, to allow these to run.</p><p>We’re going to add the 3 basic packages we need to get something up and running:</p><pre>deno add --allow-scripts npm:@nestjs/core npm:@nestjs/common npm:@nestjs/platform-express  </pre><h3>Adding some code</h3><p>Now that’ve completed setting up what we require for a simple NestJS project, it’s time to add some actual code. At this stage, things should be exactly as you’d do it in any regular Node.js environment.</p><p>Here’s a sample we can work with:</p><pre>import { NestFactory } from &quot;@nestjs/core&quot;;<br>import { Controller, Get, Module } from &quot;@nestjs/common&quot;;<br><br>@Controller()<br>class IndexController {<br>  @Get()<br>  getIndex() {<br>    return &quot;Hello World!&quot;;<br>  }<br>}<br><br>@Module({ controllers: [IndexController] })<br>class AppModule {}<br><br>const app = await NestFactory.create(AppModule);<br>app.listen(3000);</pre><p>Create a src/main.ts directory &amp; file, and save that code there.</p><h3>Running it</h3><p>All that’s left to do is run it. We need to go to our deno.json file again and add (or update) the tasks → dev command, as follows:</p><pre>{<br>  &quot;tasks&quot;: {<br>    &quot;dev&quot;: &quot;deno run --watch --allow-read --allow-env --allow-net src/main.ts&quot;<br>  },<br>}</pre><p>This will:</p><ul><li>run our main.ts file</li><li>watch for any changes and restart the process</li><li>give the necessary permissions to the process to run properly (file system, environment, and network)</li></ul><p>That’s it! We’ve got a running NestJS project, under the Deno runtime.</p><p>Going further, you can have a look at how to configure your environment, IDE to be more specific, with support for Deno and all its CLI commands that are available, such as fmt and lint.</p><p>You can also check out a more comprehensive project example on my <a href="https://github.com/serbanmarti/deno2_nestjs_example">GitHub</a>, where you’ll see how to set it up to run in Docker and how to compile your code into a runnable binary.</p><h3>Fair warning</h3><p>Whilst most of what you’ll need to do, projects you create, can and will fully run, this is definitely not “production ready”. There are many unknowns as to what might fail within what you’re doing. One such case you can check in running the Dockerized version of the <a href="https://github.com/serbanmarti/deno2_nestjs_example">GitHub</a> example I’ve added, where trying to access the Swagger documentation URL will result in a crash of the application.</p><p>I hope you found this article interesting and easy to understand, and also hope you’ll give Deno a try in anything else you’re trying to build. It’s certainly an exciting alternative to the classic Node.js.</p><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=861c1b73b90c" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/using-nestjs-with-deno-2-0-861c1b73b90c">Using NestJS with Deno 2.0</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NestJS Tracing using OpenTelemetry & Jaeger]]></title>
            <link>https://blog.stackademic.com/nestjs-tracing-using-opentelemetry-jaeger-377affcf9714?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/377affcf9714</guid>
            <category><![CDATA[jaeger]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[opentelemetry]]></category>
            <category><![CDATA[tracing]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Sun, 06 Oct 2024 18:26:45 GMT</pubDate>
            <atom:updated>2024-10-10T11:08:12.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0CiUNUUeb23KGpIvmfx3Lw.png" /></figure><p>In this article, I want to provide you with a quick, simple guide, and a complete example, of how to set up tracing in your NestJS projects, with the help of OpenTelemetry and Jaeger. You’ll see here that getting things up and running is a breeze, and will get you thinking: I should do this in all my projects from now on! You can find the fully coded/working example on <a href="https://github.com/serbanmarti/nestjs-tracing-example">GitHub</a>.</p><p>The things detailed below can also work in projects that aren’t NestJS based, with some minor tweaking, so keep on reading and explore the <a href="https://github.com/serbanmarti/nestjs-tracing-example">GitHub example</a> code if this is what you’re looking for.</p><p>Side note: there are plenty of sources out there explaining the what and why of tracing, so we won’t go through that here.</p><h3>Tracing</h3><h4>Basic setup</h4><p>You’re going to need a .ts file for your tracing code. Depending on how you structured your NestJS project, it could just be a file next to your main, in a utils directory, or a Nest library… it doesn’t matter, just make it fit your needs.</p><p>The following is the generic code you need to implement for tracing:</p><pre>&#39;use strict&#39;;<br><br>import { ATTR_SERVICE_NAME } from &#39;@opentelemetry/semantic-conventions&#39;;<br>import { NodeSDK } from &#39;@opentelemetry/sdk-node&#39;;<br>import { OTLPTraceExporter } from &#39;@opentelemetry/exporter-trace-otlp-grpc&#39;;<br>import { Resource } from &#39;@opentelemetry/resources&#39;;<br><br>// Initialize the SDK and register with the OpenTelemetry API<br>const sdk = new NodeSDK({<br>  traceExporter: new OTLPTraceExporter({<br>    url: process.env.TRACING_AGENT_URL, // (e.g. Jaeger -&gt; http://localhost:4317)<br>  }),<br>  instrumentations: [], // &lt;- TODO: add the tools you need<br>  resource: new Resource({<br>    [ATTR_SERVICE_NAME]: process.env.TRACING_SERVICE_NAME, // (e.g. &#39;x-api&#39;)<br>  }),<br>});<br><br>// Enable the API to record telemetry<br>sdk.start();<br><br>// Gracefully shut down the SDK on process exit<br>process.on(&#39;SIGTERM&#39;, () =&gt; {<br>  sdk<br>    .shutdown()<br>    .then(() =&gt; console.log(&#39;Tracing terminated&#39;))<br>    .catch((error) =&gt; console.log(&#39;Error terminating tracing&#39;, error))<br>    .finally(() =&gt; process.exit(0));<br>});<br><br>export default sdk;</pre><p>The amount of code needing to get the basics done is minimal. Here, we’re getting the tracing SDK initialized, configuring the exporter (how and where we’re sending our tracing data), configuring the name of the service that will be sending the tracing data (we require a way to determine who/what created tracing entries), and also adding some extra flair to our implementation like shutdown handling.</p><p>You might also&#39;ve noticed the TODO comment next to instrumentations. That is where we must define what sort of things we want to trace, and what (if any) configurations those require as well.</p><h4>Instrumentations</h4><p><a href="https://www.npmjs.com/org/opentelemetry">@opentelemetry</a> offers a giant number of instrumentation packages ready for us to use, depending on our needs and what we’ve implemented in our projects. Are you connecting to and interacting with a DB with Prisma? You’re good. Sending messages to an async queue with Kafka or RabbitMQ? No problem! Whatever it is, you’re probably covered.</p><p>We’ll keep it simple for this example. Let’s just add instrumentation for what Nest does, HTTP requests/responses, and Express interactions.</p><pre>...<br>import { ExpressInstrumentation } from &#39;@opentelemetry/instrumentation-express&#39;;<br>import { HttpInstrumentation } from &#39;@opentelemetry/instrumentation-http&#39;;<br>import { NestInstrumentation } from &#39;@opentelemetry/instrumentation-nestjs-core&#39;;<br>...<br><br>// Configure the endpoints/paths to ignore when tracing incoming requests<br>const IGNORED_PATHS = [&#39;/&#39;, &#39;/api&#39;, &#39;/health&#39;];<br><br>...<br>instrumentations: [<br>  new NestInstrumentation(),<br>  new HttpInstrumentation({<br>    ignoreIncomingRequestHook: (request) =&gt; {<br>      if (IGNORED_PATHS.includes(request.url)) {<br>        return true;<br>      }<br>    },<br>  }),<br>  new ExpressInstrumentation(),<br>],<br>...</pre><p>Again, notice how straightforward adding all this was. If we wanted, we could even ignore the optional configuration added to the HTTP instrumentation. That’s all you have to do here to get back some fantastic insights into your code.</p><h4>Running it</h4><p>Just one, even smaller bit remains: importing it into your main project code.</p><p>In the main.ts file, add the following:</p><pre>// IMPORTANT: This needs to be the first import! DO NOT MOVE!!!<br>import tracing from &#39;./utils/tracing&#39;;<br><br>import ...<br><br>async function bootstrap() {<br>  // Start the tracing service<br>  tracing.start();<br><br>  const app = await NestFactory.create(AppModule);<br><br>  ...<br>}<br>bootstrap();</pre><p>It’s crucial that the very first thing you import is the tracing code. Otherwise, this won’t work. In the boostrap function, again, the first thing you need to do is call the start function from the tracing SDK.</p><p>And that’s literally all there is to it. Your running app should start sending tracing data.</p><h3>Working with the example</h3><p>As mentioned at the start, I’ve also provided a fully implemented and working example with everything integrated, over on <a href="https://github.com/serbanmarti/nestjs-tracing-example">GitHub</a>.</p><p>It contains a NestJS project with a few endpoints, a library for the tracing code, and the Dockerfile and docker-compose to run it, together with Jaeger.</p><p>There’s also a very basic configuration for <a href="https://sentry.io/welcome/">Sentry</a> in there, just as a highlight of the importance of import ordering for your projects. The smallest things can mess with what you’re trying to do!</p><p>Just run docker compose up --build -d and start playing around with it. You’ll be able to see the tracing data on <a href="http://localhost:16686.">http://localhost:16686.</a></p><p>I hope this was helpful for you and got you out of any problems you might’ve had trying to implement tracing in your project. The simpleness of this article and example come after looking at many examples and articles in the past, some not working at all, some just partially, and getting it all together in one place. Happy coding!</p><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a></li><li>Visit our other platforms: <a href="https://plainenglish.io/"><strong>In Plain English</strong></a> | <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=377affcf9714" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/nestjs-tracing-using-opentelemetry-jaeger-377affcf9714">NestJS Tracing using OpenTelemetry &amp; Jaeger</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accessing Private Resources & DNS On Your Google Cloud VPC w/ Tailscale]]></title>
            <link>https://medium.com/@marti.serban/accessing-private-resources-dns-on-your-google-cloud-vpc-w-tailscale-0875a24452db?source=rss-4dd540e1f305------2</link>
            <guid isPermaLink="false">https://medium.com/p/0875a24452db</guid>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[network]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[tailscale]]></category>
            <dc:creator><![CDATA[Serban Marti]]></dc:creator>
            <pubDate>Sun, 22 Sep 2024 15:06:16 GMT</pubDate>
            <atom:updated>2024-09-22T15:06:16.322Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nf7TN_0ZABC2FroybUIaVQ.png" /></figure><p>Most of us know that we’ve been living in the “Cloud” when it comes to most online services for a good while now, and one of the top priorities for most (if not all) companies, is taking measures and implementing solutions to make sure these services are highly secure. One such measure, a basic one at that, is implementing a VPC (read more about them <a href="https://www.cloudflare.com/learning/cloud/what-is-a-virtual-private-cloud/">here</a>).</p><p>As an engineer, you may have a love-hate relationship with VPCs. You love that they protect your resources from harm, but you hate that it makes developing/testing/debugging a bit (or more) painful, as access to these resources is not so easy any more, that is, if you keep private things… well, private; no more public IPs where they shouldn’t be.</p><p>In this article, I want to give you an easy, step-by-step walkthrough, of how to access not only those private resources (like a database), but also other things like a VM running a deployed internal service using a domain through a private DNS. Some of this information is already easy(ish) to find on the internet, whilst that last part not so much. This is meant as a straightforward and easy to use method of gaining access, whilst not making compromises.</p><h4>Prerequisites</h4><p>We’re going to assume that you already have the basics set up: a GCP project with a VPC and some resources, as well as a Tailscale account. We won’t be going through how to get those things ready here, as you can find that information freely from other sources.</p><p>For the entire purpose of this article, we will assume our VPC network is named staging, with a subnetwork of Primary IPv4 range of 10.0.0.0/8.</p><h3>Setting up Tailscale access to the VPC</h3><p>The first step in this process is to let Tailscale have access to our VPC. To achieve this, we’ll need to create two things:</p><ul><li>a firewall rule — to allow connections to Tailscale</li><li>a VM using Compute Engine — where we will install, configure and run Tailscale</li></ul><h4>Firewall</h4><p>We first need to create a new firewall rule for Tailscale, to allow inbound connections. Here are the configurations needed:</p><ul><li>Name: anything relevant to you or your naming conventions; tailscale works just fine</li><li>Network: select the VPC you want to assign this to; staging in this case</li><li>Target tags: we’re setting this rule to work based on tags; I’m setting it to the tag allow-tailscale</li><li>Source IPv4 ranges: we’re going to allow IPv4 addresses to connect to our Tailscale installation; we need to set 0.0.0.0/0 here, allowing all connections</li><li>Protocols and ports: here we just have to add port 41641 as UDP</li></ul><p>After creation, it should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*av192xkRh8l6FmiDwM0PIA.png" /></figure><h4>Virtual Machine</h4><p>Next up, we need to create a VM where we’ll install and run Tailscale. For the name, region and zone, select whatever makes sense for you. For the rest:</p><ul><li>Machine configuration: choose whatever resources make sense for your needs and budget; note, you don’t need to go overboard here</li><li>Boot disk: go with a Debian or Ubuntu LTS distro, the minimum amount of disk space, and you’re set</li></ul><p>The networking section needs more specific attention. Open this up in Advanced options ⇾ Networking. Here, change the following:</p><ul><li>Network tags: add the previously created tag from the firewall rule — allow-tailscale</li><li>IP forwarding: enable this</li><li>Network interfaces: make sure the right VPC is selected here; the internal/external IPs can be of your choosing, just make sure they are set/enabled</li></ul><p>And that’s it for configurations. Create and start the VM. Once it’s up and running, we’ll SSH into it, and get to installing Tailscale.</p><p>Official documentation on installing Tailscale can be found <a href="https://tailscale.com/kb/1031/install-linux">here</a>, but I’ll go through the process as well. I’ve got Ubuntu 24.04 installed on my VM. Let’s start installing:</p><ul><li>Add Tailscale’s package signing key and repository:</li></ul><pre>curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg &gt;/dev/null<br>curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list</pre><ul><li>Install Tailscale:</li></ul><pre>sudo apt-get update<br>sudo apt-get install -y tailscale</pre><ul><li>Enable IP forwarding</li></ul><pre>echo &#39;net.ipv4.ip_forward = 1&#39; | sudo tee -a /etc/sysctl.d/99-tailscale.conf<br>echo &#39;net.ipv6.conf.all.forwarding = 1&#39; | sudo tee -a /etc/sysctl.d/99-tailscale.conf<br>sudo sysctl -p /etc/sysctl.d/99-tailscale.conf</pre><ul><li>Connect your machine to your Tailscale network and authenticate in your browser:</li></ul><pre>sudo tailscale up --advertise-routes=10.0.0.0/8 --accept-dns=true --accept-routes</pre><p>Once you’ve completed the steps above, you should see the following new machine in your Tailscale dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbSx3-MscAWEfWmPKbWXBw.png" /></figure><p>We’re going to do 2 things to the machine in this interface. Click the 3 dots at the right, and then:</p><ul><li>Disable key expiry: we don’t want the key for this machine to expire, as we want it to be constantly connected</li><li>Edit route settings: here we want to enable the subnet route we advertised in the command we last used above</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*mEHp3WpHw9dUfB_Sw-dIJg.png" /></figure><h4>Testing what we have so far</h4><p>Let’s make sure that what we’ve set up so far actually works. With Tailscale also installed on your machine, make sure it’s running, and you are connected to the network.</p><p>We’re assuming you have some resources running on your VPC here. I’m going with a PostgreSQL database. Let’s try connecting to it.</p><p>Open up a terminal window, and run the following command (adding the IP of your own DB):</p><pre>psql -h &lt;db_internal_ip&gt; -U postgres</pre><p>If everything was set up correctly, this should immediately ask you for the password. If not, retrace your steps and make sure you did everything right.</p><h3>Setting up Private DNS</h3><p>Now, connecting to resources is pretty easy. Just use their internal IP, and you’re good to go. But IPs are not something we easily remember. Domains, on the other hand, much better. What we’ve got so far takes us a good part of the way there, so let’s get over the finish line.</p><p>The resource you want to access can be any Compute Engine VM. I’m going to use a deployment of <a href="https://www.jaegertracing.io/">Jaeger</a> as the example. It’s set up with a deployed container (docker.io/jaegertracing/all-in-one). For this one, all we need to make sure we set is: the right VPC, a static internal IP, and no external IP (we want to be the only ones connecting to it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*0rLwE1lImSP5KMgPvPjXXg.png" /><figcaption>As you can see, we can access Jaeger through the private IP</figcaption></figure><h4>Creating the DNS</h4><p>We’ll need access to a terminal, with gcloud CLI installed and logged in. You can do this directly with the Cloud Shell on GCP.</p><p>Run the following command to create the private DNS, replacing with your own GCP project ID and VPC name:</p><pre>gcloud dns policies create inbound-dns \<br>  --project=&quot;YOUR_PROJECT_ID&quot; \<br>  --description=&quot;Expose DNS endpoints per subnet&quot; \<br>  --networks=&quot;YOUR_VPC_NAME&quot; \<br>  --enable-inbound-forwarding</pre><p>Next, we’ll want the IP of the DNS. We get that by running the following command, again replacing with your GCP project ID and the VPC Subnet name:</p><pre>gcloud compute addresses list \<br>  --project=&quot;YOUR_PROJECT_ID&quot; \<br>  --filter=&#39;purpose=&quot;DNS_RESOLVER&quot;&#39; \<br>  --format=&#39;csv(address, region, subnetwork)&#39; \<br>  | grep YOUR_VPC_SUBNET_NAME</pre><p>The output should look something like this:</p><pre>10.0.0.30,europe-west1,staging-eu</pre><p>Note this IP down, as we’ll need it for the next step.</p><h4>Configuring Tailscale Nameservers</h4><p>Back in the Tailscale dashboard, navigate to the DNS section. Here we’ll add the rules necessary for accessing the private DNS we just set up.</p><p>In the Nameservers section, click on Add nameserver and add any of the Public DNS entries you have there (I went with Cloudflare). You’ll see the entry added under Global nameservers, with an option on the right to Override local DNS. Enable that option. We need this in order for Tailscale DNS routing rules to take precedence over anything else configured on your system.</p><p>Let’s now add a nameserver for the private DNS. Again in the Nameservers section, click on Add nameserver and add aCustom nameserver. Fill in the IP we got at the end of the previous stage, enable Restrict to domain, and then set the Domain to whatever you want to have as a base domain for your URLs. Make sure it doesn’t clash with <a href="https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains">public TLDs</a>. Using internal or something else suffixed with internal (e.g. my use case gcp.internal) will be best.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*fvLKUlk9SSn-nv67B4qhoQ.png" /></figure><p>We’re done configuring Tailscale. All that’s left is making sure that GCP also knows that we want this domain to exist, and then add our record set(s).</p><h4>Creating the Domain</h4><p>Back in the GCP console, navigate to Cloud DNS. We’re going to create a new DNS zone:</p><ul><li>Zone type: set this to Private</li><li>Zone name: set this to internal (or any name that makes sense for you)</li><li>DNS name: set this to gcp.internal (or whatever you set the Domain previously in Tailscale)</li><li>Networks: select the VPC</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*IcBm0-pbnDAV6Aq4c51C7A.png" /></figure><p>After that is created, we need to add a record set. Click on Add Standard and then:</p><ul><li>DNS name: set this to the name of the resource/service you want to access (in my case jaeger)</li><li>Resource record type: this depends on what exactly you want, but for my example, I want an A record</li><li>IPv4 Address: the static internal IP of the resource/service we’re accessing</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*8Hsw1pZsPzOopDQ4DUFy1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hb3fNerHBc4L2Pd7hvdIsg.png" /></figure><p>And that should be it. We just need to confirm it works.</p><h4>Testing it works</h4><p>In our browser, instead of navigating to the IP of the resource/service, let’s now use the domain we just set up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*aWCLCQk0ko39zDGZEaT_ZA.png" /></figure><p>And there we have it. A working domain, only accessible internally, using Tailscale.</p><h3>Conclusion</h3><p>In this article, we’ve walked through the process of setting up secure access to private resources within a Google Cloud VPC using Tailscale. By following these steps, you can seamlessly connect to your internal services and databases without exposing them to the public internet, ensuring both security and convenience.</p><p>To recap, we started by configuring a firewall rule and setting up a VM to run Tailscale. We then installed and configured Tailscale on the VM, enabling it to route traffic to our VPC. After verifying our setup by connecting to a private database, we moved on to setting up a private DNS. This allowed us to access our internal services using easy-to-remember domain names instead of IP addresses.</p><p>By leveraging Tailscale’s capabilities, we can maintain a high level of security while simplifying access to our internal resources. This approach enhances security and improves the developer experience by making it easier to connect to and manage private resources.</p><p>I hope this guide has been helpful and that you now feel confident in setting up and using Tailscale to access your Google Cloud VPC resources. If you have any questions or run into any issues, feel free to reach out or leave a comment below. Happy networking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0875a24452db" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>