<?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>DEV Community: Manjunath</title>
    <description>The latest articles on DEV Community by Manjunath (@blizzerand).</description>
    <link>https://dev.to/blizzerand</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%2F105133%2F06557a8b-7079-4988-807d-1a6eb72ed165.jpeg</url>
      <title>DEV Community: Manjunath</title>
      <link>https://dev.to/blizzerand</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/blizzerand"/>
    <language>en</language>
    <item>
      <title>How We Cut Our AI Costs by 80%—Without Losing Quality</title>
      <dc:creator>Manjunath</dc:creator>
      <pubDate>Wed, 26 Mar 2025 11:28:29 +0000</pubDate>
      <link>https://dev.to/blizzerand/how-we-cut-our-ai-costs-by-80-without-losing-quality-1meo</link>
      <guid>https://dev.to/blizzerand/how-we-cut-our-ai-costs-by-80-without-losing-quality-1meo</guid>
      <description>&lt;p&gt;When you run a startup, watching your burn rate is as critical as breathing. At CodeDesign.ai, our &lt;a href="https://codedesign.ai" rel="noopener noreferrer"&gt;AI-powered website builder&lt;/a&gt;, we found ourselves staring at a monthly AI bill that reached a painful $800. &lt;/p&gt;

&lt;p&gt;We weren't doing anything unusual to be honest, but we have a free tier - and most of our cost came at maintaining that free tier. For a bootstrapped founder like myself, every dollar matters, and spending almost a grand monthly just on AI didn't feel right. &lt;/p&gt;

&lt;h2&gt;
  
  
  🚗 Our Journey Through AI Providers
&lt;/h2&gt;

&lt;p&gt;We've tried almost every AI service out there. GPT-4o had been our go-to for months—powerful, usually reliable, but undeniably expensive. We experimented briefly with Claude, but quickly hit their restrictive Tier 1 limits to test further. Then we moved on to Deepseek. It was promising at first, but frequent downtime was frustrating. And back then they had limited support for tooling &amp;amp; function calling. I think that might no longer the case.&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%2Flzkik5omz712vi7fwyb7.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%2Flzkik5omz712vi7fwyb7.png" alt="Comparison of Website Builders" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, last month, we decided to try Google's Gemini 2.0 Flash, and honestly—it was a breath of fresh air.&lt;/p&gt;

&lt;h2&gt;
  
  
  ♊️ The Gemini Surprise
&lt;/h2&gt;

&lt;p&gt;Gemini Flash surprised us. We initially expected a trade-off—cheaper, sure, but would it match GPT-4o's quality? To our delight, Gemini not only matched GPT-4o—it often exceeded it, especially in terms of responsiveness and overall reliability. Even more astonishing: our monthly bill plummeted from nearly $800 to just $60, an 80% cost reduction.&lt;/p&gt;

&lt;p&gt;To put things into perspective, here's a quick cost comparison for leading AI models (approximate combined cost per million tokens, including both input and output):&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%2Fsik9vppv9b38yyuiji6y.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%2Fsik9vppv9b38yyuiji6y.png" alt="Cost comparison of AI Models" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We experimented with Claude Haiku and Gpt4o-mini, but conversions were subpar and the most of the worst feedback were collected for these two models.&lt;/p&gt;

&lt;h2&gt;
  
  
  💪🏼 Building a Robust Fallback System
&lt;/h2&gt;

&lt;p&gt;Here's how we made it even better:&lt;/p&gt;

&lt;p&gt;We built a simple but effective check algorithm that monitors the number of failed requests per minute. If Gemini Flash experiences any hiccups and the error rate exceeds our threshold, the system automatically switches requests first to Claude (which, despite its limits, works as a reliable backup), and then—if Claude also struggles—falls back to GPT-4o.&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%2Fb08z0fiw35k4st7eujm4.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%2Fb08z0fiw35k4st7eujm4.png" alt="Algorithm for switching &amp;amp; Fallback" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This backup system has been flawless, ensuring near-perfect uptime without manual intervention. And thanks to Gemini's impressive reliability, these fallback triggers are rarely activated. We've only seen it kick in a handful of times during traffic spikes, which gives us incredible peace of mind.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons for Other Startups 👀
&lt;/h2&gt;

&lt;p&gt;For anyone running AI-dependent services, here's a takeaway:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Switching to Gemini Flash was one of the best decisions we've made.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We didn't just cut costs—we enhanced reliability and improved our user experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It feels almost too good to be true (don’t tell Google we said that!).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My feedback for Google:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Gemini Pro’s limits are tight, and we'd love to see those expanded.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Their current quota system works for us now, but as we scale, I hope they grow with us.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Bottom Line: Lean Without Compromise
&lt;/h2&gt;

&lt;p&gt;To sum it up, running lean is vital for startups, and sometimes the answer isn't scaling back on quality or features but looking carefully at your tools. AI doesn't have to break the bank, and with the right approach, you might just find a gem (pun absolutely intended).&lt;br&gt;
Have you had similar experiences optimizing your AI expenses? I'd love to hear about your strategies! Drop a comment below or reach out—I'm always game to swap cost-saving hacks with fellow founders in the trenches.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>startup</category>
      <category>gemini</category>
      <category>openai</category>
    </item>
    <item>
      <title>Vector Search &amp; Code Embeddings: Building a Smart Knowledge Base with LangChain and FAISS</title>
      <dc:creator>Manjunath</dc:creator>
      <pubDate>Sun, 09 Mar 2025 08:10:58 +0000</pubDate>
      <link>https://dev.to/blizzerand/vector-search-code-embeddings-building-a-smart-knowledge-base-with-langchain-and-faiss-m48</link>
      <guid>https://dev.to/blizzerand/vector-search-code-embeddings-building-a-smart-knowledge-base-with-langchain-and-faiss-m48</guid>
      <description>&lt;p&gt;Hey dev.to community! 👋&lt;/p&gt;

&lt;p&gt;Last few months, I've been working on an open-source project called &lt;a href="https://intervo.ai" rel="noopener noreferrer"&gt;Intervo.ai&lt;/a&gt;—a voice agent platform for building interactive voice experiences.&lt;/p&gt;

&lt;p&gt;Early on, I faced a common issue: How can I build a smart, queryable knowledge base from tons of unstructured data? Enter the world of Vector Search, Embeddings, LangChain, and FAISS.&lt;/p&gt;

&lt;p&gt;In this detailed guide, I'll share exactly how I built this, some mistakes I made (hint: starting with JavaScript wasn't my brightest idea), and comprehensive Python code you can use immediately. We'll go from basic setup all the way through to advanced usage.&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%2Fpb96b0pcewfnpdo9d6dc.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%2Fpb96b0pcewfnpdo9d6dc.png" alt="A diagram depicting how Vector Database works" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is LangChain?
&lt;/h2&gt;

&lt;p&gt;LangChain is a robust framework designed to simplify developing AI-powered applications. It handles complex workflows involving language models, embeddings, context management, and integration with various vector databases. Essentially, LangChain removes the headache of manually wiring up components so you can focus on the interesting part—building your application logic.&lt;/p&gt;

&lt;p&gt;I initially started with LangChain.js, hoping to leverage my JavaScript expertise. But I soon realized that there is limited documentation and fewer features compared to its Python counterpart. I then decided to switch to Python. This turned out to be the right decision—Python's ecosystem around LangChain is richer, better maintained, and supported by extensive community examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Primer: Understanding Vectors and Embeddings
&lt;/h2&gt;

&lt;p&gt;Vector embeddings are numerical representations of data (e.g., code snippets, documents, user queries) that capture the semantic meaning. These vectors position similar data points closer in vector space, making similarity searches efficient and accurate.&lt;/p&gt;

&lt;p&gt;FAISS (Facebook AI Similarity Search) is an optimized vector database library designed for high-performance similarity searches. It efficiently manages millions of vectors, making it ideal for both prototyping and scaling production apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Setting up Your Python Environment
&lt;/h3&gt;

&lt;p&gt;First, create and activate your Python environment. Then, install the necessary packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;langchain faiss-cpu openai python-dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Package Breakdown:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;langchain&lt;/strong&gt;: Manages chaining of language models, embedding generation, and simplifies integration with vector stores.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;faiss-cpu&lt;/strong&gt;: Provides lightning-fast similarity search capabilities optimized for CPU.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;openai&lt;/strong&gt;: Enables easy interaction with OpenAI's API to generate embeddings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;python-dotenv&lt;/strong&gt;: Conveniently manages environment variables like API keys.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your &lt;code&gt;requirements.txt&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;langchain
faiss-cpu
openai
python-dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create an Environment File
&lt;/h3&gt;

&lt;p&gt;Save your OpenAI API key securely in a &lt;code&gt;.env&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OPENAI_API_KEY=your_openai_api_key_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building Your RAG Service
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Understanding the Components:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Trainer&lt;/strong&gt;: Prepares your data by splitting it into semantic chunks, embedding these chunks, and storing them in FAISS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query&lt;/strong&gt;: Retrieves the most relevant data chunks based on user queries by leveraging similarity search.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Chunking Strategy
&lt;/h3&gt;

&lt;p&gt;Effective chunking ensures optimal results from vector searches. LangChain's &lt;code&gt;RecursiveCharacterTextSplitter&lt;/code&gt; splits text intelligently without breaking the semantic context, making it ideal for this task.&lt;/p&gt;

&lt;p&gt;Here's the complete implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.text_splitter&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RecursiveCharacterTextSplitter&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.embeddings&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAIEmbeddings&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.vectorstores&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FAISS&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.docstore.document&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Document&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RagService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;embedding_model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text-embedding-ada-002&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text_splitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RecursiveCharacterTextSplitter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chunk_overlap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAIEmbeddings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;embedding_model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;openai_api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;train_from_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input_string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page_content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;input_string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;chunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text_splitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split_documents&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FAISS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save_local&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;faiss_index&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;top_k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FAISS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load_local&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;faiss_index&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;similarity_search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;top_k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Practical Example Usage
&lt;/h3&gt;

&lt;p&gt;Here's how you'd practically integrate and run the above class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;rag_service&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RagService&lt;/span&gt;

&lt;span class="c1"&gt;# Initialize the service
&lt;/span&gt;&lt;span class="n"&gt;rag_service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RagService&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Train your model with a detailed string input
&lt;/span&gt;&lt;span class="n"&gt;training_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
React is a popular JavaScript library for building user interfaces. It manages state efficiently using hooks like useState, useEffect, and useReducer. Global state management can be handled through libraries like Redux, MobX, Zustand, or the built-in Context API.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;span class="n"&gt;rag_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;train_from_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;training_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Perform a query
&lt;/span&gt;&lt;span class="n"&gt;query_result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rag_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How do you manage global state in React?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Relevant results:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;query_result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;page_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Running Your Example
&lt;/h3&gt;

&lt;p&gt;Store your class in &lt;code&gt;rag_service.py&lt;/code&gt;. Then execute the example by creating &lt;code&gt;run_example.py&lt;/code&gt; with the provided script and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python run_example.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Personal Reflection
&lt;/h2&gt;

&lt;p&gt;Initially, I anticipated building a RAG service to be challenging, but the combination of LangChain and FAISS dramatically streamlined the process. Switching to Python from JavaScript was a pivotal moment that highlighted the importance of selecting the right tool ecosystem for your needs.&lt;/p&gt;

&lt;p&gt;Through this journey, I realized the immense potential of embeddings and vector databases in creating responsive, intelligent systems that feel genuinely "smart".&lt;/p&gt;

&lt;h2&gt;
  
  
  A Subtle Plug for Intervo
&lt;/h2&gt;

&lt;p&gt;If you’re excited about creating smart conversational systems or voice-enabled experiences, check out &lt;a href="https://github.com/Intervo-ai" rel="noopener noreferrer"&gt;Intervo&lt;/a&gt;. It’s a soon-to-be-released open-source project aimed at simplifying the development of voice assistants and interactive voice-based applications.&lt;/p&gt;

&lt;p&gt;Thank you for sticking with me through this detailed guide! I'm curious—how are you using vector databases or LangChain in your projects? I'd love to chat about your experiences or answer any questions you might have. 🚀&lt;/p&gt;

</description>
      <category>vectordatabase</category>
      <category>rag</category>
      <category>voiceai</category>
      <category>langchain</category>
    </item>
    <item>
      <title>Best Practices of Agile Database Development</title>
      <dc:creator>Manjunath</dc:creator>
      <pubDate>Mon, 08 Apr 2019 03:53:59 +0000</pubDate>
      <link>https://dev.to/blizzerand/best-practices-of-agile-database-development-2fi8</link>
      <guid>https://dev.to/blizzerand/best-practices-of-agile-database-development-2fi8</guid>
      <description>&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fv4fu1ocmwjgjj0pzxrt1.jpeg" 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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fv4fu1ocmwjgjj0pzxrt1.jpeg" title="image_tooltip" alt="Agile Development" width="800" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When done in the proper manner and with suggested methods, Agile Development can transform the delivery of systems. This allows users to receive what they require, much closer to when they need it.&lt;/p&gt;

&lt;p&gt;Unfortunately, the training, resources and work practices related to databases tend to stick to less effective methods. These result in a more significant cost incurred to government and business organizations as well as giving database-derived products a bad reputation the market. &lt;/p&gt;

&lt;p&gt;Even though a vast majority of application developers consider agile to be a mainstream approach, many developers specializing in databases, especially relational databases, have remained slower in adopting the agile methodology. This can be attributed mainly to the lack of understanding of the state of a database at the time of change deployment. &lt;/p&gt;

&lt;p&gt;This has resulted in database professionals having to rely on manual processes that are unable to reach the level of agile when it comes to quicker developmental cycles.&lt;/p&gt;

&lt;p&gt;Until database development processes, especially the development of relational databases includes SQL Server, Oracle, and DB2, do not scale up to a higher level, they will continue to be a bump in the road for otherwise agile organizations.&lt;/p&gt;

&lt;p&gt;Eliminating such bottlenecks needs automated data pipelines that development teams can address risk areas, ensure a quality standard and fasten the development cycle of businesses altogether. To this end, here are some key areas to focus on when it comes to the development of Agile Databases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices of Agile Database Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Version Control
&lt;/h3&gt;

&lt;p&gt;The role of version control is entirely different when it comes to &lt;a href="https://www.enterprisedb.com/edb-postgres-cds" rel="noopener noreferrer"&gt;cloud database development&lt;/a&gt; projects. However, it remains a meaningful way to track changes to&lt;a href="https://en.wikipedia.org/wiki/Data_definition_language" rel="noopener noreferrer"&gt; data definition language (DDL)&lt;/a&gt; at each stage.&lt;/p&gt;

&lt;p&gt;The ability to track revisions made to saved procedures and functions over time makes it simple when users need to assess or compare them against one another to identify and flag possible problems that may crop up during production.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automated Testing
&lt;/h3&gt;

&lt;p&gt;Manual testing is comprehensively slower than automated testing. &lt;a href="https://www.guru99.com/difference-automated-vs-manual-testing.html" rel="noopener noreferrer"&gt;Automated testing&lt;/a&gt; provides developers with a safety net when it comes to accelerating database deployments as automated testing offers an almost instantaneous assurance that modifications will work as intended. &lt;/p&gt;

&lt;p&gt;Additionally, automation allows the execution of the process at the point of check-in. Developers are notified via immediate feedback whenever a break occurs and suggestions as to the best possible way to fix the problem and what the expected cost would be to troubleshoot the break. &lt;/p&gt;

&lt;h3&gt;
  
  
  Analysis of Static Code
&lt;/h3&gt;

&lt;p&gt;In most cases, developers put their code through a peer review process. This is to make sure that the system they have developed has not missed a possible security vulnerability, miscalculated a logic or unintentionally slowed down the logic of the code. &lt;/p&gt;

&lt;p&gt;Static code analysis allows the software in question to speed up the process significantly and makes sure that it is in line with specific standards set by the company. Static code analysis reads through the code and identifies similar patterns that peer developers are searching for.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Stage for Deployment
&lt;/h3&gt;

&lt;p&gt;To reduce the danger of mishaps like loss of data, in most cases, the database development path includes a DBA in the deployment stage. This is to review the changes to code before when it goes into production. &lt;/p&gt;

&lt;p&gt;While the process of automating the DBA stop may not always be a good idea, ensuring that the automation of the creation of &lt;a href="https://www.techopedia.com/definition/32178/alter-script" rel="noopener noreferrer"&gt;ALTER scripts&lt;/a&gt; for deployment helps to save a valuable step when attempting to quicken the overall development cycle. &lt;/p&gt;

&lt;p&gt;DBAs are used to manage the deployment path and can be utilized when attempting to automate tools that are used to collect the relevant queued changes, which have been passed through different regression tests as well as static code analysis. This is then compared to the respective production environment to generate the scripts that can then be used to commit them. &lt;/p&gt;

&lt;p&gt;This improves DBA efficiency as well as shortens the development cycle. It also makes sure that the changes specified in the project make it through unscathed into the production stage. &lt;/p&gt;

&lt;h3&gt;
  
  
  Automation
&lt;/h3&gt;

&lt;p&gt;As organizations move away from various manual processes in favor of automated tools, database development cycles begin to shrink while teams understand the advantages of agile. &lt;/p&gt;

&lt;p&gt;The usage of different software tools in a systematic method makes the overall method much faster and more efficient with incremental improvements. &lt;/p&gt;

&lt;h3&gt;
  
  
  Don't Neglect Product Testing
&lt;/h3&gt;

&lt;p&gt;In today's day and age, companies are often pushed to move products to the market. The competitive reasons for this focus are clear enough. However, the possible problems that may crop up as a result of a quick path to production of release versions may not be as clear as they should be. &lt;/p&gt;

&lt;p&gt;Software that has been released without the due tests and checks may result in hiccups such as security flaws, poor quality as well as problems surrounding ease of use. Among the ways this can be circumvented include, the thorough testing of software and associated products before they are released to the market for general consumption.&lt;/p&gt;

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

&lt;p&gt;Teams can very merely take advantage of Agile methods when it comes to the testing processes. As a report by the research company 'Frost &amp;amp; Sullivan' observed in May of last year, 'The software market is developing new products based in large part on IT trends like the rise in popularity of 'Big Data' and 'Internet of Things.' This is leading to a shift in the testing market. The concerned is expected to grow at a rate of 14% CAGR in the coming few years, thanks in large part to DevOps and Agile concepts.&lt;/p&gt;

&lt;p&gt;When it comes to Agile, testing has been embedded within the development process. Software developers have been trained to develop tests before or side by side with the code they write. This ensures that the method of flagging and isolating the process is not overlooked. This is an especially aspect of testing given the dynamism of software product development. &lt;/p&gt;

&lt;p&gt;Many different methods of software testing exist within Agile. These include Behavior Driven Development (BDD), Exploratory Testing, as well as Acceptance Test Driven Development. It is critical for concerned teams to understand how to choose the most appropriate method to meet the standards and requirement of their organization(s).&lt;/p&gt;

&lt;p&gt;Similar to other areas within Agile, it is essential to have the right mapping in place when it comes to people and their roles and responsibilities throughout the different phases of the development lifecycle.  &lt;/p&gt;

&lt;p&gt;Where Agile has been implemented using the established best practices, Agile can result in - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An improved level of team collaboration&lt;/li&gt;
&lt;li&gt;A close collaboration between development teams and end-users of the software&lt;/li&gt;
&lt;li&gt;An increased likelihood of customer satisfaction with regards to the end product&lt;/li&gt;
&lt;li&gt;An accelerated path of development for new software products and its features&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>5 Trends in Software Testing that You Should Know About</title>
      <dc:creator>Manjunath</dc:creator>
      <pubDate>Wed, 27 Feb 2019 08:35:11 +0000</pubDate>
      <link>https://dev.to/blizzerand/5-trends-in-software-testing-that-you-should-know-about-1d08</link>
      <guid>https://dev.to/blizzerand/5-trends-in-software-testing-that-you-should-know-about-1d08</guid>
      <description>

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hmFAerbR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/szk8z5v6t4yn0vo6xyim.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hmFAerbR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/szk8z5v6t4yn0vo6xyim.jpg" alt="Featured Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Modern web and mobile components are among the fastest and most frequently updated software packages for users as well as businesses. It, therefore, is in need of constant and steady testing before deployment. &lt;/p&gt;

&lt;p&gt;While the benefit of automation in allowing teams to reduce the number of manual testing efforts and increase testing to ensure efficient operations, it also significantly reduces the number of repetitive processes that need to be performed manually. &lt;/p&gt;

&lt;p&gt;During the last decade, there has been a lot of activity in the field of mobile computing, web development &amp;amp; AI. There has been an increased adoption of API architecture. Server-side logic are designed with the help of APIs making them accessible to the general public. Frontend code has seen a shift towards JavaScript-oriented platforms for both Mobile &amp;amp; Web. &lt;/p&gt;

&lt;p&gt;Given that some details tend to vary with different stacks, this article attempts to list down some of the more general trends in software testing in 2018. &lt;/p&gt;

&lt;h2&gt;
  
  
  API and Microservices Test Automation
&lt;/h2&gt;

&lt;p&gt;A microservice is necessarily a way to develop software specifically designed to test for pre-defined conditions. These types of services can be simulated, and when a connection is established between them, the complete task of testing can be categorized into different parts. &lt;/p&gt;

&lt;p&gt;In this case, each service is designed in a manner to enable it to perform a particular set of tasks. This allows users and developers the freedom to modify a smaller area of the application where the change is required rather than modifying the whole system altogether. You can go with&lt;a href="https://softwareengineering.stackexchange.com/questions/252748/is-it-actually-worth-unit-testing-an-api-client"&gt; unit tests&lt;/a&gt; or a variant of integration tests for microservices because each service or API endpoint can be treated as an individual unit. &lt;/p&gt;

&lt;h2&gt;
  
  
  Adoption of Open Source Test Suites and Tools
&lt;/h2&gt;

&lt;p&gt;Open source software tools are especially helpful for organizations, and&lt;a href="https://opensource.com/article/17/11/10-open-source-technology-trends-2018"&gt; trends indicate they are here to stay&lt;/a&gt;. There are a host of different advantages of making use of open source tools besides the cost aspect, as it is usually free for the public to use. &lt;/p&gt;

&lt;p&gt;Open source software tools are easily customizable, much more flexible and are open to the general public. At the same time, as designers have a say in its design, users get to design it in a way they require while also allowing for multiple integrations with powerful test automation features. &lt;/p&gt;

&lt;p&gt;Some of the commonly used AI/web &amp;amp; mobile development frameworks are built open-source components. Chances are, most of the test frameworks that you're using already are open-source. &lt;/p&gt;

&lt;p&gt;An oft-discussed point though is the aspect of security vulnerabilities. As open source tools are, by definition, open to the public, but that doesn't make them strictly more secure than a proprietary alternative. However, it is also true that open source tools have multiple sets of eyes reviewing versions of code and, therefore, the chances of locating and fixing a potential bug increases substantially. &lt;/p&gt;

&lt;p&gt;An increasing number of companies are accepting open source software services for executing the testing of their management, automation, DevOps and Agile tactics along with the responsibility of defect management. This has the potential to lead to the development and growth of open support communities for open source tools as they become increasingly active. &lt;/p&gt;

&lt;h2&gt;
  
  
  Shift-Left and Shift-Right Testing
&lt;/h2&gt;

&lt;p&gt;When discussing quality software for DevOps processes, two essential parameters come to point – &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Shift-Left Testing – When testing is a part of Continuous Integration or CI.&lt;/li&gt;
&lt;li&gt;Shift-Right Testing – Where testing is expanded based on feedback received from users.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Shift-Left Testing
&lt;/h3&gt;

&lt;p&gt;Shift-left testing is a scenario that is laid down during the testing of specific product features needed to meet the product acceptance criteria as well as the assumptions that are pending validation to meeting business acceptance criteria. &lt;/p&gt;

&lt;p&gt;In simpler words,&lt;a href="https://resources.whitesourcesoftware.com/blog-whitesource/shift-left-the-software-development-seismic-shift"&gt; shift-left testing&lt;/a&gt; refers to defining tests prior to building the product features. Shift-left testing is essential for developing quality software with speed and efficiency. &lt;/p&gt;

&lt;p&gt;Most organizations find it challenging to deploy a fresh patch for an application. Rigorous levels of testing need to be undertaken, either via functional or regression testing. This ensures that the patch update does not destabilize the existing system. &lt;/p&gt;

&lt;p&gt;If testing begins earlier in the production cycle, teams are generally more concentrated on quality. This saves a lot of staff-hours and decreases the amount iterations needed during software development. &lt;/p&gt;

&lt;h3&gt;
  
  
  Shift-Right Testing
&lt;/h3&gt;

&lt;p&gt;Though testing during the early stages of the application's lifecycle is essential, it is by no means enough. A continuous stream of feedback from users is as crucial and that is where &lt;a href="https://techbeacon.com/shift-right-test-microservices-wild-tame-devops"&gt;shift-right testing&lt;/a&gt; comes in. &lt;/p&gt;

&lt;p&gt;Some aspects are not always within a developer's or engineer's purview and can get forgotten. A ready to be deployed application cannot afford to have such a failure, and shift-right testing helps iron out these creases before an application is publicly deployed.&lt;/p&gt;

&lt;p&gt;Shift-right testing allows for the usability and performance of an application to be monitored continuously. A tester should be aware of how users perceive the application even at the stage of information or requirement gathering. The focus here is to cover as much ground as possible during testing. &lt;/p&gt;

&lt;h2&gt;
  
  
  Quality Engineering over Quality Assurance
&lt;/h2&gt;

&lt;p&gt;With the constant change in the world of software development, there is never-ending talking about new technology being floated in the market. Quality Assurance or QA is a process that follows a guided waterfall approach when it comes to software testing. It is a step by step process designed to make QA thorough but time-consuming. &lt;/p&gt;

&lt;p&gt;This is part of the reason why QA is fighting a losing battle to keep pace with the ever-changing dynamics present in software testing. It is true that the QA process can also be a bottleneck at times when it comes to completing an application's development lifecycle. &lt;/p&gt;

&lt;p&gt;Because of its natural step by step process, the QA process cannot proceed from one level to the other, until the previous phase (s) are completed and validated. &lt;/p&gt;

&lt;p&gt;This is one of the prime reasons why a lot of QA processes and data pile up. When it comes to Quality Engineering, on the other hand, testing and automation can be brought in earlier in the process instead of at the final acceptance stage. &lt;/p&gt;

&lt;p&gt;The improvement ideas for the QA process in 2018 couldn't be brought about without the latest developing trends in software development. As a simple rule, the better the UX, the higher are the chances for it being used as a System/Software Performance Engineering or SPE instead of Process testing. &lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating Tests for Mobile Devices
&lt;/h2&gt;

&lt;p&gt;Mobile apps are an integral part of an individual's day. Testing application isn't just about testing the app logic, there are other details that are identically important. For instance, you need to verify whether the UI &amp;amp; UX actions are rendered as expected and whether it's responsive. The sheer types of devices, number of updates to the app and the platform software play a part in increasing its complexity. Your options for testing a mobile app from an enterprise perspective includes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unit testing&lt;/li&gt;
&lt;li&gt;UI testing&lt;/li&gt;
&lt;li&gt;Fuzz testing&lt;/li&gt;
&lt;li&gt;Performance testing&lt;/li&gt;
&lt;li&gt;End-to-end testing&lt;/li&gt;
&lt;li&gt;Pre-production testing&lt;/li&gt;
&lt;li&gt;Canary (post-production) testing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can read more about the &lt;a href="https://medium.com/@FizzyInTheHall/testing-mobile-apps-a-primer-889f62a85e40"&gt;7 test scenarios on Medium&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As cost considerations and market readiness play a more critical role in times to come, mobile app testing automation should come into its own. Constant and continuous innovation is essential for consistent growth, and this is difficult to achieve without Continuous Testing using a combination of above-mentioned techniques. These platforms will assist developers and testers check for issues and bugs before the testing process. &lt;/p&gt;

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

&lt;p&gt;The increasing penetration of mobile devices has resulted in quite a happy headache for app developers and QA testers. This growth comes hand in hand with newer technologies for software testing and the overall development in the mobile industry. &lt;/p&gt;

&lt;p&gt;Testers need to enhance their skills continuously, entrepreneurs need to be guided by the best choice for their products and solutions and organizations need to give preference to a robust testing process. This is to ensure near perfect apps and solutions to customers and end-users.&lt;/p&gt;

&lt;p&gt;The evolving testing trends will continue to ask questions and pose challenges to mobile testers and will continue to take development down the path of cost-efficiency and effectiveness. When combined with a sufficient amount of testing and technical expertise in this field, the software technologies to come in future should be best poised to provide in-depth and unbiased Quality Assurance.&lt;/p&gt;


</description>
      <category>testing</category>
      <category>softwaretesting</category>
      <category>opensource</category>
    </item>
    <item>
      <title>React Basics – State, Props &amp; Functional Components</title>
      <dc:creator>Manjunath</dc:creator>
      <pubDate>Mon, 04 Feb 2019 14:39:25 +0000</pubDate>
      <link>https://dev.to/blizzerand/react-basics--state-props--functional-components-5cll</link>
      <guid>https://dev.to/blizzerand/react-basics--state-props--functional-components-5cll</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;React is among the more popular front-end libraries in use today. However, beginners might find it hard to get started with the concept in React because they're different compared to traditional programming concepts like that of Java. Different aspects like how components work, component composition and hierarchy, state, props, and functional programming concepts need to be considered beforehand. This guide attempts to make things simpler by providing readers with an easy and simple way to start using React. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up React
&lt;/h2&gt;

&lt;p&gt;There are two popular ways to set up React. If you're looking to set up React real quick, you can use the one-page setup by including the scripts from unpkg.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://unpkg.com/react@16/umd/react.development.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Otherwise, you can set up the React environment by running create-react-app:&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-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can also use yarn.  \&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn create react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the structure of files created by yarn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-app
├── README.md
├── node_modules
├── package.json
├── .gitignore
├── public
│   ├── favicon.ico
│   ├── index.html
│   └── manifest.json
└── src
    ├── App.css
    ├── App.js
    ├── App.test.js
    ├── index.css
    ├── index.js
    ├── logo.svg
    └── serviceWorker.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To start your application, you'll need to run npm run start or yarn start. &lt;/p&gt;

&lt;h2&gt;
  
  
  Components
&lt;/h2&gt;

&lt;p&gt;Components are the building blocks of a React application. You can build your entire application using just components. They are reusable and independent blocks of code.  They're are two types of Components and the classification is popularly known under different names: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Class vs Functional Component&lt;/li&gt;
&lt;li&gt; Smart vs. Dumb components&lt;/li&gt;
&lt;li&gt; Container vs. Presentational components&lt;/li&gt;
&lt;li&gt; Stateful vs. Stateless components&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Although the components are known under different names, the basis of classification is relatively similar. Class components use ES6 classes whereas Functional components are based on JavaScript functions. &lt;/p&gt;

&lt;p&gt;Since the central aspect of React is components, a better &lt;a href="https://storylens.com/@manjunath/how-to-organize-react-components-ac2e2" rel="noopener noreferrer"&gt;understanding of how to organize components in React&lt;/a&gt; is essential. We'll cover that in this article by defining the differences between functional components and class components. Here's a basic example that demonstrates the difference between them.&lt;/p&gt;

&lt;p&gt;Replace the src/App.js with the following lines: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tr&gt;
   &lt;td&gt;
&lt;code&gt;class App extends Component { \
  &lt;/code&gt;
&lt;p&gt;
&lt;code&gt;  render() { \
       const message = `This is the App Component.`; \
    return ( \
      &amp;lt;&lt;strong&gt;div&lt;/strong&gt;&amp;gt;{message}&lt;strong&gt;div&lt;/strong&gt;&amp;gt; \
    ); \
  } \
}&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The App component here is an ES6 class and hence we'll call them class components. It extends the Component class which is a part of the React API. It contains a 'render' method which comprises a return statement. Everything inside the return statement is rendered in the browser. You can render HTML elements or other components (read Composition Hierarchy). &lt;/p&gt;

&lt;p&gt;If you remove the render method, React will throw an error because the class component needs to include a render method. However, other methods are optional. ReactDOM.render() renders the App component in a div element using the id 'root'. &lt;/p&gt;

&lt;p&gt;But remember, this is not the only way that you can create components. You can also use functional components as follows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tr&gt;
   &lt;td&gt;
&lt;code&gt;function App(props){&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;   const message = `This is the App Component.`; \
   return &amp;lt;&lt;strong&gt;div&lt;/strong&gt;&amp;gt;{message}&lt;strong&gt;div&lt;/strong&gt;&amp;gt; \
}&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So, the next obvious question is, what are props?&lt;/p&gt;

&lt;h3&gt;
  
  
  Props
&lt;/h3&gt;

&lt;p&gt;Props refer to properties that are passed to child components by the parent components. For instance, if you need to pass a value from a parent component to a child component, you can pass them down as properties or props.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends React.Component {
 render() {
  return &amp;lt;Child value="SOS" /&amp;gt;;  
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Child extends React.Component{
 render(){
  return &amp;lt;h3&amp;gt;The value passed from parent is {this.props.value}&amp;lt;/h3&amp;gt;;
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can replace the class component we created earlier with this functional component and it will appear just the same in the browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Child (props) {
 return &amp;lt;h3&amp;gt;The value passed from parent is {props.value}&amp;lt;/h3&amp;gt;;
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, why do we have two different types of components when you can stick with just one? That's because class components have certain features that are bestowed upon them whereas functional components lack these features. &lt;/p&gt;

&lt;h2&gt;
  
  
  Functional Components
&lt;/h2&gt;

&lt;p&gt;Functional components have very little baggage compared to the more popular class components. They're theoretically faster than class components, but that might not be relevant if you're running a small application with very limited components. &lt;/p&gt;

&lt;p&gt;The drawbacks with Functional component is that you can't use the state and lifecycle hooks inside functional components. Instead, they're meant to be just presentational component without any logic of their own. Unlike class components, you can't also use componentDidMount and other similar lifecycle hooks. But instead, you can wrap a part of your web UI as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Button = props =&amp;gt; (
   &amp;lt;button className="our_button" onClick={props.onClick}&amp;gt;
      {props.label}
   &amp;lt;/button&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are a few good things about functional components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; They are reusable compared to class components&lt;/li&gt;
&lt;li&gt; Functional components can potentially have a better performance&lt;/li&gt;
&lt;li&gt; They're easy to debug&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, you can wrap your buttons, input fields etc. inside functional components and pass everything that's required by that component as props. However, certain other logic involves making API calls and then storing the result in the state. That's where class component come in handy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Class Components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  State
&lt;/h3&gt;

&lt;p&gt;Similar to Props, the state also contains data, however, with a few differences.&lt;/p&gt;

&lt;p&gt;Props contain data that are communicated by the parent component. On the other hand, the state contains private data that's local to the component. Unlike props which are read-only value, State is readable and writable by the component. It stores data that changes between different renderings of the component.&lt;/p&gt;

&lt;p&gt;Here is an example -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends React.Component {
 constructor(){
  super();
  this.state = {name :"Foo Bar"};
 }
 changeName(){
  this.setState({name : "Lorem Ipsum"});
 }

 render(){
  return (
   &amp;lt;div&amp;gt;
     &amp;lt;h3&amp;gt;Hello {this.state.name}&amp;lt;/h3&amp;gt;
     &amp;lt;button type='button' onClick=this.changeName.bind(this)}&amp;gt;
      Save
     &amp;lt;/button&amp;gt;
   &amp;lt;/div&amp;gt;
  );
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As demonstrated in the example above, once a constructor is initialized, it can be used in a render method. Similar to props, the state can be accessed via the 'this.state' object. On clicking the Save button, users are able to change the value name of the state to their choosing. this.setState() takes care of updating the state.&lt;/p&gt;

&lt;h3&gt;
  
  
  setState()
&lt;/h3&gt;

&lt;p&gt;this.setState() is a part of the React API that's used to modify the state. This is available in React Component by default and is pretty much the only way to change state. When an object is being passed as a parameter to setState, React asynchronously make changes to the state by modifying the keys that are passed to it.  React will look at the passed object and will change only the provided keys of the state with the provided values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Life Cycle Methods
&lt;/h2&gt;

&lt;p&gt;React provides users with specific special methods known as Life Cycle Hooks. These life cycle hooks execute at specific times in the life cycle of a component. Fortunately, users have the ability to include their own functionality in these life cycle hooks. You can define lifecycle hooks inside the components to define what a component does when it mounts, receives new props, unmounts etc. Here are some examples of commonly used life cycle hooks.&lt;/p&gt;

&lt;h3&gt;
  
  
  componentDidMount()
&lt;/h3&gt;

&lt;p&gt;Mounting refers to the time taken when the component is initially rendered in the browser. componentDidMount() executes after the component is mounted. This is a good place to fetch specific data or initiate anything.&lt;/p&gt;

&lt;p&gt;Here is an example of the events that happen when a component mounts. \&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Data gets fetched by making a call to a API endpoint&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The response is being stored into the state using this.setState()&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; componentDidMount(){
    componentDidMount() {
    fetch(API + DEFAULT_QUERY)
      .then(response =&amp;gt; response.json())
      .then(data =&amp;gt; 
         this.setState({ 
           person: 
               {
                name: data.name, age: data.age
               }
        })
     );
    }
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  \
&lt;/h3&gt;

&lt;p&gt;componentWillUnMount()&lt;/p&gt;

&lt;p&gt;This gets executed just before the component unmounts. If you want to clear some global state (stored in Redux store) or remove some event listener, this should be the where your code goes.&lt;/p&gt;

&lt;p&gt;For instance, if you've set up an event listener like for scroll, you can remove it as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;componentWillUnmount() {
       window.removeEventListener('scroll', this.onScroll, false);
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  componentDidUpdate()
&lt;/h3&gt;

&lt;p&gt;As the name suggests, componentDidUpdate() executes once the component is completely updated. This is where data changes and related modifications are handled. It may be possible that users may need to handle specific network requests, or perform calculations based on the changed data. In scenarios like this, componentDidUpdate() is the place to be.&lt;/p&gt;

&lt;p&gt;Here is an example of this in action –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends React.Component {
 constructor(){
  super(); 
  this.state = {
   person : {name : "" , age : ""}
  };
 }
 componentDidMount(){
    componentDidMount() {
    fetch(API + DEFAULT_QUERY)
      .then(response =&amp;gt; response.json())
      .then(data =&amp;gt; 
         this.setState({ 
           person: 
               {
                name: data.name, age: data.age
               }
        })
     );
    }
 }

componentDidUpdate(prevProps) {
  // Typical usage (don't forget to compare props):
  if (this.props.person.name !== prevProps.person.name) {
    this.fetchData(this.props.name);
  }
}


 render(){
  return (
   &amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;Name : {this.state.person.name}&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;Age : {this.state.person.age}&amp;lt;/p&amp;gt;
   &amp;lt;/div&amp;gt;
  );
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our first state consists of two distinct properties, viz. name and age, Both of these have an empty string as value. In componentDidMount() users can set the state and modify the name as needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Words - Choosing the right component
&lt;/h2&gt;

&lt;p&gt;So, how do you choose between functional components and class components? I usually start with functional components and then shift to class components if either state or component life cycles is required. If not, you can just stick with functional components. &lt;/p&gt;

&lt;p&gt;You can use functional components for anything that doesn't require state or is meant to serve as a UI element. If it has complex logic, then you should probably fit it inside a class component. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>components</category>
    </item>
    <item>
      <title>Deploying An Express Application - 6 Best Practices for Improving Security</title>
      <dc:creator>Manjunath</dc:creator>
      <pubDate>Sun, 30 Sep 2018 08:31:50 +0000</pubDate>
      <link>https://dev.to/blizzerand/deploying-an-express-application---6-best-practices-for-improving-security-5hmn</link>
      <guid>https://dev.to/blizzerand/deploying-an-express-application---6-best-practices-for-improving-security-5hmn</guid>
      <description>&lt;p&gt;Deployment is the final phase of software development lifecycle when an application or an API is readily available to consumers and end users. Unlike the development phase where the application is in active development, once deployed, the application could be under potential risks because the endpoints are exposed.  &lt;/p&gt;

&lt;p&gt;The environments for both development and production generally have a different set up as they have distinct requirements. What is required at the development stage may not be essential when it comes to production. To take an example, in a development stage, a verbose log of errors to help in debugging efforts may have the highest priority, however, at the production stage, security concerns become a priority. &lt;/p&gt;

&lt;p&gt;Similarly, at the development stage, scalability, performance or reliability are not areas that you need to address, however, these become critical at the production stage.&lt;/p&gt;

&lt;p&gt;In this post, we'll address some of these issues and cover everything that you need know about deployment best practices. &lt;/p&gt;

&lt;h2&gt;
  
  
  Usage of Deprecated or Vulnerable Versions of Express
&lt;/h2&gt;

&lt;p&gt;If you are still using Express 2.x or Express 3.x, you should know that these are no longer actively maintained or monitored. Therefore, it might not be best idea to use them. In case you have not already moved to version 4.0, you can follow the &lt;a href="https://expressjs.com/en/guide/migrating-4.html" rel="noopener noreferrer"&gt;migration guide here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, you need to make sure that you are not using any versions of Express that are known to be vulnerable. You can see these listed on the &lt;a href="https://expressjs.com/en/advanced/security-updates.html" rel="noopener noreferrer"&gt;Security Updates page&lt;/a&gt; – If you are, you need to update to one of the latest stable releases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use TLS for Encryption
&lt;/h2&gt;

&lt;p&gt;In case the app you are developing uses sensitive data, it is best to use Transport Layer Security or TLS. TLS can be used to secure your connection as well as data. &lt;/p&gt;

&lt;p&gt;TLS encrypts data before it is transmitted from the client to the server. This prevents most common and easy hacks. &lt;/p&gt;

&lt;p&gt;Given that Ajax and POST requests at times are not visibly obvious and may seem 'hidden' at the browser level, the network traffic they generate is open to packet sniffing as well as man-in-the-middle attacks. You may already be familiar with SSL encryption, however, TLS can be considered as a more advanced version. I&lt;/p&gt;

&lt;p&gt;f you are already using SSL, you might want to consider upgrading to TLS. Our recommendation is that you use Nginx to handle TLS. As a reference you can have a look at- Another useful tool to acquire a free TLS certificate is &lt;a href="https://letsencrypt.org/about/" rel="noopener noreferrer"&gt;'Let's Encrypt&lt;/a&gt;' . This is a free, automated and open source certificate authority brought to you by the ISRG, Internet Security Research Group.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Helmet For Protection Against Vulnerabilities
&lt;/h2&gt;

&lt;p&gt;Helmet is a handy tool when it comes to protecting your app from commonly known web vulnerabilities. Its safeguard is to ensure the most appropriate setting for HTTP headers.&lt;/p&gt;

&lt;p&gt;Coming down to the basics, Helmet is not much more than a collection of 9 smaller middleware functions that define security related HTTP headers. These include – &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Csp – Sets the content-security-policy header to assist in preventing cross-site script attacks and various other inter site injections&lt;/li&gt;
&lt;li&gt; hidePoweredBy – This eliminates X-Powered-By header&lt;/li&gt;
&lt;li&gt; Hpkp – This adds Public Key Pinning headers to prevent any man-in-the-middle attacks using various forged certificates&lt;/li&gt;
&lt;li&gt; hsts – hsts sets Strict-Transport-Security headers which enforce secure connections to the server via HTTP over SSL/TLS. &lt;/li&gt;
&lt;li&gt; noCache – noCache sets a Cache-Control and Pragma headers to disable any client facing caching&lt;/li&gt;
&lt;li&gt; noSniff – This sets an X-Content-Type-Options that can prevent browsers from MIME-sniffing a response generated from a declared a content-type.&lt;/li&gt;
&lt;li&gt; frameguard – frameguard sets the X-frame-Options header to allow for clickjacking protection&lt;/li&gt;
&lt;li&gt; xssFilter – The xssFilter establishes a X-XSS-Protection that enables Cross-site scripting, or XSS, in the more recent web browsers. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To install Helmet, you can do it as with any normal module –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -save helmet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After which, you can now use it in your code via –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ...
var helmet = require( 'helmet' )
app.use(helmet())

// ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Safe Usage of Cookies
&lt;/h2&gt;

&lt;p&gt;In order to make sure that cookies do no expose your apps to malicious attacks, it is recommended that you do not use a default cookie name. However, you can choose to set a predefined cookie security option. These are available in two broad middleware cookie session modules – &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Express-session – This replaces express.session middleware built-in to Express 3.x&lt;/li&gt;
&lt;li&gt; Cookie-session – This replaces express.cookieSession middleware built-in to Express 3.x&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The differentiating factor between these two modules is the method in which they save data from cookie sessions. The Express-session middleware stores its session data onto the server. This saves only the session ID within the cookie and not the session data. &lt;/p&gt;

&lt;p&gt;Unless programmed otherwise, the Express-session makes use of in-memory storage capabilities and not is best designed for production environments.&lt;/p&gt;

&lt;p&gt;Contrasting the Express-session middleware, the cookie-session middleware makes use of cookie backed storage. It sterilizes the complete session within the cookie, instead of just producing a cookie key. It is advised that this is best used when session is relatively small and easy to encode. &lt;/p&gt;

&lt;p&gt;Also, another flag, it is best to be aware that cookie data will be available to the client, therefore, if there is need any need for confidentiality, this is something to keep in mind.&lt;/p&gt;

&lt;p&gt;Using the default session cookie name may be a bad idea&lt;/p&gt;

&lt;p&gt;If you use the default session cookie name you open your app to attacks. The security flag is similar to X-Powered-By: a potential attacker that fingerprints servers and targets attacks accordingly.&lt;/p&gt;

&lt;p&gt;To circumvent this problem, you can use generic cookie names like using express-session middleware:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var session = require('express-session')
app.set('trust proxy', 1) // trust first proxy
app.use(session({
  secret: 's3Cur3',
  name: 'sessionId'
}))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Options for setting cookie security
&lt;/h3&gt;

&lt;p&gt;In order to enhance the security of the following cookie options, you can- &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; secure – Ensure that the browser only sends the cookie over HTTPS.&lt;/li&gt;
&lt;li&gt; httpOnly – This ensures that the cookie is only sent via HTTP(S), and not client JavaScript. This assists in protecting against cross-site scripting attacks.&lt;/li&gt;
&lt;li&gt; domain – This indicates the domain of the cookie. Domain can be used to compare against the domain of the host server from where the URL is being requested. &lt;/li&gt;
&lt;li&gt; path – This indicates the path of the cookie. Path can be used it to compare against the request path. If there is match found between the path and domain fields, send the cookie in the request.&lt;/li&gt;
&lt;li&gt; expires – This is used to specify the expiration date of repetitive cookies. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Below is an example of how a cookie-session middleware can be used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var session = require('cookie-session')
var express = require('express')
var app = express()

var expiryDate = new Date(Date.now() + 60 * 60 * 1000) // 1 hour
app.use(session({
  name: 'session',
  keys: ['key1', 'key2'],
  cookie: {
    secure: true,
    httpOnly: true,
    domain: 'example.com',
    path: 'foo/bar',
    expires: expiryDate
  }
}))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Avoid Identified Vulnerabilities and Other Securities Issues
&lt;/h2&gt;

&lt;p&gt;As mentioned earlier, it is a good idea to monitor &lt;a href="https://www.npmjs.com/advisories" rel="noopener noreferrer"&gt;Node Security Project&lt;/a&gt; and Snyk updates that may impact the express package and other node modules that your application uses. There are resources that are excellent to stay abreast with the ever-evolving node security. Here are some of the generic security resources that you can use to keep up with the latest trends in security for your Application:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;a href="https://blog.npmjs.org/" rel="noopener noreferrer"&gt;NPM's security blog&lt;/a&gt; - NPM's official blog is a great resource to keep yourself up to date with the NPM and Nodejs. &lt;/li&gt;
&lt;li&gt; &lt;a href="https://www.exabeam.com/information-security-blog/" rel="noopener noreferrer"&gt;Exabeam's Security Blog&lt;/a&gt; - Exabeam's security blog focuses on incident reporting and the steps required to contain the surface area of the vulnerability. &lt;/li&gt;
&lt;li&gt; &lt;a href="https://blog.risingstack.com/node-js-security-checklist" rel="noopener noreferrer"&gt;RisingStack Blog&lt;/a&gt; - They have an impressive security checklist that you shouldn't miss if you are developing the server using Nodejs.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Ensure All Your Dependencies Are Secure
&lt;/h2&gt;

&lt;p&gt;The usage of Npm to ensure that the dependencies of your application are both robust and convenient is the best you can hope for. However, most developers use packages that may, at times, contain critical security vulnerabilities which can have an adverse in your in-house application. &lt;/p&gt;

&lt;p&gt;Since the release of npm@6, npm now automatically reviews each requested installation. &lt;/p&gt;

&lt;p&gt;Additionally, you can also use 'npm audit' for analysis –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'$ npm audit'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you would like to ensure a greater level of security, you can also consider using Snyk.&lt;/p&gt;

&lt;p&gt;Snyk provides a &lt;a href="https://www.npmjs.com/package/snyk" rel="noopener noreferrer"&gt;command-line tool&lt;/a&gt;  in collaboration with Github, that can provide audit services for your applications against known open source database vulnerabilities. You can install the CLI below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -g snyk
$ cd your-app
To check your application for vulnerabilities, you can use the following command - 
$ snyk test
You can implement the command below to open a wizard that will apply updates and patches to fix uncovered vulnerabilities as they are discovered:
$ snyk wizard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;We've covered some of the best practices for creating an Express application. The common production phase security best practices include – &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Avoid the usage of deprecated or vulnerable versions of express &lt;/li&gt;
&lt;li&gt; Use TLS&lt;/li&gt;
&lt;li&gt; Use Helmet package&lt;/li&gt;
&lt;li&gt; Implement the cookies the safe way&lt;/li&gt;
&lt;li&gt; Avoid known vulnerabilities&lt;/li&gt;
&lt;li&gt; Ensure all your dependencies are secure &amp;amp; up to date&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, what are your thoughts on securing your  Express application? Share them in the comments. &lt;/p&gt;

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