<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Gourav Ghosal</title>
    <description>The latest articles on Forem by Gourav Ghosal (@gourav221b).</description>
    <link>https://forem.com/gourav221b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F962293%2F3399f395-4f72-4a2c-b4cd-87e052302187.jpeg</url>
      <title>Forem: Gourav Ghosal</title>
      <link>https://forem.com/gourav221b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gourav221b"/>
    <language>en</language>
    <item>
      <title>The Rise of the Specialist: Why Small Language Models are the Future of Enterprise AI</title>
      <dc:creator>Gourav Ghosal</dc:creator>
      <pubDate>Thu, 06 Nov 2025 16:37:07 +0000</pubDate>
      <link>https://forem.com/gourav221b/the-rise-of-the-specialist-why-small-language-models-are-the-future-of-enterprise-ai-dbc</link>
      <guid>https://forem.com/gourav221b/the-rise-of-the-specialist-why-small-language-models-are-the-future-of-enterprise-ai-dbc</guid>
      <description>&lt;h2&gt;
  
  
  Part I: Redefining the Landscape - Beyond the Hype of Scale
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Introduction: The Paradigm Shift from "Bigger is Better" to "Fit for Purpose"
&lt;/h3&gt;

&lt;p&gt;The artificial intelligence landscape has been dominated by a compelling narrative: bigger is better. The proliferation of Large Language Models (LLMs), characterized by an "arms race" among technology giants to develop ever-larger systems, has cemented the idea that model scale is the primary determinant of capability. However, as the AI market matures, this paradigm is being challenged. A more nuanced, strategic approach is emerging, centered on the principle of "fit for purpose". For a significant and growing number of enterprise applications, the massive scale of LLMs represents not just overkill, but a strategic and economic liability.&lt;/p&gt;

&lt;p&gt;This report posits that Small Language Models (SLMs) represent the next frontier of value creation in enterprise AI. This shift is not a rejection of the power of LLMs, but rather an evolution toward a more sophisticated, portfolio-based strategy where specialized, efficient, and controllable SLMs handle the majority of defined business tasks. The initial focus on sheer model size is giving way to a more pragmatic emphasis on domain-specific accuracy, operational efficiency, cost-effectiveness, and governance—areas where SLMs provide a decisive advantage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deconstructing the Models: An Architectural and Operational Comparison
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Defining the Terms
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LLMs&lt;/strong&gt;: Vast scale and general-purpose, parameter counts ranging from tens of billions to over a trillion, trained on massive, diverse datasets from the internet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SLMs&lt;/strong&gt;: Comparatively smaller size (few million to &amp;lt;10B parameters), specialized focus, trained/fine-tuned on curated datasets for specific tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  The Architectural Divide
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parameter Count&lt;/strong&gt;: GPT-4 (~1.76T parameters) vs. Phi-3 (3.8B) or Mistral 7B (7.3B).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Neural Network Depth&lt;/strong&gt;: LLMs often 48+ layers, SLMs 6–12 layers optimized for efficiency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attention Mechanisms&lt;/strong&gt;: LLMs use full self-attention (quadratic costs); SLMs use efficient alternatives (sliding window, sparse attention).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Divergent Training Philosophies
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LLMs&lt;/strong&gt;: Internet-scale, broad datasets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SLMs&lt;/strong&gt;: Domain-specific, curated datasets → higher accuracy, less noise.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  The SLM Creation Toolkit
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Knowledge Distillation&lt;/strong&gt;: Teacher-student model compression.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pruning&lt;/strong&gt;: Remove redundant weights/neurons/layers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quantization&lt;/strong&gt;: Reduce precision (e.g., FP32 → INT8) for smaller, faster models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deeper Insights: The "Quality over Quantity" Training Revolution
&lt;/h3&gt;

&lt;p&gt;Recent SLMs like &lt;strong&gt;Llama 3 8B&lt;/strong&gt; and &lt;strong&gt;Phi family&lt;/strong&gt; show that training data quality outweighs raw parameter counts. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Phi-3 Mini (3.8B)&lt;/strong&gt; rivals Mixtral 8x7B and GPT-3.5.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Llama 3 8B&lt;/strong&gt; outperforms &lt;strong&gt;Llama 2 70B&lt;/strong&gt; on reasoning and coding benchmarks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This democratizes AI development—quality curation over sheer compute resources—and reframes enterprise proprietary data as a strategic asset for building competitive SLMs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part II: The Strategic Imperative - Quantifying the SLM Advantage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Economic Case: Drastic Reductions in Total Cost of Ownership (TCO)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Training/Fine-Tuning Costs&lt;/strong&gt;: LLM training costs tens/hundreds of millions. SLM fine-tuning can cost as little as \$20/month.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inference/Operational Costs&lt;/strong&gt;: 7B SLMs are &lt;strong&gt;10–30x cheaper&lt;/strong&gt; to serve than 70–175B LLMs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure Costs&lt;/strong&gt;: LLMs need high-end GPU clusters. SLMs can run on CPUs or consumer GPUs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Performance and Efficiency: Speed, Latency, and Sustainability
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inference Speed&lt;/strong&gt;: SLMs &amp;lt;300ms vs. LLMs &amp;gt;1s.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge Deployment&lt;/strong&gt;: SLMs run offline on devices (smartphones, IoT, vehicles).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sustainability&lt;/strong&gt;: Lower energy consumption and carbon footprint.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Control and Governance: Enhancing Security, Privacy, and Compliance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Privacy/Security&lt;/strong&gt;: On-premise/private cloud deployment keeps data in-house.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bias/Safety&lt;/strong&gt;: Smaller curated datasets → easier auditing and fairness.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transparency&lt;/strong&gt;: Simpler architecture → better interpretability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independence&lt;/strong&gt;: Avoid lock-in with external API providers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deeper Insights: The Compounding Value of On-Device AI
&lt;/h3&gt;

&lt;p&gt;On-device deployment resolves LLM trade-offs in &lt;strong&gt;latency, privacy, and cost&lt;/strong&gt;. Applications become:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster (real-time interactions).&lt;/li&gt;
&lt;li&gt;Safer (no cloud data transmission).&lt;/li&gt;
&lt;li&gt;Cheaper (fixed deployment cost vs. per-token fees).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Part III: The Evidence - Benchmarks and Performance in the Real World
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Proof in the Numbers
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Table 1: Llama 3 8B vs. Llama 2 Family
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Benchmark&lt;/th&gt;
&lt;th&gt;Llama 3 8B (Instruct)&lt;/th&gt;
&lt;th&gt;Llama 2 70B (Instruct)&lt;/th&gt;
&lt;th&gt;Llama 2 13B (Instruct)&lt;/th&gt;
&lt;th&gt;Llama 2 7B (Instruct)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MMLU (5-shot)&lt;/td&gt;
&lt;td&gt;68.4&lt;/td&gt;
&lt;td&gt;52.9&lt;/td&gt;
&lt;td&gt;47.8&lt;/td&gt;
&lt;td&gt;34.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPQA (0-shot)&lt;/td&gt;
&lt;td&gt;34.2&lt;/td&gt;
&lt;td&gt;21.0&lt;/td&gt;
&lt;td&gt;22.3&lt;/td&gt;
&lt;td&gt;21.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HumanEval (0-shot)&lt;/td&gt;
&lt;td&gt;62.2&lt;/td&gt;
&lt;td&gt;25.6&lt;/td&gt;
&lt;td&gt;14.0&lt;/td&gt;
&lt;td&gt;7.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GSM-8K (8-shot, CoT)&lt;/td&gt;
&lt;td&gt;79.6&lt;/td&gt;
&lt;td&gt;57.5&lt;/td&gt;
&lt;td&gt;77.4&lt;/td&gt;
&lt;td&gt;25.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MATH (4-shot, CoT)&lt;/td&gt;
&lt;td&gt;30.0&lt;/td&gt;
&lt;td&gt;11.6&lt;/td&gt;
&lt;td&gt;6.7&lt;/td&gt;
&lt;td&gt;3.8&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Table 2: Phi-3 vs. GPT-4/3.5
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Benchmark&lt;/th&gt;
&lt;th&gt;Phi-3.5-MoE-instruct&lt;/th&gt;
&lt;th&gt;GPT-4 (0613)&lt;/th&gt;
&lt;th&gt;Phi-3-mini (3.8B)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MMLU&lt;/td&gt;
&lt;td&gt;78.9%&lt;/td&gt;
&lt;td&gt;86.4%&lt;/td&gt;
&lt;td&gt;69.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HumanEval&lt;/td&gt;
&lt;td&gt;70.7%&lt;/td&gt;
&lt;td&gt;67.0%&lt;/td&gt;
&lt;td&gt;--&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MATH&lt;/td&gt;
&lt;td&gt;59.5%&lt;/td&gt;
&lt;td&gt;42.0%&lt;/td&gt;
&lt;td&gt;--&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Table 3: Gemma vs. Llama 3 (SLM Variants)
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Benchmark&lt;/th&gt;
&lt;th&gt;Llama 3.2 1B&lt;/th&gt;
&lt;th&gt;Gemma 3 1B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MMLU (5-shot)&lt;/td&gt;
&lt;td&gt;49.3%&lt;/td&gt;
&lt;td&gt;38.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GSM8K (8-shot, CoT)&lt;/td&gt;
&lt;td&gt;44.4%&lt;/td&gt;
&lt;td&gt;62.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Table 4: Quantifying Operational Gains
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;SLM&lt;/th&gt;
&lt;th&gt;LLM&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Inference Cost&lt;/td&gt;
&lt;td&gt;10–30x cheaper&lt;/td&gt;
&lt;td&gt;10–30x more expensive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Example Monthly Cost&lt;/td&gt;
&lt;td&gt;Mistral-7B: \$300–\$515 / 100M tokens&lt;/td&gt;
&lt;td&gt;GPT-4: \$9,000 / 100M tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inference Latency&lt;/td&gt;
&lt;td&gt;&amp;lt;300ms&lt;/td&gt;
&lt;td&gt;&amp;gt;1s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Energy Efficiency (Code Gen)&lt;/td&gt;
&lt;td&gt;Same or less in &amp;gt;52% of outputs&lt;/td&gt;
&lt;td&gt;Higher per output&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VRAM Usage&lt;/td&gt;
&lt;td&gt;~6 GB (quantized Mistral-7B)&lt;/td&gt;
&lt;td&gt;High-end GPUs required&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  From Lab to Live: Enterprise Case Studies
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Case Study 1: Microsoft Supply Chain Optimization
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Challenge&lt;/strong&gt;: Natural language interface for Azure logistics APIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Fine-tuned Phi-3, Llama 3, and Mistral with 1,000 examples.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result&lt;/strong&gt;: Phi-3 mini (3.8B) achieved &lt;strong&gt;95.86% accuracy&lt;/strong&gt; vs. GPT-4-turbo's &lt;strong&gt;85.17%&lt;/strong&gt; (20-shot).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Takeaway&lt;/strong&gt;: SLMs can outperform LLMs in structured, API-driven enterprise tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Case Study 2: Airtrain in Healthcare &amp;amp; E-commerce
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Healthcare&lt;/strong&gt;: On-premise patient intake chatbot, GPT-3.5-like quality, but compliant and cost-effective.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;E-commerce&lt;/strong&gt;: Product recommendation engine → reduced latency + cost, improved personalization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Takeaway&lt;/strong&gt;: SLMs deliver &lt;strong&gt;accuracy + privacy + efficiency&lt;/strong&gt; in regulated and customer-facing industries.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;SLMs are not merely a lightweight alternative to LLMs; they are the future of &lt;strong&gt;enterprise-grade AI&lt;/strong&gt;. Their advantages in cost, speed, governance, and privacy make them the natural choice for specialized, scalable, and sustainable deployments. The strategic imperative is clear: &lt;strong&gt;fit-for-purpose SLMs will define the next era of enterprise AI innovation.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>slm</category>
    </item>
    <item>
      <title>Create a fullstack Next.js 15 app with Drizzle ORM, Postgresql, Docker</title>
      <dc:creator>Gourav Ghosal</dc:creator>
      <pubDate>Sat, 15 Mar 2025 17:10:30 +0000</pubDate>
      <link>https://forem.com/gourav221b/create-a-fullstack-nextjs-15-app-with-drizzle-orm-postgresql-docker-2a6g</link>
      <guid>https://forem.com/gourav221b/create-a-fullstack-nextjs-15-app-with-drizzle-orm-postgresql-docker-2a6g</guid>
      <description>&lt;p&gt;In modern web development, integrating a robust backend with a responsive frontend is crucial for building powerful and scalable applications. With Next.js, creating dynamic full stack applications have become easier with the usage of server components. No dynamic application can work without a scalable and powerful database. While NoSQL databases like MongoDB, are widely used, many industries still stick to SQL databases.&lt;/p&gt;

&lt;p&gt;In this guide, we'll explore how to set up a full stack Next.js application using &lt;strong&gt;Drizzle ORM&lt;/strong&gt; for database interactions, &lt;strong&gt;PostgreSQL&lt;/strong&gt; for relational data storage, and &lt;strong&gt;Docker&lt;/strong&gt; for environment consistency.&lt;/p&gt;

&lt;h2&gt;
  
  
  What well build
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we will create a &lt;strong&gt;simple task manager application&lt;/strong&gt; that allows users to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create, read, update, and delete tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Persist data using PostgreSQL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;strong&gt;Drizzle ORM&lt;/strong&gt; to simplify database queries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leverage Docker for seamless development and deployment.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fue1ojk328rs8f3o18r1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fue1ojk328rs8f3o18r1l.png" alt="Screenshot of todo app" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To get started with this project, we will need the following to be installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Node.js(v18 or later)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An IDE (e.g. VS Code)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and some basic knowledge of Typescript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Setup the Next.js project
&lt;/h2&gt;

&lt;p&gt;To setup the Next.js project, we need to run the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest next-drizzle-docker --use-pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will be using pnpm as our package manager. Ensure you select Typescript and App Router during installation.&lt;/p&gt;

&lt;p&gt;Navigate into the project directory and install dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd next-drizzle-dockerpnpm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install additional dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm add postgres drizzle-orm drizzle-kit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2 : Configure PostgreSQL with Docker Compose
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;docker-compose.yaml&lt;/code&gt; file in the root directory to set up a PostgreSQL Database&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3.8'services: postgres: image: postgres:15 container_name: next_postgres environment: POSTGRES_USER: admin POSTGRES_PASSWORD: admin POSTGRES_DB: tasks_db ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/datavolumes: postgres_data:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spin up the PostgreSQL service with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that the database is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Set Up Drizzle ORM
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Initialize Drizzle ORM
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;drizzle.config.ts&lt;/code&gt; file in the project root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { defineConfig } from 'drizzle-kit';export default defineConfig({ out: './drizzle', schema: './db/schema.ts', dialect: 'postgresql', dbCredentials: { url: process.env.DATABASE_URL || "postgres://admin:admin@localhost:5432/your_db", },});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;code&gt;package.json&lt;/code&gt; file, create a new script to perform migrations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": { // other required scripts "migrate": "drizzle-kit generate &amp;amp;&amp;amp; drizzle-kit push"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a PostgreSQL instance
&lt;/h3&gt;

&lt;p&gt;In the root of the project create a &lt;code&gt;config&lt;/code&gt; folder and a &lt;code&gt;db&lt;/code&gt; subfolder (can vary according to your file conventions). In the &lt;code&gt;db&lt;/code&gt; subfolder, create an &lt;code&gt;index.ts&lt;/code&gt; file and create a postgres instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { drizzle } from "drizzle-orm/postgres-js";import postgres from "postgres";import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";// Dev environment solve for "sorry, too many clients already"declare global { // eslint-disable-next-line no-var -- only var works here var db: PostgresJsDatabase | undefined;}let db: PostgresJsDatabase;if (process.env.NODE_ENV === "production") { db = drizzle(postgres(`${process.env.DATABASE_URL}`));} else { if (!global.db) global.db = drizzle(postgres(`${process.env.DATABASE_URL}`)); db = global.db;}export { db };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create the Database Schema
&lt;/h3&gt;

&lt;p&gt;In the root of the project directory, create a &lt;code&gt;db/schema.ts&lt;/code&gt; file where the data schema will be stored.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { pgTable, serial, text, boolean } from "drizzle-orm/pg-core";export const tasks = pgTable("tasks_table", { id: serial("id").primaryKey(), title: text().notNull(), description: text().notNull(), completed: boolean().default(false),});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Create the backend logic
&lt;/h2&gt;

&lt;p&gt;We will write all the database operations in side a &lt;code&gt;repositories&lt;/code&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { db } from "@/config/db"import { tasks } from "@/config/db/schema"import { determinePagination } from "@/lib/utils"import { count, eq, sql } from "drizzle-orm"const taskReponseBody = { id: tasks.id, title: tasks.title, description: tasks.description, completed: tasks.completed}// create prepared statements for optimized queriesconst allTasksCount = db.select({ total: count() }) .from(tasks).prepare("all_tasks_count")const allTasksQuery = db.select(taskReponseBody) .from(tasks) .limit(sql.placeholder('size')) .offset((Number(sql.placeholder('page')) - 1) * Number(sql.placeholder('size'))) .prepare("all_tasks")const getAllTasks = async (page = 1, size = 10) =&amp;gt; { try { const [totalResult, data] = await Promise.all([allTasksCount.execute(), allTasksQuery.execute({ page, size }),]); const total = totalResult[0].total return { total, data, ...determinePagination(total, page, size) }; } catch (error: unknown) { if (error instanceof Error) throw new Error(error.message); }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;determinePagination&lt;/code&gt; function helps communicating to the frontend regarding pagination status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function determinePagination(total: number, page: number, page_size: number) { if (total &amp;lt;= 0 || page &amp;lt;= 0) { // No pages available if total is 0 or negative or page number is invalid return { hasNextPage: false, hasPrevPage: false }; } const totalPages = Math.ceil(total / page_size); // Total number of pages const hasPrevPage = page &amp;gt; 1 &amp;amp;&amp;amp; page &amp;lt;= totalPages; const hasNextPage = page &amp;lt; totalPages; return { hasNextPage, hasPrevPage };}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, we can write the functions to create, update and delete tasks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const createNewTask = async (data: typeof tasks.$inferInsert) =&amp;gt; { if (!data.title) throw new Error("Title is required") const createdTask = await db.insert(tasks).values({ title: data.title, description: data.description, completed: data.completed }).returning(); return createdTask;}const deleteTask = async (id: number) =&amp;gt; { const deletedTask = await db.delete(tasks).where(eq(tasks.id, id)).returning(); return deletedTask;}type UpdateTaskType{ id: number, title?: string, description?: string, completed?: boolean }const updateTask = async (data: ) =&amp;gt; { if (!data.id) throw new Error("Task id is required") const updatedTask = await db.update(tasks).set(data).where(eq(tasks.id, data.id)).returning(); return updatedTask;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Create APIs to communicate with frontend
&lt;/h2&gt;

&lt;p&gt;In the app directory, create a new folder named &lt;code&gt;api&lt;/code&gt; and a sub folder &lt;code&gt;tasks&lt;/code&gt; to create the route.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app/ api/ tasks/ [taskId]/ route.ts route.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;code&gt;tasks/route.ts&lt;/code&gt; file, we will write the code for listing all tasks and creating a new task.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NextRequest, NextResponse } from "next/server";import { createNewTask, getAllTasks } from "@/repositories/tasks.repositories";// GET tasksexport async function GET(req: NextRequest) { const searchParams = req.nextUrl.searchParams try { const page = Number(searchParams.get('page')) || 1; const size = Number(searchParams.get('size')) || 1; const allTasks = await getAllTasks(page, size); return NextResponse.json(allTasks); } catch (error) { if (error instanceof Error) { return NextResponse.json({ message: error.message }, { status: 500 }); } }}// POST taskexport async function POST(req: Request) { try { const { title, description, completed } = await req.json(); const newTask = await createNewTask({ title, description, completed }); return NextResponse.json(newTask); } catch (error) { if (error instanceof Error) { return NextResponse.json({ message: error.message }, { status: 500 }); } }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we want to update the task, or delete the task, we would be using the path parameters.&lt;br&gt;&lt;br&gt;
In the &lt;code&gt;[taskId]/route.ts&lt;/code&gt;, we will write the PATCH and DELETE methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function PATCH(req: Request, { params }: { params: Promise&amp;lt;{ taskId: string }&amp;gt; }) { try { const taskId = (await params).taskId if (!taskId || isNaN(Number(taskId))) throw new Error("Task id is required to delete record") const data = await req.json(); const updateObject: { id: number, title?: string, description?: string, completed?: boolean } = { id: Number(taskId) }; if (data.title !== undefined) updateObject.title = data.title; if (data.description !== undefined) updateObject.description = data.description; if (data.completed !== undefined) updateObject.completed = data.completed; const updatedTask = await updateTask(updateObject) return NextResponse.json({ message: "Task updated", data: updatedTask }); } catch (error) { if (error instanceof Error) { console.log(error) return NextResponse.json({ message: error.message }, { status: 500 }); } }}// DELETE taskexport async function DELETE(req: Request, { params }: { params: { taskId: string } }) { try { const id = params.taskId; if (!id || isNaN(Number(id))) throw new Error("Task id is required to delete record"); await deleteTask(Number(id)); return NextResponse.json({ message: "Task deleted" }); } catch (error) { if (error instanceof Error) { return NextResponse.json({ message: error.message }, { status: 500 }); } }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6 : Integrate the frontend
&lt;/h2&gt;

&lt;p&gt;Below is a very rudimentary code for integrating the APIs. &lt;strong&gt;For a more detailed and better version, please checkout the&lt;/strong&gt; &lt;a href="https://github.com/gourav221b/next-drizzle-docker" rel="noopener noreferrer"&gt;&lt;strong&gt;GitHub repository here&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;!&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";import { useState, useEffect } from "react";const TaskManager = () =&amp;gt; { const [tasks, setTasks] = useState([]); const [newTask, setNewTask] = useState(""); const fetchTasks = async () =&amp;gt; { const res = await fetch("/api/tasks"); const data = await res.json(); setTasks(data); }; const addTask = async () =&amp;gt; { await fetch("/api/tasks", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ title: newTask }), }); setNewTask(""); fetchTasks(); }; const deleteTask = async (id: number) =&amp;gt; { await fetch("/api/tasks", { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id }), }); fetchTasks(); }; useEffect(() =&amp;gt; { fetchTasks(); }, []); return ( &amp;lt;div&amp;gt; &amp;lt;h1&amp;gt;Task Manager&amp;lt;/h1&amp;gt; &amp;lt;input value={newTask} onChange={(e) =&amp;gt; setNewTask(e.target.value)} placeholder="New task" /&amp;gt; &amp;lt;button onClick={addTask}&amp;gt;Add Task&amp;lt;/button&amp;gt; &amp;lt;ul&amp;gt; {tasks.map((task: any) =&amp;gt; ( &amp;lt;li key={task.id}&amp;gt; {task.title}{" "} &amp;lt;button onClick={() =&amp;gt; deleteTask(task.id)}&amp;gt;Delete&amp;lt;/button&amp;gt; &amp;lt;/li&amp;gt; ))} &amp;lt;/ul&amp;gt; &amp;lt;/div&amp;gt; );};export default TaskManager;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 7: Run Your Application
&lt;/h2&gt;

&lt;p&gt;Start the Next.js development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; to view your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 8: Deploy with Docker
&lt;/h2&gt;

&lt;p&gt;To prepare your app for deployment, create a &lt;code&gt;Dockerfile&lt;/code&gt; in your project root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use an official Node.js runtime as the base imageFROM node:20-alpine# Set the working directory in the containerWORKDIR /app# Copy package.json and pnpm-lock.yaml (if you have one)COPY package*.json pnpm-lock.yaml* ./# Install pnpmRUN npm install -g pnpm# Install dependenciesRUN pnpm install # Copy the rest of the application codeCOPY . .# Build the Next.js applicationRUN pnpm build# Expose the port the app runs onEXPOSE 3000# Start the applicationCMD ["pnpm", "start"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build and run your Docker container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t next-drizzle-app .docker run -p 3000:3000 next-drizzle-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Youve successfully built and containerized a fullstack &lt;strong&gt;Next.js&lt;/strong&gt; application using &lt;strong&gt;Drizzle ORM&lt;/strong&gt; , &lt;strong&gt;PostgreSQL&lt;/strong&gt; , and &lt;strong&gt;Docker&lt;/strong&gt;. This setup provides a scalable foundation for more complex applications while maintaining flexibility and ease of development.&lt;/p&gt;

&lt;p&gt;Whats next? You could:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Add user authentication with &lt;strong&gt;Auth.js&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extend the database schema to support relationships.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy the app to platforms like Cloud Run, Digital Ocean etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>postgres</category>
      <category>drizzle</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Anthropic's Model Context Protocol (MCP): A New Era in AI Integration</title>
      <dc:creator>Gourav Ghosal</dc:creator>
      <pubDate>Sat, 15 Mar 2025 17:02:26 +0000</pubDate>
      <link>https://forem.com/gourav221b/anthropics-model-context-protocol-mcp-a-new-era-in-ai-integration-4fi2</link>
      <guid>https://forem.com/gourav221b/anthropics-model-context-protocol-mcp-a-new-era-in-ai-integration-4fi2</guid>
      <description>&lt;p&gt;Advancements in AI are progressing faster than anyone expected. What seemed like a game-changing move by DeepSeek has now been eclipsed by Anthropic’s latest breakthrough — the &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this blog, I'll walk you through what MCP is, why it matters, and how you can build your own MCP host and tools to enhance AI capabilities.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is &lt;strong&gt;Model Context Protocol&lt;/strong&gt;?
&lt;/h2&gt;

&lt;p&gt;Anthropic’s &lt;strong&gt;Model Context Protocol&lt;/strong&gt; is a new standard for connecting AI assistants to real-world data sources — including content repositories, business tools, and development environments. Its goal is to enable AI models to produce more accurate and context-aware responses by integrating them with live, structured data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Choose MCP?
&lt;/h2&gt;

&lt;p&gt;AI assistants have become mainstream, but their performance has been inconsistent across industries. While some sectors have seen significant improvements, others remain skeptical due to AI's inability to provide accurate responses based on specific data sources.&lt;/p&gt;

&lt;p&gt;Several methods have been used to address this issue:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Model Fine-Tuning&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
After pretraining, LLMs are fine-tuned on specific datasets to adapt to specialized domains (e.g., medical or legal texts). Fine-tuning helps models understand niche terminology and context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Retrieval-Augmented Generation (RAG)&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Instead of relying solely on internal knowledge, RAG allows models to query external databases or APIs for real-time information. This improves accuracy and keeps the model updated without retraining.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prompt Engineering&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Carefully structuring prompts improves the quality of responses by defining roles, providing context, and setting clear instructions.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;MCP doesn’t aim to replace these methods — it enhances them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of MCP:
&lt;/h3&gt;

&lt;p&gt;✅ Structured information exchange between applications and LLMs&lt;br&gt;&lt;br&gt;
✅ Standardized input/output formats for consistent interactions&lt;br&gt;&lt;br&gt;
✅ Reduced hallucinations and increased reliability through structured prompting&lt;br&gt;&lt;br&gt;
✅ Easy to implement without extensive infrastructure&lt;br&gt;&lt;br&gt;
✅ Works with existing models without requiring modifications&lt;/p&gt;


&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;MCP follows a client-server architecture designed for seamless communication between AI models and external systems.&lt;/p&gt;
&lt;h3&gt;
  
  
  Core Components:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hosts&lt;/strong&gt; – LLM applications (e.g., Claude Desktop or IDEs) that initiate connections&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Clients&lt;/strong&gt; – Maintain 1:1 connections with servers inside the host application&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Servers&lt;/strong&gt; – Provide context, tools, and prompts to the client&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2vcsr5krr1eciv55v18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2vcsr5krr1eciv55v18.png" alt="MCP Architecture" width="733" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fig. MCP Architecture (Source:&lt;/em&gt; &lt;a href="https://modelcontextprotocol.io/docs/concepts/architecture" rel="noopener noreferrer"&gt;&lt;em&gt;Model Context Protocol Docs&lt;/em&gt;&lt;/a&gt;&lt;em&gt;)&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  MCP Clients
&lt;/h2&gt;

&lt;p&gt;MCP clients are the software that connect to your server and gives users response. The following documentation lists some of the majorly used and supporting clients:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://modelcontextprotocol.io/clients" rel="noopener noreferrer"&gt;https://modelcontextprotocol.io/clients&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Build Your Own MCP Server
&lt;/h2&gt;

&lt;p&gt;For this example, I'll use &lt;strong&gt;TypeScript&lt;/strong&gt; to set up an MCP server. To keep things simple, we'll focus on servers, tools, and transport. More advanced configurations will be covered in a future post.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Set Up the Server
&lt;/h3&gt;

&lt;p&gt;Create a basic MCP server using TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/index.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gourav-mcp-server&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1.0.0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 2: Define the Tools
&lt;/h3&gt;

&lt;p&gt;Tools are functions that allow the LLM to perform specific actions, like making API calls, fetching data, or processing inputs. In this example, we'll create a tool that fetches a random fact and provides a snarky analysis.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/index.js&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setRequestHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ListToolsRequestSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;
            &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;random_facts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;returns random facts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;inputSchema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;object&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="na"&gt;fact&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}]&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 3: Configure the Tool
&lt;/h3&gt;

&lt;p&gt;Next, configure the tool to fetch the random fact:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/index.js&lt;/span&gt;
&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setRequestHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CallToolRequestSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;random_facts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;fact&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://uselessfacts.jsph.pl/api/v2/facts/random&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;toolResult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
            &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error fetching random fact:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;McpError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ErrorCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;InternalError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Failed to fetch random fact&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;McpError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ErrorCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MethodNotFound&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tool not found&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Finally, register the transport mechanism, and then you're ready to test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transport&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;StdioServerTransport&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Register the Server
&lt;/h3&gt;

&lt;p&gt;Add the server configuration to &lt;code&gt;claude_desktop_config.json&lt;/code&gt; so that Claude Desktop can recognize and use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mcpServers&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gourav-mcp-server-2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;command&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;args&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;path/to/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 6: Test the Integration
&lt;/h3&gt;

&lt;p&gt;Restart Claude Desktop, and you should see the MCP tool listed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal1ffdyjsi70v71un8pj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal1ffdyjsi70v71un8pj.png" alt="MCP tools in claude" width="619" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you query the LLM for a random fact, it will now use the configured MCP tool rather than relying solely on its internal knowledge:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbn9p5arwtr25u721k0i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbn9p5arwtr25u721k0i.png" alt="Claude result" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The Model Context Protocol (MCP) represents a significant step forward in AI integration. By enabling structured communication between LLMs and real-world data sources, MCP makes AI more &lt;strong&gt;reliable&lt;/strong&gt;, &lt;strong&gt;accurate&lt;/strong&gt;, and &lt;strong&gt;context-aware&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With the example above, you’ve seen how easy it is to create your own MCP server and tool. By configuring MCP to access specialized data sources, you can significantly enhance the performance and usefulness of AI models in real-world applications.&lt;/p&gt;

&lt;p&gt;MCP isn’t just another tool — it’s a foundational layer for the next generation of AI-powered systems.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agenticai</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>A Beginner’s approach to Responsive Design</title>
      <dc:creator>Gourav Ghosal</dc:creator>
      <pubDate>Sun, 16 Feb 2025 13:05:09 +0000</pubDate>
      <link>https://forem.com/gourav221b/a-beginners-approach-to-responsive-design-2bk3</link>
      <guid>https://forem.com/gourav221b/a-beginners-approach-to-responsive-design-2bk3</guid>
      <description>&lt;p&gt;If you’re reading this blog, let us assume you already have some basic knowledge and practical knowledge on how to structure your website using HTML and basic CSS.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll be covering some aspects of responsive design, why it is needed, and how to implement such a design.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Responsive Design?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;­Responsive Design is an approach where &lt;strong&gt;layouts become fluid&lt;/strong&gt; and can automatically mold themselves according to the screen sizes and viewports.&lt;/p&gt;

&lt;p&gt;It does not require any additional technology and can be implemented with the existing stylesheet.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll be talking about Responsive Web Design.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Responsive Web Design&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Imagine a scenario — You’ve created an amazing website with great design ideas and good content. But that is limited to your computer screen only. The minute you take out your phone to test it, the design is all broken. There is a huge scroll or even unreadable content. No one wants to see that.&lt;/p&gt;

&lt;p&gt;To give the most fulfilling client experience, you need to ensure that your site looks similarly great on screens of every kind. That is the reason why having a site with a responsive design is significant.&lt;/p&gt;

&lt;p&gt;The facts confirm that most of the online traffic is coming from portable yet the work area is as yet a nearby second, and a responsive plan will assist you with defeating the two universes. It keeps up with the respectability of your site content yet adjusts it to deliver fittingly as per the points of interest of various gadgets, making it easier to understand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0kafweikr798ybjlrba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0kafweikr798ybjlrba.png" alt="Image description" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fig: Representation of responsive vs non-responsive design.&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;website:&lt;/em&gt;&lt;a href="http://www.galleria-de-artiste.netlify.app/" rel="noopener noreferrer"&gt;&lt;em&gt;www.galleria-de-artiste.netlify.app&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;How to implement Responsive Web Design(RWD)?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this blog, we’ll talk about 5 ways to implement RWD.&lt;/p&gt;

&lt;p&gt;1. using media queries&lt;/p&gt;

&lt;p&gt;2. using flexbox&lt;/p&gt;

&lt;p&gt;3. using grid&lt;/p&gt;

&lt;p&gt;4. using relative units&lt;/p&gt;

&lt;p&gt;5. using packages/frameworks/libraries&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Media Queries:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Media queries allow developers to apply CSS styles depending on a device’s general type (such as print vs. screen) or other characteristics such as screen resolution or browser viewport width. Media queries are used for the following:&lt;/p&gt;

&lt;p&gt;· To conditionally apply styles with the CSS &lt;code&gt;@media&lt;/code&gt; and &lt;code&gt;@import&lt;/code&gt; at-rules.&lt;/p&gt;

&lt;p&gt;· To target specific media for the &amp;lt;style&amp;gt;, &amp;lt;link&amp;gt;, &amp;lt;source&amp;gt;, and other HTML elements with the media= attribute.&lt;/p&gt;

&lt;p&gt;· To test and monitor media states using the &lt;code&gt;Window.matchMedia()&lt;/code&gt; and &lt;code&gt;MediaQueryList.addListener()&lt;/code&gt; JavaScript methods.&lt;/p&gt;

&lt;p&gt;A media query is composed of an optional media type and any number of media feature expressions, which may optionally be combined in various ways using logical operators. Media queries are case-insensitive.&lt;/p&gt;

&lt;p&gt;A common approach when using Media Queries is to create a simple single-column layout for narrow-screen devices (e.g. smartphones), then check for wider screens and implement a multiple-column layout when you know that you have enough screen width to handle it. Designing for mobile first is known as &lt;strong&gt;mobile-first design.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Media type includes: all, screen, print (default is all)&lt;/p&gt;

&lt;p&gt;To begin with, you can simply start by writing the syntax as such:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since this is a beginner's guide, let's focus on using the screen as a media type only.&lt;/p&gt;

&lt;p&gt;We can specify some targeted features, i.e. we can specify some particular device width for which the designs will be different.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;480px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this snippet, &lt;code&gt;50px&lt;/code&gt; is applied to the &lt;code&gt;h1&lt;/code&gt; tag across all screens. However, whenever the device width is less than &lt;code&gt;480px&lt;/code&gt; (generally considered for small screens such as smartphones), the font size for all &lt;code&gt;h1&lt;/code&gt; tags would become &lt;code&gt;20px&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Combining multiple types or features:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;and&lt;/code&gt; keyword combines a media feature with a media type or other media features. This example combines a media type screen and two media features to restrict styles to portrait-oriented devices with a width of at most &lt;code&gt;480px&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;480px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orientation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;potrait&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;20px&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Testing for multiple queries&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You can use a comma-separated list to apply styles when the user’s device matches any one of various media types, features, or states. For instance, the following query will apply styles if the user’s device has either a minimum height of &lt;code&gt;780px&lt;/code&gt; &lt;em&gt;or&lt;/em&gt; is a &lt;code&gt;screen&lt;/code&gt; device in portrait mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;780px&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orientation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;potrait&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;20px&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Flexbox:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Flex layout offers a row/column-based one-dimensional layout where the items can &lt;em&gt;flex&lt;/em&gt;(expand) or shrink based on layout requirements.&lt;/p&gt;

&lt;p&gt;According to the available space in their container, flex elements in Flexbox can grow or shrink, redistributing space between them as necessary. You may specify how you want the objects to react when they meet more or less space by adjusting the values for &lt;code&gt;flex-grow&lt;/code&gt; and &lt;code&gt;flex-shrink&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The following example shows the container to occupy the entire width available based on the space. The children are distributed in a 1:2:1 ratio of width.&lt;/p&gt;

&lt;p&gt;If you’re new to Flexbox, I suggest reading about it from &lt;a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.child1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nc"&gt;.child3&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.child2&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;CSS Grid:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In CSS Grid Layout the &lt;code&gt;fr&lt;/code&gt; unit allows the distribution of available space across grid tracks. This example creates a grid container with three tracks sized at &lt;code&gt;1fr&lt;/code&gt;. This will create three column tracks, each taking one part of the available space in the container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The alignment can be changed to rows by simply replacing &lt;code&gt;grid-template-columns&lt;/code&gt; with &lt;code&gt;grid-template-rows&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you’re not familiar with the layout and structure of a grid, it’s recommended to learn more about it from &lt;a href="https://css-tricks.com/snippets/css/complete-guide-grid/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Using relative units&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;While mentioning sizes, we generally should avoid the use of absolute units like &lt;code&gt;px&lt;/code&gt;, &lt;code&gt;pt&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;Rather, the usage of relative units such as &lt;code&gt;%&lt;/code&gt;,&lt;code&gt;vw&lt;/code&gt;,&lt;code&gt;vh&lt;/code&gt;,&lt;code&gt;em&lt;/code&gt;,&lt;code&gt;rem&lt;/code&gt; should be encouraged to increase responsiveness with minimal amounts of code redundancy.&lt;/p&gt;

&lt;p&gt;Here are the relative units and their definitions, sourced from &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;em :&lt;/strong&gt; Font size of the parent, in the case of typographical properties like font-size, and font size of the element itself, in the case of other properties like width.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ex:&lt;/strong&gt; x-height of the element’s font.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ch :&lt;/strong&gt; The advance measure (width) of the glyph “0” of the element’s font.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;rem:&lt;/strong&gt; Font size of the root element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;lh:&lt;/strong&gt; Line height of the element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;rlh:&lt;/strong&gt; Line height of the root element. When used on the font-size or line-height properties of the root element, it refers to the properties’ initial value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vw:&lt;/strong&gt; 1% of the viewport’s width.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vh:&lt;/strong&gt; 1% of the viewport’s height.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vmin:&lt;/strong&gt; 1% of the viewport’s smaller dimension.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vmax:&lt;/strong&gt; 1% of the viewport’s larger dimension.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vb:&lt;/strong&gt; 1% of the size of the initial containing block in the direction of the root element’s block axis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;vi:&lt;/strong&gt; 1% of the size of the initial containing block in the direction of the root element’s inline axis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;svw, svh:&lt;/strong&gt; 1% of the small viewport’s width and height, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;lvw, lvh :&lt;/strong&gt; 1% of the large viewport’s width and height, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dvw, dvh:&lt;/strong&gt; 1% of the dynamic viewport’s width and height, respectively.&lt;/p&gt;

&lt;p&gt;An example might clear out any doubts about the usage of these units.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A875%2F1%2AQvFeieU6wKV4DLuM_fYQ7A.png%2520align%3D" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A875%2F1%2AQvFeieU6wKV4DLuM_fYQ7A.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.wrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;lem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.box&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#007bff&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.px&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.vw&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.em&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.rem&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.vh&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;l0vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Using frameworks/libraries/packages&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Several libraries like Bootstrap or Tailwind have predefined class names that enable the usage of responsive design.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- tailwind css !--&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"w-96 bg-white shadow rounded"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    w-96
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- bootstrap css !--&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-md-6"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        col-md-6
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can explore more on these on the official docs of Bootstrap and Tailwind.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A website or application that adapts to the environment in which it is viewed is said to have a responsive design. It includes many CSS and HTML capabilities and approaches and is now practically the only way we create webpages.&lt;/p&gt;

&lt;p&gt;With the aid of the layout techniques you have learned in these classes, it has also become much simpler to create responsive designs. Today, web developers have access to a far wider range of tools than they had in the early days of responsive design. Even while the older tutorials are still helpful, it is far simpler to develop beautiful and practical designs using contemporary CSS and HTML, regardless of the device a visitor is using to access the website.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
