<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jay on Medium]]></title>
        <description><![CDATA[Stories by Jay on Medium]]></description>
        <link>https://medium.com/@jaidg2012?source=rss-452bf95fc10f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hnjk4m7Qqa_xQQN-NSvI5g.jpeg</url>
            <title>Stories by Jay on Medium</title>
            <link>https://medium.com/@jaidg2012?source=rss-452bf95fc10f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 18:19:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaidg2012/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ Beyond the Prompt: What I Learned About Prompt Internals & RAG (Part 2)]]></title>
            <link>https://jaidg2012.medium.com/beyond-the-prompt-what-i-learned-about-prompt-internals-rag-part-2-4b2b0d3f15c2?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b2b0d3f15c2</guid>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[gradio]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Sat, 15 Aug 2026 11:47:50 GMT</pubDate>
            <atom:updated>2026-08-15T11:47:50.669Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://blog.devgenius.io/from-zero-to-practical-what-i-learned-about-prompt-engineering-in-a-few-weeks-b1747185e11d">my last post</a>, I wrote about prompt engineering basics — roles, context, constraints, chain-of-thought. That post was about <em>how you ask</em>.</p><p>This one is about a different question I kept running into after that:</p><blockquote>❗ Once I ask well, how does the model actually see my prompt — and how do I give it knowledge it was never trained on?</blockquote><p>I recently ran a developer session on exactly this — prompt internals, configuration, and RAG (Retrieval-Augmented Generation) — and built a fully local demo (Ollama + Chroma + Gradio, no cloud APIs) to go with it. This post is my recap.</p><p>Full code: <a href="https://github.com/jayandran-Sampath/sessiondemo2"><strong>github.com/jayandran-Sampath/sessiondemo2</strong></a></p><h3>🧩 What’s Actually Inside a Prompt</h3><p>I used to think of a prompt as just a string. It’s not — it’s a structured payload made of three roles:</p><pre>[<br>  { &quot;role&quot;: &quot;system&quot;,    &quot;content&quot;: &quot;You are a helpful assistant.&quot; },<br>  { &quot;role&quot;: &quot;user&quot;,      &quot;content&quot;: &quot;What&#39;s our remote work policy?&quot; },<br>  { &quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: &quot;...&quot; }<br>]</pre><ul><li><strong>system</strong> — set once by the developer, applies to the whole conversation. This is where guardrails belong — it’s not something an end user can edit directly.</li><li><strong>user</strong> — the actual human message.</li><li><strong>assistant</strong> — the model’s own previous replies, fed back in so it has memory across turns.</li></ul><p>👉 One gotcha I hit while building the demo: if you’re using a UI framework (I used Gradio) to render chat history, don’t assume what it hands you back is safe to forward straight to the model. Gradio’s message format carries extra UI-only fields (metadata, options) that have nothing to do with the model — I had to strip them down to just role/content before sending.</p><h3>📌 Configuration — The Knobs Nobody Talks About</h3><p>Wording isn’t the only thing shaping the output. A prompt is only half the story — these parameters are the other half:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfqTPgqqodOQEOkMwekqcA.png" /></figure><p>Something I didn’t expect: top_k and top_p aren&#39;t either/or — they stack. top_k filters first (narrows by rank), then top_p filters <em>within</em> that shortlist (narrows by cumulative probability). Whichever is tighter ends up doing most of the actual work.</p><h3>🔄 Why RAG, Not Just a Bigger Prompt</h3><p>A general-purpose model has three real problems:</p><ol><li><strong>Knowledge cutoff</strong> — no idea what happened after training ended</li><li><strong>Private data</strong> — your internal docs were never in the training set</li><li><strong>Hallucination under pressure</strong> — asked something it doesn’t know, it’ll often guess fluently instead of saying so</li></ol><p>RAG fixes this without retraining anything. The pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R26LFVSGK_BvUhOjS3tUJA.png" /></figure><ol><li><strong>Sources</strong> — your raw documents (policies, docs, whatever you want the model to know about)</li><li><strong>Embed Sources</strong> — each source gets chunked and turned into vectors</li><li><strong>Vector Store</strong> — those vectors get saved (Chroma, in my case)</li><li><strong>Prompt</strong> — the user’s question, kept as-is for later</li><li><strong>Embed Prompt</strong> — the same question also gets embedded into a vector, using the same embedding model as step 2</li><li><strong>Retriever</strong> — the embedded prompt is compared against everything in the vector store, pulling back the closest matches</li><li><strong>Retrieved Text (+)</strong> — those matching chunks come back as raw text, ready to be <em>added</em> to the original prompt</li><li><strong>LLM → Response</strong> — the retrieved text and the original prompt (from step 4) are combined and sent to the model together, which generates the final answer</li></ol><p>There are two legs for this journey <br>Step 1- 3 -&gt; Ingestion journey — Pre requisite where context are created to use in RAG journey</p><p>Step 4–8 -&gt; RAG journey — where prompt augmentation happens with retrieved content</p><h3>🧠 Embeddings — Why It Actually Works</h3><p>An embedding is a fixed-length vector that captures a piece of text’s <em>meaning</em>.</p><p>Similar meaning → vectors land close together, even with totally different wording:</p><pre>&quot;What&#39;s our remote work policy?&quot;      → [0.12, -0.44, 0.87, ...]<br>&quot;How many WFH days can I take?&quot;       → [0.14, -0.41, 0.85, ...]  ← very close<br><br>&quot;What&#39;s the mileage reimbursement rate?&quot; → [-0.61, 0.22, -0.05, ...] <br> ← different topic</pre><p>This is why plain keyword search wouldn’t catch the connection between the first two — they barely share any words. Embedding both into the same vector space and comparing distance does.</p><p>In the demo, nomic-embed-text (running locally via Ollama) embeds both the document chunks — once, at ingest — and every user question, live.</p><h3>✂️ Chunking — The Step I Underrated</h3><p>Before anything gets embedded, documents get split into pieces. I hand-rolled a naive sliding character window for my first pass. Frameworks do it smarter:</p><ul><li><strong>LlamaIndex</strong> defaults to SentenceSplitter — 1024 tokens, 200 overlap, splits on paragraph → sentence boundaries</li><li><strong>LangChain</strong> defaults to RecursiveCharacterTextSplitter — tries paragraph → sentence → word boundaries before falling back</li></ul><p>👉 Lesson learned building the demo: my hand-rolled chunker (500 characters) and LlamaIndex’s default (1024 tokens) produced <em>very</em> different chunks for the same document. Two “equivalent” RAG pipelines can silently chunk differently unless you configure it explicitly.</p><h3>🛠️ LlamaIndex vs LangChain</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShaZGD9iNvBARCF96uWvmw.png" /></figure><p>👉 <strong>My rule of thumb</strong>: reach for <strong>LlamaIndex</strong> when the core job is retrieval over your own data. Reach for <strong>LangChain</strong>when you need multi-step chains, agents, or tool use beyond just RAG.</p><p>(Small trap either way — LlamaIndex uses singular class names, OllamaEmbedding; LangChain uses plural, OllamaEmbeddings. I typo&#39;d this more than once.)</p><h3>🎬 The Live Demo, in Three Acts</h3><p>Everything ran locally — Ollama for the model + embeddings, Chroma as the vector store, Gradio for the UI. I used a real-looking travel &amp; expenses policy doc as the test data, specifically because it’s full of checkable facts (mileage rate, overnight meal limits, the 40-mile claim threshold).</p><p><strong>Act 1 — No RAG.</strong> Ask the model about the policy directly. It guesses, or admits it doesn’t know.</p><p><strong>Act 2 — Embed &amp; store.</strong> Run ingestion live, watch chunks land in Chroma — I built a small Gradio-based DB viewer just to make this visible instead of staring at a terminal.</p><p><strong>Act 3 — RAG on.</strong> Same question, retrieval switched on. The UI shows both the retrieved chunks (with similarity distance) and the <em>exact</em> augmented prompt sent to the model — which ties straight back to the “prompt internals” section above.</p><h3>🎯 Final Thoughts</h3><p>If my last post was about <em>how you ask</em>, this one is about <em>what happens after you ask</em> — how the model sees your prompt structurally, what the config knobs actually do, and how retrieval lets a model answer things it was never trained on.</p><p>Things I’d tell past-me before starting this:</p><ul><li>A prompt isn’t a string, it’s a structured messages array — treat it that way</li><li>Temperature doesn’t make answers more correct, just more (or less) random</li><li>RAG’s whole job is narrowing what the model sees to what’s actually relevant — that’s the point, not a limitation</li><li>Chunking strategy is easy to overlook and changes your results more than you’d expect</li><li>A completely local stack is enough to prototype all of this — no API keys needed to learn it</li></ul><h3>🚀 Try It Yourself</h3><pre>git clone https://github.com/jayandran-Sampath/sessiondemo2.git<br>cd sessiondemo2<br>python3 -m venv venv &amp;&amp; source venv/bin/activate<br>pip install -r requirements.txt<br><br>ollama pull llama3.2<br>ollama pull nomic-embed-text<br><br>python ingest.py    # embed the demo docs into Chroma<br>python app.py        # launch the chat widget</pre><p>If you’re also going down the RAG rabbit hole, I’d love to hear what you’re building 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b2b0d3f15c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ From Zero to Practical: What I Learned About Prompt Engineering in a Few Weeks]]></title>
            <link>https://blog.devgenius.io/from-zero-to-practical-what-i-learned-about-prompt-engineering-in-a-few-weeks-b1747185e11d?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1747185e11d</guid>
            <category><![CDATA[ai-developer]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[generative-ai]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Wed, 20 May 2026 22:03:28 GMT</pubDate>
            <atom:updated>2026-05-30T17:15:11.687Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence is everywhere now — from coding assistants to writing tools. But one thing I quickly realised while using Large Language Models (LLMs) like ChatGPT or Copilot is:</p><blockquote><em>❗ It’s not about what the AI knows — it’s about how you ask.</em></blockquote><p>That’s where <strong>Prompt Engineering</strong> comes in.</p><p>In the past few weeks, I’ve been learning and applying prompt engineering in my daily work. In this blog, I want to share my understanding in a simple, beginner-friendly way.</p><h3>🔍 What is Prompt Engineering?</h3><p>A <strong>prompt</strong> is simply the instruction you give to an AI model.</p><p>But here’s the catch: Even though LLMs are trained on massive data, they don’t always give the right answer unless you guide them properly.</p><p>👉 Prompt Engineering is the practice of:</p><ul><li>Asking the right questions</li><li>Structuring inputs clearly</li><li>Controlling output format</li><li>Providing context and examples</li></ul><p>It helps avoid the classic problem:</p><blockquote><em>🗑️ Garbage In → Garbage Out</em></blockquote><h3>🧩 Key Components of a Good Prompt</h3><p>Here’s a simple structure I’ve found very effective:</p><h3>1. 🎭 Role / Persona</h3><p>Assigning a role helps shape the response.</p><p><strong>Example:</strong></p><blockquote><em>“You are a senior Scala developer…”</em></blockquote><p>This makes the model respond with more depth and relevant expertise.</p><h3>2. 📘 Context</h3><p>Give background information to guide the model.</p><ul><li>What problem are you solving?</li><li>Any specific data/source?</li></ul><p><strong>Example:</strong></p><pre>You are a senior Scala Play developer.<br> <br>Context: <br>I am building a backend service for an e-commerce platform<br>The service manages product details<br>We use Play Framework with Scala 2.13 <br><br>Task: <br>Create an endpoint /products/:id to fetch product details from a repository.</pre><h3>3. ✅ Clear Instructions</h3><p>Be simple and direct.</p><p>Bad:</p><blockquote><em>“Explain API”</em></blockquote><p>Better:</p><blockquote><em>“Explain REST API concepts for beginners with examples”</em></blockquote><h3>4. 📌 Constraints</h3><p>Limit the scope.</p><p>Example:</p><ul><li>“Limit to 200 words”</li><li>“Use bullet points only”</li></ul><h3>5. 📊 Output Format</h3><p>This is <strong>super powerful</strong>.</p><p>Example:</p><ul><li>JSON output</li><li>Table format</li><li>Positive/Negative classification</li></ul><h3>✅ Example Prompt</h3><pre>You are a lead Scala Play Developer.</pre><pre>Create an endpoint (/details/:id) that:<br>- Fetches data from a repository<br>- Returns:<br>  - 200 with JSON if found<br>  - 400 if not found<br>  - 500 for errors</pre><pre>Use latest Scala Play syntax.<br>Return response in clean JSON format.</pre><h3>🔄 Zero-shot vs Few-shot Prompting</h3><h3>⚪ Zero-shot</h3><p>No examples — just ask.</p><p>👉 Good when:</p><ul><li>You are exploring</li><li>You don’t know the expected format</li></ul><h3>🟢 One-shot / Few-shot</h3><p>Provide examples.</p><p>👉 Good when:</p><ul><li>You know what output should look like</li><li>You want consistency</li></ul><h3>🧠 Chain-of-Thought (CoT)</h3><p>This is one of the most impactful techniques I’ve used.</p><p>👉 Instead of asking for a final answer, guide the AI step-by-step.</p><p>Example:</p><ul><li>Step 1: Analyze problem</li><li>Step 2: Break into parts</li><li>Step 3: Solve each</li></ul><p>✅ Helps reduce errors<br>✅ Improves reasoning</p><h3>📐 Why Constraints &amp; Formatting Matter</h3><p>Without structure → messy output<br>With structure → usable output ✅</p><p>Example:</p><p>Instead of:</p><blockquote><em>“Summarize feedback”</em></blockquote><p>Use:</p><blockquote><em>“Classify feedback as Positive, Negative, Neutral and return JSON”</em></blockquote><h3>🔁 How I Improve Prompts (My Process)</h3><p>I follow an iterative approach:</p><ol><li>Start simple</li><li>Add role + context</li><li>Add format and constraints</li><li>Refine based on output</li><li>Sometimes even ask AI:</li></ol><ul><li>“Improve this prompt for better accuracy”</li></ul><p>👉 Prompting is not one-shot — it’s refinement.</p><h3>⚠️ Handling Hallucinations</h3><p>Sometimes AI gives confident but incorrect answers. This is called <strong>hallucination</strong>.</p><h3>Why it happens:</h3><ul><li>Lack of context</li><li>Over-generalization</li><li>Long conversations</li></ul><h3>How I reduce it:</h3><ul><li>Add constraints</li><li>Break into steps (CoT)</li><li>Validate outputs</li><li>Keep prompts specific</li></ul><h3>🚀 Advanced Techniques (Starter View)</h3><h3>🧵 Prompt Chaining</h3><p>Break tasks into multiple prompts:</p><pre>Prompt 1 → Output → Prompt 2 → Output → Prompt 3</pre><h3>🔁 Self-Consistency</h3><p>Ask the same question multiple times and pick the best answer.</p><p>👉 Useful for complex reasoning tasks</p><h3>🛠️ How I Use Prompt Engineering in Real Work</h3><p>I’m not a full-time Prompt Engineer, but I use these techniques daily.</p><p>👉 Especially:</p><ul><li>Chain-of-Thought for problem solving</li><li>Structured prompts for coding</li><li>Iterative refinement</li></ul><p>It helps me:</p><ul><li>Think clearer</li><li>Solve faster</li><li>Reduce manual effort</li></ul><h3>🎯 Final Thoughts</h3><p>Prompt Engineering is not just a skill — it’s becoming a <strong>necessary literacy</strong>.</p><p>As AI tools become part of everyday workflows, knowing how to:</p><ul><li>Ask better questions</li><li>Structure problems</li><li>Guide AI effectively</li></ul><p>…will make a huge difference.</p><h3>✅ If You’re Starting Out</h3><p>My advice:</p><ul><li>Start simple</li><li>Practice daily</li><li>Experiment a lot</li><li>Don’t chase perfection — iterate</li></ul><blockquote><em>💡 “Better prompts = Better results”</em></blockquote><p>If you’re also learning prompt engineering, I’d love to hear your journey 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1747185e11d" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/from-zero-to-practical-what-i-learned-about-prompt-engineering-in-a-few-weeks-b1747185e11d">🧠 From Zero to Practical: What I Learned About Prompt Engineering in a Few Weeks</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rewriting a Scala 2 Codebase Into Scala 3: A Practical Guide]]></title>
            <link>https://jaidg2012.medium.com/rewriting-a-scala-2-codebase-into-scala-3-a-practical-guide-351155d01a76?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/351155d01a76</guid>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[scala-3]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Sun, 30 Nov 2025 18:25:37 GMT</pubDate>
            <atom:updated>2025-11-30T18:31:34.898Z</atom:updated>
            <content:encoded><![CDATA[<p>Scala 3 introduces some of the biggest language improvements. Many of these features are designed to clean up the rough edges of Scala 2, especially around implicits and type safety.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJvzPaTpUXcDXcbs5WYakQ.png" /></figure><p>In this post, we’ll walk through a small example and show how the same code looks in Scala 2 vs Scala 3, focusing on:</p><p>• braceless class &amp; methods</p><p>• Case Class with Companion Apply</p><p>• implicit → given / using</p><p>•	type alias → opaque types</p><p>•	implicit classes → extension methods</p><p>•	JSON Reads/Writes rewrite</p><p>•	dependency injection rewrite</p><p>By the end, you’ll have a clear mental model of how to migrate real code from Scala 2 to Scala 3.</p><h4><strong>Why Rewrite Scala 2 → Scala 3?</strong></h4><p>Scala 2 codebases often suffer from:</p><p>• too much implicit magic</p><p>• weak domain modeling using type aliases</p><p>•	verbose implicit class boilerplate</p><p>•	implicit dependency injection that’s hard to trace</p><p>•	complicated JSON codecs using unapply boilerplate</p><h4>Braceless class &amp; methods</h4><p><strong>Scala 2</strong></p><pre>class Person(name: String, age: Int) {<br>  def greet(): Unit = {<br>    println(s&quot;Hello, I&#39;m $name and I&#39;m $age years old.&quot;)<br>  }<br>}<br><br>object Main extends App {<br>  val p = new Person(&quot;John&quot;, 30)<br>  p.greet()<br>}</pre><p><strong>Scala 3 Version</strong></p><pre>class Person(name: String, age: Int):<br>  def greet(): Unit =<br>    println(s&quot;Hello, I&#39;m $name and I&#39;m $age years old.&quot;)<br><br>@main def run =<br>  val p = Person(&quot;John&quot;, 30)<br>  p.greet()</pre><p><strong>What Changed?</strong></p><ul><li>Braceless syntax</li><li>Top-level @main instead of object Main extends App</li><li>new is optional in constructors</li></ul><p><strong>Case Class with Companion Apply</strong></p><p><strong>Scala 2</strong></p><pre>case class User(name: String, email: String)<br><br>object User {<br>  def fromTuple(t: (String, String)): User = User(t._1, t._2)<br>}<br><br>object Demo extends App {<br>  val u = User.fromTuple((&quot;Alice&quot;, &quot;a@example.com&quot;))<br>  println(u)<br>}</pre><p><strong>Scala 3 Version</strong></p><pre>case class User(name: String, email: String)<br><br>def fromTuple(t: (String, String)): User =<br>  User(t._1, t._2)<br><br>@main def run =<br>  val u = fromTuple((&quot;Alice&quot;, &quot;a@example.com&quot;))<br>  println(u)</pre><p><strong>What Changed?</strong></p><ul><li>No need for a companion object just for utility methods</li><li>Top-level defs allowed</li><li>Cleaner indentation-based syntax</li></ul><h4>Domain Model Before &amp; After</h4><p>Scala 2 version (the old way)</p><pre>type PostId = Long</pre><p>The problem?</p><p>PostId is still a Long . You can accidentally pass any Long and the compiler won’t complain.</p><p><strong>Scala 3 version (the modern way)</strong></p><p>Scala 3 introduces <strong>opaque types</strong>, which behave like zero-overhead wrapper types but are fully type-safe.</p><pre>object BlogDomain:<br>  opaque type PostId = Long<br><br>  def PostId(value: Long): PostId = value<br><br>  extension (id: PostId)<br>    def value: Long = id</pre><p><strong>Why this is better</strong></p><p>• PostId is not interchangeable with Long.</p><p>• You get the same performance as a raw Long.</p><p>•	You can attach domain logic using extension methods.</p><p><strong>Usage</strong></p><pre>import BlogDomain.*<br><br>val e: PostId = PostId(1)<br><br>val s: Long = e.value   // OK<br>// val wrong: PostId = 1  // ❌ compile error</pre><p><strong>JSON Reads/Writes Before &amp; After</strong></p><p><strong>Scala 2 JSON codecs</strong></p><pre>implicit val blogPostReads: Reads[BlogPost] = (<br>  (__ \ &quot;id&quot;).read[Long] and<br>  (__ \ &quot;title&quot;).read[String] and<br>  (__ \ &quot;content&quot;).read[String]<br>)(BlogPost.apply _)<br><br>implicit val blogPostWrites: Writes[BlogPost] = (<br>  (__ \ &quot;id&quot;).write[Long] and<br>  (__ \ &quot;title&quot;).write[String] and<br>  (__ \ &quot;content&quot;).write[String]<br>)(unlift(BlogPost.unapply))</pre><p>requires unapply tricks and relies on implicits everywhere</p><p><strong>Scala 3 JSON codecs (cleaner &amp; explicit)</strong></p><pre>import play.api.libs.json.*<br>import BlogDomain.*<br><br>given Reads[PostId] = Reads(_.validate[Long].map(PostId(_)))<br>given Writes[PostId] = Writes(id =&gt; JsNumber(id.value))<br><br>given Reads[BlogPost] with<br>  def reads(json: JsValue) =<br>    for<br>      id &lt;- (json \ &quot;id&quot;).validate[PostId]<br>      title &lt;- (json \ &quot;title&quot;).validate[String]<br>      content &lt;- (json \ &quot;content&quot;).validate[String]<br>    yield BlogPost(id, title, content)<br><br>given Writes[BlogPost] with<br>  def writes(b: BlogPost) =<br>    Json.obj(<br>      &quot;id&quot; -&gt; b.id,<br>      &quot;title&quot; -&gt; b.title,<br>      &quot;content&quot; -&gt; b.content<br>    )</pre><p><strong>What’s different?</strong></p><ul><li>No unapply boilerplate</li><li>Much clearer and more explicit</li><li>Works with opaque types</li></ul><p><strong>Implicit Classes → Extension Methods</strong></p><p><strong>Scala 2 version</strong></p><pre>implicit class RichString(val s: String) extends AnyVal {<br>  def truncate(n: Int): String = s.take(n)<br>}</pre><p><strong>Scala 3 version</strong></p><pre>extension (s: String)<br>  def truncate(n: Int): String = s.take(n)</pre><p><strong>That’s it.</strong></p><p>No need of wrapper class.</p><p>No boilerplate.</p><p>No implicit keyword.</p><p><strong>Dependency Injection (Scala 2 implicits → Scala 3 using/given)</strong></p><p>Let’s say we want a repository:</p><p><strong>Scala 2 version</strong></p><pre>trait BlogRepo {<br>  def list(): List[BlogPost]<br>}<br><br>implicit val repo: BlogRepo = new InMemoryBlogRepo<br><br>class BlogService(implicit repo: BlogRepo) {<br>  def list() = repo.list()<br>}</pre><p>The problem?</p><p>Implicit DI is hard to trace and unclear to new developers.</p><p><strong>Scala 3 version – explicit contextual parameters</strong></p><pre>given BlogRepo = new InMemoryBlogRepo<br><br>class BlogService(using repo: BlogRepo):<br>  def list() = repo.list()</pre><p><strong>What changed?</strong></p><p>•	given replaces confusing implicit vals</p><p>•	using says “this is a context value”</p><p>•	Much easier to read and test</p><p><strong>Play Controller Before &amp; After</strong></p><p>Scala 2 version</p><pre>class BlogController @Inject()(<br>  cc: ControllerComponents<br>)(implicit service: BlogService)<br>  extends AbstractController(cc) {<br><br>  def list = Action {<br>    Ok(Json.toJson(service.list()))<br>  }<br>}</pre><p><strong>Scala 3 version</strong></p><pre>class BlogController @Inject()(<br>  cc: ControllerComponents<br>)(using service: BlogService)<br>  extends AbstractController(cc):<br><br>  def list = Action:<br>    Ok(Json.toJson(service.list()))</pre><p>Cleaner syntax everywhere.</p><p><strong>Final Before/After Comparison</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*MVRNoZa13RrjvnIJx3xh3A.png" /></figure><p><strong>Final Thoughts</strong></p><p>Scala 3 fixes many of the pain points of Scala 2:</p><p>•	No more “implicit hell”</p><p>•	Safer domain modeling</p><p>•	Cleaner JSON code</p><p>•	Better readability</p><p>•	More predictable DI</p><p>There are other features too, keep exploring. I just added what i recently studied for my day to day work :)</p><p>You don’t need to rewrite everything at once – but even migrating 1 – 2 areas (like domain types and JSON codecs) dramatically improves your codebase. Im going to start with braceless syntax :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=351155d01a76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ How HTTPS Really Works — The Secret Behind the Lock Icon]]></title>
            <link>https://jaidg2012.medium.com/how-https-really-works-the-secret-behind-the-lock-icon-023f44e1f58d?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/023f44e1f58d</guid>
            <category><![CDATA[short-read]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[fundamentals]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Mon, 06 Oct 2025 16:39:50 GMT</pubDate>
            <atom:updated>2025-10-06T16:47:09.984Z</atom:updated>
            <content:encoded><![CDATA[<h3>🔒 How HTTPS Really Works — The Secret Behind the Lock Icon</h3><p>Every time you visit a website and see that tiny lock 🔒 in your browser’s address bar, something magical (and mathematical) is happening behind the scenes.</p><p>Your passwords, messages, and credit card info stay safe — all thanks to a protocol called <strong>HTTPS</strong>.</p><p>We all know HTTPS means secured traffic but to understand better on what’s really going on under that lock?<br>Let’s look into it — step by step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7EnB4Yx74pVmz8at5sE9hQ.png" /></figure><h3>🌐 HTTP — The Starting Point</h3><p>As we all know starting point is <strong>HTTP</strong> — the <em>HyperText Transfer Protocol </em>and<em> </em>Still we are using for local sessions.</p><p>A simple HTTP request looks like this:</p><pre>GET /login?username=alice&amp;password=1234 HTTP/1.1<br>Host: example.com</pre><p>As the request is sent in <strong>plain text </strong>across the network. Anyone sitting between your browser and the server — say, a hacker on the same Wi-Fi — can read or even modify it.</p><p>That’s where <strong>HTTPS</strong> comes in.</p><h3>🔐 HTTPS = HTTP + Encryption (via SSL/TLS)</h3><p>HTTPS uses an extra layer called <strong>TLS (Transport Layer Security)</strong> to encrypt data.</p><p>So now:</p><ul><li>All HTTP requests and responses are wrapped inside an encrypted tunnel.</li><li>No one can read or alter the data in transit.</li></ul><p>But how does this “encryption tunnel” get created?<br>That’s where <strong>public and private keys </strong>are used — and then <strong>TLS handshake</strong> — come in.</p><h3>🧩 Step 1: Understanding Public &amp; Private Keys</h3><p>Think of it like a padlock:</p><ul><li>The <strong>public key</strong> is the padlock anyone can close.</li><li>The <strong>private key</strong> is the only key that can open it.</li></ul><p>So, if your browser encrypts something using the server’s <strong>public key</strong>, only the server can decrypt it with its <strong>private key</strong>.</p><h3>⚙️ Step 2: The TLS Handshake — Setting Up the Secure Connection</h3><p>When you connect to an HTTPS website, your browser and the server go through a “handshake” before sending any data.</p><p>Here’s a simplified version of what happens:</p><h3>🧱 Phase 1 — Hello</h3><ul><li><strong>ClientHello</strong>: The browser says “Hi” to the server, listing basic info’s like supported tls versions, encrytion types &amp; optional data.</li><li><strong>ServerHello</strong>: The server responds with its chosen method and sends its <strong>digital certificate</strong> (which contains its public key).</li></ul><h3>📜 Phase 2 — Certificate Verification</h3><p>The browser verifies that the certificate:</p><ul><li>is the certificate issued by a trusted Certificate Authority (CA)</li><li>Matches the domain name</li><li>Hasn’t expired or been revoked</li></ul><p>If all checks pass ✅, the browser trusts it’s talking to the real server.</p><h3>🔐 Phase 3 — Key Exchange</h3><p>Now the two sides need to agree on a <strong>shared session key</strong> — a temporary key used for symmetric encryption.</p><p>There are two main ways this happens:</p><h3>🔹 (Old Way) RSA Key Exchange — The Browser Sends the Key</h3><p>In older TLS (like 1.2 with RSA):</p><ol><li>The browser generates a random “pre-master secret.”</li><li>It encrypts this secret with the server’s <strong>public key</strong>.</li><li>The server decrypts it with its <strong>private key</strong>.</li><li>Both sides derive the same <strong>session key</strong> from this secret.</li></ol><p>🔒 That session key is then used to encrypt all HTTP traffic.</p><p><strong>Downside:</strong><br>If someone ever steals the server’s private key, they can decrypt <em>past sessions</em> too.<br>That’s why better approach is introduced.</p><h3>🔹 (Modern Way) ECDHE — Shared Secrets via Math (TLS 1.3)</h3><p>Modern HTTPS uses <strong>Ephemeral Diffie–Hellman (ECDHE)</strong>, which is both faster and more secure. (<em>Note: Ephemeral means temporary)</em></p><p>Here’s how it works:</p><ol><li><strong>Both browser and server generate temporary key pairs</strong> (each has a public and private key).</li><li>They <strong>exchange only their public keys</strong>.</li><li>Each side computes the same <strong>shared secret</strong> mathematically:</li></ol><pre>shared_secret = (other_public_key * own_private_key)<br><br>client_secret = (server_public_key * temporary_private_key)<br><br>server_secret = (client_public_key * temporary_private_key)<br>G * c * s = G * s * c</pre><p>mathematical computation is as below</p><pre>G * c * s = G * s * c</pre><p>Both sides end up with the same shared secret — but no one ever sent it over the network!</p><p>4. From this shared secret, both derive the <strong>session key</strong> using a key derivation function (KDF).</p><p>🧠 Magic:<br>Even if a hacker records your encrypted traffic today and later steals the server’s private key, they <strong>still can’t decrypt it</strong> — because those ephemeral keys (private key’s) were destroyed after the session.</p><p>That’s called <strong>Perfect Forward Secrecy</strong> ✅</p><h3>🔄 Step 3: Secure HTTP Communication</h3><p>Once the handshake is complete, both sides now have:</p><ul><li>The same <strong>session key</strong></li><li>Agreed-upon encryption algorithms</li></ul><p>Now, the browser sends:</p><pre>GET /profile HTTP/1.1<br>Host: example.com</pre><p>But on the wire, it looks like:</p><pre>[Encrypted binary data]</pre><p>The server decrypts it using the same session key, processes it, and responds — also encrypted.</p><p>Everything — headers, cookies, payloads — travels through the secure tunnel.</p><h3>🚀 Step 4: All of This Happens Instantly</h3><p>All this complex math and cryptographic verification — from ClientHello to session encryption — happens in <strong>milliseconds</strong> before your first page loads.</p><p>That’s why HTTPS feels just as fast as HTTP today.</p><h3>🧠 Recap</h3><p>StepPurposeKey UsedTLS HandshakeAgree on encryption rulesPublic/Private keysKey ExchangeGenerate shared secretEphemeral (ECDHE) keysData TransferEncrypt actual HTTP messagesSession key (symmetric)</p><h3>🔒 Final Thoughts</h3><p>Every time you see that lock icon in your browser, remember — there’s a full cryptographic dance happening under the hood.<br>The browser and server exchange keys, verify identities, and build a private tunnel that no one else can see into.</p><p>All that, in under a second.</p><p>So next time you type a password or make a payment online, you’ll know what’s really protecting it — <strong>math, trust, and the brilliance of HTTPS</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=023f44e1f58d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL with Airflow & PySpark]]></title>
            <link>https://jaidg2012.medium.com/etl-with-airflow-pyspark-7d0c8f78b10d?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d0c8f78b10d</guid>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[airflow-installation]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[airflow]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Sat, 03 May 2025 17:50:15 GMT</pubDate>
            <atom:updated>2025-05-03T17:57:31.267Z</atom:updated>
            <content:encoded><![CDATA[<p>Continuing my DE learning journey from <a href="https://medium.com/@jaidg2012/data-engineering-getting-started-367429e7c4cc">previous blog</a>. In this blog, i will explain creating ETL pipeline using Airflow &amp; Pyspark with quick demo :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EI8WjYiA8oSZevuwuYLD1Q.png" /></figure><blockquote>Before we get started, lets have quick intro about the tools</blockquote><h3>Airflow</h3><p>……. is the orchestration tool where data pipelines are created and managed using python code. Airflow provides flexibility of using different operators(type of executable script) like bash, python etc. Airflow uses directed acyclic graph pattern for pipelines so it is easy to organise and manage tasks. It is open source project and well maintained.</p><h3>Apache Spark</h3><p>……. is a data processing tool which uses mapreduce algorithm &amp; also supports HDFS to process big data efficiently. Spark uses distributed processing by following master/worker node architecture. Unlike hadoop processes, spark uses in-memory processing which helps to achieve better performance. Spark provides flexibility of programming language like scala, java, python and R.</p><p><strong>HDFS Effective Storage methods : </strong>HDFS doesn’t have indexing to process the read effectively so there are alternative methods to overcome that difficulty.</p><p><strong>Partitioning</strong> -&gt; Storing the data into sub folders which are derived by category of dataset like enums. eg : record dates, products types.</p><p><strong>Bucketing -&gt; </strong>Storing the data into specified number sub folders using hashing algorithm.</p><p><strong>Compression</strong> -&gt; Pyspark supports multilpe compression types like Snappy, LZO, GZIP, etc.</p><p><strong>Storage Types -&gt; </strong>Pyspark supports multiple storage types like parquet, auro, plain text, etc.</p><p>For our usecase, we will be partioning the data by year and storing the data in parquet format by compressing using GZIP codec.</p><p><strong>GZIP — Quick Intro :</strong></p><p>Gzip is opensource codec which provides better compression &amp; moderate processing performance and doesnt support splitting. It is commonly used with parquet.</p><p><strong>Parquet — A Quick Intro:</strong></p><p>Parquet stores data column by column and it supports reading only selected columns values from disk. It also supports compression &amp; splitting of data.</p><h3>Lets Get Started</h3><blockquote><strong>Use Case</strong> : Fetch all countries GDP data from public server &amp; calculate yearly growth rate for last 8 years</blockquote><p>What is GDP -&gt; A country’s Gross Domestic Product (GDP) is a measure of the total value of all goods and services produced within a country’s borders during a specific period, usually a year.</p><p><strong>Solution</strong> : We will create simple <strong>ETL</strong> <strong>pipeline</strong> using airflow and make use of pyspark to transform and load the data into db.</p><p>Contents</p><ul><li>Airflow Setup &amp; Installation</li><li>Pyspark Setup &amp; Installation</li><li>Data Model &amp; DB Setup</li><li>Creating Pipeline in Airflow</li><li>First Task — Extract the raw data</li><li>Second Task — Transform the data</li><li>Third Task — Load the data</li><li>Demo</li><li>Whats next</li></ul><h4>Airflow Setup &amp; Installation</h4><p>First we will setup airflow locally and start the server.</p><p>Below commands will install airflow</p><pre>export AIRFLOW_HOME=~/airflow <br>AIRFLOW_VERSION=2.10.5 <br><br># Extract the version of Python you have installed. If you&#39;re currently using a Python version that is not supported by Airflow, you may want to set this manually.<br># See above for supported versions.<br>PYTHON_VERSION=&quot;$(python -c &#39;import sys; print(f&quot;{sys.version_info.major}.{sys.version_info.minor}&quot;)&#39;)&quot;<br><br>CONSTRAINT_URL=&quot;https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt&quot;<br># For example this would install 2.10.5 with python 3.8: https://raw.githubusercontent.com/apache/airflow/constraints-2.10.5/constraints-3.8.txt<br><br>pip install &quot;apache-airflow==${AIRFLOW_VERSION}&quot; --constraint &quot;${CONSTRAINT_URL}&quot;</pre><p>To Start the server for local development</p><pre>airflow standalone</pre><p>This command basically starts all the required internal components of airflow like DB creation &amp; user creation, Webserver, Scheduler. After running, airflow web console can be found at <a href="http://localhost:8080/">http://localhost:8080</a> and login can be found in airflow server logs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0iYIOiL7nriHCNr907E-xA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hiGr6l6eRKwCjW6ORtc8jw.png" /></figure><h4><strong>PySpark Setup &amp; Installation</strong></h4><p>Spark requires jvm &amp; supported java versions are 8,11,17. please make sure JAVA_HOME env is set</p><pre>brew install openjdk@17</pre><p>Once you are able to see java env path &amp; java version in your terminal. we will proceed to install pyspark libraries</p><p>Either we can install the below python libraries in virtual env or globally. <em>better way would be to use virtual env using requirements.txt</em></p><pre>pip install pyspark<br>pip install findspark</pre><h4>Data Model &amp; DB Setup</h4><p>We will be using postgress container &amp; its init DB query to create our destination table.</p><p><strong>init.sql</strong></p><figure><img alt="init.sql" src="https://cdn-images-1.medium.com/max/964/1*fZI9Re-AIy6TJr395DRFbQ.png" /></figure><p><strong>Container startup</strong></p><p>Repo have docker compose file , you can make use of it to create postgress container instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*jDZzJjs9I9P8FgNmTaLKNg.png" /></figure><h4>Creating ETL Pipeline in Airflow</h4><p>Data pipeline in airflow are made up of multiple tasks(single execution unit) and are organised using DAG ( Directed acyclic graph) data structure. Pipelines are created using python with the help of airflow libraries. Folder path containing pipeline codes are configurable in airflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQM5oubh3F-ZS70OpwNJRQ.png" /></figure><p>To create a pipeline, first we need to create .py file under Dags folder path mentioned in airflow config. Then we need to add meta info about the pipeline and then start adding tasks like shown in below example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*lzYRdZ4irb_e_qyqDd0qRg.png" /></figure><p>Most of the DE tutorials were mentioning about Change in a way of thinking while designing pipelines. As we are going to handle Big Data its better to design from the perspective on How can we divide the problem statement into sub tasks which can be executed separately and produce the result collectively at the end.</p><p>Lets relook into our problem statement and try to come up with the plan</p><p><em>Fetch the countries gdp growth and calculate the growth rate</em></p><p>As per the learnings , if we try to split the tasks for our problem statement. It would be</p><ol><li>Extract the information from server &amp; store the data into local storage</li><li>Read the data from the storage and perform the cleanup &amp; calculate the GDP growth rate for each year and store the data in to local storage</li><li>Fetch the processed information from the storage and store into final destination (postgres DB)</li></ol><p>There is no right or wrong way on dividing this task . By this way of splitting, each task can be executed independently and issues can be dealt separately without redoing the already executed tasks.</p><h4><strong>First Task – Extract the raw data</strong></h4><p>To achieve this task, we can use Airflow Bash Operator and make use of wget to fetch the information from server and store into my local directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wx7sDrc9YyOZAKfjk1zHLw.png" /></figure><p><strong>Output :</strong></p><p>CSV file is downloaded in input folder. It consist of 13980 records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*0WQrVm98cAUKQahzEXN0cQ.png" /></figure><h4><strong>Second Task – Transform the data</strong></h4><p>In this task, we will make use of Python Operator and Pyspark library to cleanup &amp; calculate the GDP growth rate for each year and store the data effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwj3Wp702mGNdi8WnFgJ_w.png" /></figure><p><em>Note : convertDataFromSource is implemented in separate python project.</em></p><p>Below are the steps performed during transformation</p><p><strong>Clean Up The Data</strong></p><ul><li>remove unwanted columns</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*LmBbPwb0MICB_5Mv9adTxQ.png" /></figure><ul><li>remove unwanted rows</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*k8a6aYBlejXtTNWGy8GXNA.png" /></figure><p><strong>Transform The Data</strong></p><p>We will make use of Spark SQL to calculate per year GDP growth rate.</p><blockquote><strong>Formula : ((Current Year GDP — Previous Year GDP) / Previous Year GDP ) * 100</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*JcGdpv8_R1CMvz4K8XTGOg.png" /></figure><p><strong>Stage the Data</strong></p><p>In this stage, we will store the processed data into local storage by following HDFS best practices like Partitioning &amp; Compressing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rqeqFRg6BycQHQvxElgdVA.png" /></figure><p><strong>Output</strong></p><p>Records are stored as parquet files using Partioned by Year &amp; compressed using GZIP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*Zp0r2lZdMqzI8qKbazhiWA.png" /></figure><h4><strong>Third Task – Load the data</strong></h4><p>In this stage, we will again use pyspark to read the transformed data and load the data into DB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gqGKyBp8GQWT_m9zOqqTEw.png" /></figure><p>Note : loadDataToDestination method is implemented in seperate package.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8FGvt-yAQWsi0_mJGjmuKg.png" /></figure><p>As the data is saved by year partitioned, we will be able to fetch the specific year &amp; load. For our usecase, we wanted to store last 8 years so we will fetch all the records and store into DB using JDBC operation.</p><p><strong>Output</strong></p><p>GDP Growth rate for all the countries are stored in our postgress db from 2015–2023.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*Pn-e4QVUfmDs_Ml2ppDWGQ.png" /></figure><h4>Demo</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmtEJLzuNk74%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmtEJLzuNk74&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmtEJLzuNk74%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1a6d81e1d96f1dc6a45b092aacc6870/href">https://medium.com/media/c1a6d81e1d96f1dc6a45b092aacc6870/href</a></iframe><h4><strong>What&#39;s Next?</strong></h4><p>As we have successfully completed our first ETL Pipeline using airflow, next would be creating ELT pipeline. Currently i have plan to do it using DBT. Anyways I will also be skimming through the web for good learning material for ELT. It would also be great if you share any suggestion for next learning material or feedbacks on current blog.</p><p>Notes :</p><p>Repository Link : <a href="https://github.com/jayandran-Sampath/data-pipelines">https://github.com/jayandran-Sampath/data-pipelines</a></p><p>Always follow Readme :) Drop me a message if in case you need any help</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d0c8f78b10d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Engineering – Getting started]]></title>
            <link>https://jaidg2012.medium.com/data-engineering-getting-started-367429e7c4cc?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/367429e7c4cc</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[airflow]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 14:18:10 GMT</pubDate>
            <atom:updated>2025-02-03T14:18:10.793Z</atom:updated>
            <content:encoded><![CDATA[<p>In Current AI era (<em>yes there were previous era’s where we failed to achieve super intelligence</em>), Data is core component for building machine learning models &amp; business intelligence. Quality &amp; quantity of data directly correlate with the output of the models. Good data provides better performance. So there is spike in demand for capturing quality data in large volume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7wtyK0BKBF5abv0CFwoC4w.png" /></figure><p><strong>Data Engineering</strong> is about capturing data which is required for business to understand and take necessary actions with the help of systems like Business Intelligence Systems / Machine Learning Services / Data Analysist. Data captured are used for analytics (<strong>OLAP</strong>) which differs from our usual transactional data (<strong>OLTP</strong>).</p><p>Data can be anything like plain text, image, encrypted, etc. It can be</p><ul><li>batched data like user order history / monthly billing information</li><li>streaming data like user behaviour / survey result / logs</li><li>real time data which requires immediate response like image capturing for threat analysis, transaction information for fraud detection etc</li></ul><p>There are two actors in this process.</p><ol><li><strong>Data Providers</strong> — are the platforms where data originates for the business. Usually providers are Application, Databases , Cloud providers, Web Scrappers etc. Role of data providers is crucial because data is backbone for any of the subsequent processes.</li><li><strong>Data Consumers</strong> — are end user of the captured data. Usually systems like Business Intelligence Systems, Machine Learning Models / Services, In-house Data Analysts / Scientist.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1V88XPjXvdnuXwHuUnQP1A.png" /></figure><p><strong>Data Pipeline </strong>is an data orchestration process where data is captured from providers and goes through series of transformation and shared to end consumers. During the transformation process, Raw data is transformed into Quality Data which can be readily consumed by methods like cleaning, filtering, reformatting, restructuring, etc. It is achieved through automated workflows with the help of modern tools. Data Engineer role evolve around this process so i will share my learnings below.(<em>For High level note — It is similar to infrastructure as code, where we automate complete infrastructure deployment using code. Similar to that, we will automate whole data orchestration workflow using code)</em></p><p>Data are processed in</p><ol><li><strong>Batches </strong>— <em>Where data is processed regularly like backup from database, sorting, filtering, etc. This way of process will be compute intensive and performance efficient as modern tools processes the batch of data in distributed way.</em></li><li><strong>Real Time / Streams </strong>— <em>Where data is continuous which may require immediate processing like sensor data/ real time transaction analysis, etc. Most of the cases, data is processed as soon as it arrives, providing instantaneous results or captured in streaming systems for further processes.</em></li></ol><p>Common steps followed to achieve this process.</p><ol><li>Ingestion — Data are collected from sources like Databases , Applications, IOT devices, Scrapping, SAAS application, Survey etc.</li><li>Staging — Collected datasets are ingested into staging environment which can be Streaming services / Operational data stores or hubs. Some of the file formats used during this process are csv, parquet, auro etc.</li><li>Cleaning — data usually goes through cleaning process like removal of duplication / reformatting the data / schema updates where data quality is streamlined.</li><li>Processing — clean data goes through set of transformation stage where data are appended with meta data / filtered &amp; remodelling into expected format.</li><li>Loading — Once data are transformed into expected format, data will be loaded into data warehouses / data lakes where BI Systems / ML Services / Analytics Systems can connect and consume the data for further processing.</li></ol><p>Data Pipelines are usually designed in two formats and terms are self explanatory ;)</p><ol><li>ETL -&gt; Extract Transform Load</li><li>ELT -&gt; Extract Load Transform</li></ol><p>For Practice, i have used airflow tool and created few simple ETL Processes and committed in a <a href="https://github.com/jayandran-Sampath/data-pipelines">data-repository.</a></p><p>Workflow looks like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jypuHWt6l46Pd6fW0Z1MWw.png" /></figure><p>Extract -&gt; Used wget tool to query online server for data using bash operator</p><p>Transform -&gt; Used python library (pandas) to clean up, filter and transform the data and generate SQL Queries for insertion using python operator</p><p>Load_data_DB -&gt; Used SQL to insert into Postgress db using Sql Operator</p><p>There are huge variety of tools &amp; systems available in market for data engineering. Some of the open source tech stacks which help us to practice</p><p>Programming Languages -&gt; Python, Scala, R</p><p>Orchestration Tools -&gt; Apache Airflow</p><p>Processing -&gt; Apache Spark , Apache Flink</p><p>Streaming services-&gt; Kafka</p><p>Storage -&gt; Apache Hadoop</p><p>Data Warehouse -&gt; Apache Doris</p><p>Data Lake -&gt; Apache Hudi</p><p>Data Base -&gt; Postgres, Mongo</p><blockquote>Github Repo Link : <a href="https://github.com/jayandran-Sampath/data-pipelines">https://github.com/jayandran-Sampath/data-pipelines</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=367429e7c4cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring jpa - performance improvement from 5.5s -> 350ms]]></title>
            <link>https://jaidg2012.medium.com/spring-jpa-performance-improvement-from-5-5s-350ms-250d6f92fc01?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/250d6f92fc01</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[spring-jpa]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 11:41:43 GMT</pubDate>
            <atom:updated>2025-01-06T11:41:43.816Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Situation</strong> : All the features are UAT completed and performance testing phase started. With first run(8 hrs soak test), team is not happy with specific feature result. It became blocker for production.</p><p><strong><em>Initial response time -&gt;17s</em></strong></p><p><strong><em>Average response time -&gt; 5.5s.</em></strong></p><p><strong>Tech stack:</strong></p><p>Spring boot with Elk Stack</p><p>Database : MySql</p><p><strong>Functional context of flow :</strong></p><p>similar type of data resides in four different tables and each record have an identifier number.</p><p>Post Request will contain 4 identifiers in body without having a clue of which table the identifier belongs to and process has to look into four different table for each of the identifier and return the record details as response.</p><p>To handle this flow, team have created view with combining multiple tables and fetching the details from view.</p><p><strong>Task</strong> : To Analyse and optimise the performance for the flow.</p><p><strong>Initial Analysis :</strong></p><ol><li>In Local DB, Simulated the setup and could see response time for single select query on view is taking more than <strong>5s</strong> initially.</li><li>SQL Explain statement for view query is already running via index’s.</li><li>Spring jpa execute each query on view table within transaction, so it has its own process of creating &amp; closure of transaction.</li><li>Child tables are queried using findBy entity which was retrieved from view for further details which is taking roughly <strong>1s</strong>.</li><li>All functionality for this process are handled in single service layer which had its own issues like nested flows, unnecessary conditions, etc..</li></ol><p>Tools used to troubleshoot the issue-&gt;</p><ol><li>Grafana metrics for repository methods</li><li>Database explain query for view</li><li>Kibana log timestamps</li><li>Actuator spring jpa metrics</li></ol><p><strong>Actions :</strong></p><p>Initial Step :</p><p><strong>Minor Fix </strong>: Targeted change to reduce time for child tables query responses.</p><ol><li>Changed Child table queries to use find by id rather than find by entity</li><li>Used projection with required fields rather than getting all fields in entity</li></ol><p><strong>Results </strong>: Deployed &amp; ran high level Performance test and could see improved response time for child table queries from <strong>1s -&gt; 150–300 ms.</strong></p><p>With positive result from initial fix, i have proposed the approach of refactoring the flow without using view.</p><p><strong>Final Step :</strong></p><p><strong>Fixes :</strong></p><ol><li>Used Derived table query which returns only Table Name &amp; primary key ID of the record <br>— which avoids usage of view <br>— also avoids unnecessary Spring transactions creation &amp; closure</li><li>Used primary key id to find the record and fetch the details</li><li>Use of projection to fetch only required data</li><li>Use functional knowledge to identify the grouping of data and customise the query for targeted flow</li><li>Refactor the code by splitting single service handling into multiple services based on functionality.</li></ol><p><strong>Result :</strong></p><p>Initial response time from <strong>17s -&gt; 1s</strong></p><p>Average Response time from <strong>5s -&gt; 350ms</strong></p><p><strong>Take Away :</strong></p><ol><li>Usage of view in mysql comes with cost, we should decide accordingly</li><li>Alternate of using view, we can use derived table query to achieve the same result</li><li>Make use of projection instead of getting all fields in entity</li><li>Use findBy ID(<em>PrimaryKey</em>) rather than findBy entity for child table queries</li><li>Write decoupled code for better performance</li><li>Use functional knowledge to segregate the flow</li><li>Use metrics tools like Micrometer &amp; ELK Stack for better observer ability</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=250d6f92fc01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ActionBuilders in Scala Play framework]]></title>
            <link>https://jaidg2012.medium.com/actionbuilders-in-scala-play-framework-4c3ea6ffea6b?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c3ea6ffea6b</guid>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[scala]]></category>
            <category><![CDATA[action-builder]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[play]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 17:10:37 GMT</pubDate>
            <atom:updated>2023-06-16T17:10:37.845Z</atom:updated>
            <content:encoded><![CDATA[<p>As we discussed in <a href="https://medium.com/dev-genius/developing-restapi-using-scala-play-framework-d5df0cec8a10">previous blog</a>, play handles all the request using action methods. Play also provides more flexibility to handle the request efficiently using action builders.</p><p><strong>How does action builders help?</strong></p><p><em>Action builders are like </em><strong><em>Interceptors </em></strong><em>and its of type Trait (i.e Interface). It has </em><strong><em>4 types </em></strong><em>commonly used and each one have its </em><strong><em>own abstract methods</em></strong><em>.</em></p><p><strong>How does action builders works?</strong></p><p><em>Based on our need, we can choose trait and add our custom implementation for those abstract methods and tie it with action method in our controller. Also we can chain multiple action builders with our action method.</em></p><p><strong>Action Builder Traits Types :</strong></p><p><strong>Action Transformer</strong> : <em>It is used to transform incoming request into another form, most common case would be adding additional fields to the request after authentication. Below is the trait where Type R will be converted into Type P. To achieve this functionality, we need to implement invoke method.</em></p><pre>trait ActionTransformer[-R[_], +P[_]] extends ActionRefiner[R, P]</pre><p><strong>Action Filter</strong> : <em>Intercept the request and conditionally make the decision to proceed without changing the request. To achieve this functionality we need to implement filter method to return result either with None(i.e : to proceed further)or Some(i.e: to return result immediately).</em></p><pre>trait ActionFilter[R[_]] extends ActionRefiner[R, R]</pre><p><strong><em>Action Refiner</em></strong> : <em>Refiner is parent of both filter &amp; transformer so we can choose to decide either to block or proceed further with transforming the request type into another type. To achieve this functionality we need to implement refine method to return future Result Type P either with Right(i.e : to proceed further)or Left(i.e: to return immediately).</em></p><pre>trait ActionRefiner[-R[_], +P[_]] extends ActionFunction[R, P]</pre><p><strong><em>Action Builder :</em></strong> <em>As name implies, it builds action with another another. It takes request as input and build actions. To achieve this functionality, we need to implement invoke method.</em></p><pre>trait ActionBuilder[+R[_], B] extends ActionFunction[Request, R]</pre><p>I have implemented Action Filter &amp; Action Builder traits with our login api to achieve Logging &amp; Authentication.</p><ol><li>Implemented ActionBuilder to get request body (i.e emailId) for all login request and add log based on it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ABO9ImOA1MiMx-1qGHwU7Q.png" /></figure><p>To make use of this Implementation, we need to add it in our Controller Action Method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXk7KZ1mcWqP67CAK__viQ.png" /></figure><p>2. Implemented ActionFilter Triat to perform custom authentication by validating request headers (i.e userId &amp; Authentication).</p><ol><li>If userId or authentication token not present in headers, bad request is returned with result (i.e Future.<em>successful</em>(Some(<em>BadRequest</em>)))</li><li>If data is invalid, forbidden result is returned (i.e Future.<em>successful</em>(Some(<em>Forbidden</em>))</li><li>For successful validation Future.<em>successful</em>(None) is returned, so the next consecutive actions are performed.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKkDXzYWueFtG0xiYizt8A.png" /></figure><p>To make use of this Implementation, we need to add it in our Controller Action Method. It is been added with andThen method to show how we can chain action builders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OH7XKwM3i_0MORNY8J8TSQ.png" /></figure><p>Full CodeBase : <a href="https://github.com/jayandran-Sampath/login-api.git">https://github.com/jayandran-Sampath/login-api.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c3ea6ffea6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing RestAPI using Scala Play Framework]]></title>
            <link>https://blog.devgenius.io/developing-restapi-using-scala-play-framework-d5df0cec8a10?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5df0cec8a10</guid>
            <category><![CDATA[example]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[play]]></category>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 15:07:13 GMT</pubDate>
            <atom:updated>2023-05-02T09:35:27.127Z</atom:updated>
            <content:encoded><![CDATA[<p>What is Play Framework?</p><blockquote>Play is simple &amp; very lite MVC driven framework, which comes with very minimal configuration to handle common factors for web development like Exceptions handling, Logging, Dependency injection, etc. more info can be referred in <a href="https://www.playframework.com/">official site</a></blockquote><h4>Architecture of play framework</h4><ol><li>Requests initiated from client, for eg: GET — curl <a href="http://localhost:9000/users.">http://localhost:9000/users.</a></li><li>The Play internal HTTP Server receives the request.</li><li>Play resolves the request using the routes file, which maps URIs to controller action methods, for eg: GET /users controller.HomeControllers.getUsers().</li><li>The action method gets the list of users in json object.</li><li>The HTTP server returns the response as an json response.</li></ol><p>In this blog, we are going to create simple rest service for user to register &amp; login.</p><p>To generate template project, we are going to run sbt play template. please find the below screenshot for reference</p><pre>sbt new playframework/play-scala-seed.g8</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QFpg2HitHqqJKdYXhUBEfA.png" /></figure><p>First, we have to implement service classes to accept user registration data and validate &amp; save the details inUserList &amp; LoginDetails in-memory maps.</p><p>Lets create three models to handle the data, as below</p><p>models/Register.scala<em> </em>-&gt; <em>Case class to define the model to handle the request data &amp; Object to implement methods to handle read &amp; write data into json structure</em></p><pre>case class Register(userEmail: String, password: String, firstName: String, lastName: String)<br><br>object Register {<br><br>  implicit val implicitRegisterWrites = new Writes[Register] {<br>    def writes(registerDetails: Register): JsValue = {<br>      Json.obj(&quot;emailId&quot; -&gt; registerDetails.userEmail,<br>        &quot;password&quot; -&gt; registerDetails.password,<br>        &quot;firstName&quot; -&gt; registerDetails.firstName,<br>        &quot;lastName&quot; -&gt; registerDetails.lastName,<br>      )<br>    }<br>  }<br><br>  implicit val implicitRegisterReads: Reads[Register] = (<br>    (JsPath \ &quot;emailId&quot;).read[String] and<br>      (JsPath \ &quot;password&quot;).read[String] and<br>      (JsPath \ &quot;firstName&quot;).read[String] and<br>      (JsPath \ &quot;lastName&quot;).read[String]<br>    ) (Register.apply _)<br>}</pre><p><em>models/User.scala</em> -&gt; User case class to define model of user with details &amp; User object to implement methods to handle read &amp; write in json.</p><pre>case class User (userEmail: String, firstName:String, lastName:String)<br><br>object User {<br><br>  implicit val implicitUserWrites = new Writes[User] {<br>    def writes(user: User): JsValue = {<br>      Json.obj(&quot;emailId&quot; -&gt; user.userEmail,<br>        &quot;firstName&quot; -&gt; user.firstName,<br>        &quot;lastName&quot; -&gt; user.lastName,<br>      )<br>    }<br>  }<br><br>  implicit val implicitUserReads: Reads[User] = (<br>    (JsPath \ &quot;emailId&quot;).read[String] and<br>      (JsPath \ &quot;firstName&quot;).read[String] and<br>      (JsPath \ &quot;lastName&quot;).read[String]<br>    ) (User.apply _)<br>}</pre><p><em>models/Login.scala -&gt; </em>Login case class to define model to store user login with hash password</p><pre>case class Login(userId: String, hash: String)</pre><p>Next, Lets create service classes</p><p><em>service/Authentication.scala </em>→ Service class to generateHash for the password</p><blockquote>We will use Bcrypt library to handle the hashing</blockquote><pre>@Singleton<br>class AuthenticationService extends AuthInterface {<br>  private val logger = Logger(getClass)<br>  override def generateHash(password:String): String = password.bcryptSafeBounded match {<br>    case Success(value) =&gt; {<br>      logger.info(&quot;generated hash value for password&quot;)<br>      value<br>    }<br>    case Failure(exception) =&gt; {<br>      logger.error(&quot;exception occurred while hashing the password &quot;+exception)<br>      throw new RuntimeException(&quot;Exception occurred while parsing the password&quot;)<br>    }<br>  }<br>}</pre><p><em>service/UserService.scala </em>→ Service class to accept register details &amp; save it in repository</p><blockquote>UserRepository &amp; Authentication service will be injected during runtime</blockquote><pre>@Singleton<br>class UserService @Inject()(val userRepository: UserRepository, val authenticationService: AuthenticationService){<br>  private val logger = Logger(getClass)<br><br>  def registerUser(registerDetails : Register): Unit = {<br>    logger.info(&quot;registerUser service method invoked&quot;)<br>    val hashPassword = authenticationService.generateHash(registerDetails.password)<br>    userRepository.registerUser(registerDetails,hashPassword)<br>  }<br>}</pre><p>Lets write controller method to handle the action for the route</p><p><em>controllers/HomeController.scala -&gt; </em>registerUser method handles the action for the request</p><blockquote>request is converted in to Json structure &amp; then transfered to user service class handler as scala object , Once successful execution of service method, Action response is returned with 200 Ok with body of Json object</blockquote><pre>@Singleton<br>class HomeController @Inject()(val controllerComponents: ControllerComponents,<br>                               val userService: UserService) extends BaseController {<br><br>  private val logger: Logger = Logger(this.getClass())<br><br>  def registerUser = Action { request =&gt;<br>    logger.info(&quot;registerUser method invoked&quot;)<br>    val json = request.body.asJson.get<br>    userService.registerUser(json.as[Register])<br>    Ok(Json.obj(&quot;status&quot; -&gt; &quot;success&quot;, &quot;message&quot; -&gt; &quot;user registered successfully!&quot;))<br>  }<br>}</pre><p>Lets configure route for user registration endpoint , route file can be found in config/routes</p><p>Add below line to configure user registeration (/user/register) endpoint with action method</p><pre>POST    /user/register              controllers.HomeController.registerUser</pre><p>Now, lets start the service</p><pre>sbt run</pre><p>verify the endpoint using curl</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUYUCN1UbqRdNIaBEeycTA.png" /></figure><p>service logs for execution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tKEtubCV9kf5r3yZ765ISg.png" /></figure><p>Below repository have full implementation of both user registration &amp; login. As part of it, i have covered Common error handling, Logging, mocking, unit test which i will try to cover in coming blogs !</p><p><a href="https://github.com/jayandran-Sampath/login-api">https://github.com/jayandran-Sampath/login-api</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5df0cec8a10" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/developing-restapi-using-scala-play-framework-d5df0cec8a10">Developing RestAPI using Scala Play Framework</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Every method/function call you make is adding your time of execution]]></title>
            <link>https://jaidg2012.medium.com/every-method-function-call-you-make-is-adding-your-time-of-execution-86ee73cebafc?source=rss-452bf95fc10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/86ee73cebafc</guid>
            <category><![CDATA[uiautomation]]></category>
            <category><![CDATA[webdriverio]]></category>
            <category><![CDATA[appium]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Jay]]></dc:creator>
            <pubDate>Sat, 20 Mar 2021 11:10:10 GMT</pubDate>
            <atom:updated>2021-03-20T11:24:19.446Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Every method/function call you make is adding your time of execution</strong></p><p>General mindset of us while writing automation test was we wanted to keep the test stable and test the functionality without any flakiness. So to avoid flakiness we tend to cover up the test with wait methods &amp; assertion on dependent elements status.</p><p>Let me show you the code on how it will impact the execution performance in case of unwanted wait method &amp; assertions</p><p><em>Im going to use Webdriverio, Browserstack &amp; Appium(Native App) for this exercise</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*IKdvw5FDuBY-gOT0GUZ4GA.png" /></figure><p>This snippet is used to perform login by entering details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*6YZDNNK-EvjfmZdb_IEeng.png" /></figure><p>Is this looks normal and how we generally write test??????</p><p>Right!!! So if you notice we are checking whether the element is displayed and then we are entering the value in the element. This seems fine in case of page to page navigation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*GzG8O2Gt78tKK6RRbs9Ehg.png" /></figure><p>Above functions are used to enter Password &amp; click on Login button and it also have similar setup of validating the element status and then performing the action.</p><p>if you notice, i have checked whether both Password &amp; Login Button element is displayed also i have used SetValue for Password (which internally clear the element before setting the value)</p><p>These method calls will have their own processing time. Below are time from Browserstack Logs</p><pre>Password Textbox =&gt; waitForDisplayed method call took <strong>478 + 26</strong> ms </pre><pre>Password Textbox =&gt; Element clear method call took <strong>31 ms</strong></pre><pre>Login Button =&gt; waitForDisplayed method call took <strong>490 + 31 ms</strong></pre><p><strong>As a QA, i know My Password textbox &amp; Login button should be present below Email Id text box and i dont need to check for the element status before performing action</strong></p><p><strong>Similarly As a business expectation, Password field should be empty on landing in login form so clearing the field before entering password is also unwanted and it will hide my APP Bug in case password field is not working as expected.</strong></p><p>So if we calculate the overall unwanted method call/assertion time in this simple snippet <strong>1056 ms =&gt; 1.056 s</strong></p><pre>Some stats: <br>In my current project we are executing around 25+ build every day and we have around 300+ test cases </pre><pre><strong>300 (TC) * 25(Build) * 1.056 =&gt; 7920 </strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*9vYy_ZuYqc0CDl4eS8jBcA.png" /></figure><p>Wow.. its around 2.2 hrs every day. Hope i make sense!!!!!!!</p><p><strong><em>So lets identify these kind of unwanted method/function calls &amp; remove it. Smaller changes can collectively improve the performance of test</em></strong></p><p>Appium Log — <a href="https://gist.github.com/jayandran-Sampath/c892e70ea9649a81fa19710a73d0c8a5">Log file</a></p><p>Please find the Repo Link below</p><p>Branch (<a href="https://github.com/jayandran-Sampath/TestAutomationRepo/tree/notOptimized">notOptimized</a>) — Code without optimisation</p><p>Branch (Main) — Optimised code</p><p><a href="https://github.com/jayandran-Sampath/TestAutomationRepo">jayandran-Sampath/TestAutomationRepo</a></p><p>Main Blog (<a href="https://jaidg2012.medium.com/is-your-ui-automation-takes-more-time-than-manual-7427e4cce0ab">https://jaidg2012.medium.com/is-your-ui-automation-takes-more-time-than-manual-7427e4cce0ab</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86ee73cebafc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>