<?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: Prateek Kr</title>
    <description>The latest articles on DEV Community by Prateek Kr (@prateek_kr).</description>
    <link>https://dev.to/prateek_kr</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%2F2205933%2F1e6c39e0-cfad-43b7-8146-fa05f86035b9.jpg</url>
      <title>DEV Community: Prateek Kr</title>
      <link>https://dev.to/prateek_kr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prateek_kr"/>
    <language>en</language>
    <item>
      <title>How to analyse an image with GPT 5 — a practical, production-ready guide</title>
      <dc:creator>Prateek Kr</dc:creator>
      <pubDate>Mon, 13 Oct 2025 11:57:21 +0000</pubDate>
      <link>https://dev.to/prateek_kr/how-to-analyse-an-image-with-gpt-5-a-practical-production-ready-guide-5b51</link>
      <guid>https://dev.to/prateek_kr/how-to-analyse-an-image-with-gpt-5-a-practical-production-ready-guide-5b51</guid>
      <description>&lt;p&gt;This article shows a &lt;strong&gt;clean, copy-pasteable&lt;/strong&gt; Python example for analyzing an architecture diagram image using a GPT multimodal model. You’ll get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A minimal, production-oriented code snippet (cleaned of comments / clutter)
&lt;/li&gt;
&lt;li&gt;A line-by-line explanation of how the code works
&lt;/li&gt;
&lt;li&gt;Prompt-engineering tips for accurate, structured output
&lt;/li&gt;
&lt;li&gt;Important &lt;em&gt;gotchas&lt;/em&gt; (image size, encoding, costs, privacy, and error handling)
&lt;/li&gt;
&lt;li&gt;Suggestions for parsing and validating responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The snippet below assumes you have a configured &lt;code&gt;client&lt;/code&gt; object that wraps your OpenAI-compatible API (Azure OpenAI or OpenAI). Replace the &lt;code&gt;model&lt;/code&gt; string with the multimodal model name available to you (e.g., &lt;code&gt;gpt-5&lt;/code&gt;, &lt;code&gt;gpt-4o&lt;/code&gt;, or the provider-specific variant).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clean, copy-pasteable Python code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from clients import client
import base64
from io import BytesIO
from PIL import Image

IMAGE_SRC = "./assets/banking.png"
MODEL = "gpt-4o"  # replace with your multimodal model name if different

def encode_image_pil(img: Image.Image) -&amp;gt; str:
    buffered = BytesIO()
    fmt = img.format or "PNG"
    img.save(buffered, format=fmt)
    return base64.b64encode(buffered.getvalue()).decode("utf-8")

def analyze_image_pil(img: Image.Image, model: str = MODEL, temperature: float = 0.0):
    encoded = encode_image_pil(img)
    prompt_text = (
        "Analyze the architecture diagram in the image in comprehensive detail. "
        "1) Identify every distinct block and name it as a service/module. For each, describe its role. "
        "2) For every connection, list the exact data types/names that flow (include direction). "
        "3) List any text visible in the image verbatim. "
        "4) Describe the full system behaviour and highlight bottlenecks or single points of failure. "
        "Return the analysis as JSON with keys: blocks[], connections[], visible_text[], summary, issues[]. "
    )
    response = client.chat.completions.create(
        model=model,
        messages=[
            {"role": "user", "content": [{"type": "text", "text": prompt_text},
                                        {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{encoded}", "detail": "high"}}]}
        ],
        temperature=temperature,
    )
    return response.choices[0].message.content

if __name__ == "__main__":
    img = Image.open(IMAGE_SRC)
    result = analyze_image_pil(img)
    print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What the code does — step-by-step&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Imports and constants&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;from clients import client — client is your pre-configured OpenAI/Azure client. Keep credentials/config outside this file.&lt;/li&gt;
&lt;li&gt;base64, BytesIO, and PIL.Image are used to convert an in-memory image into a base64 data URI suitable for embedding into the chat request.&lt;/li&gt;
&lt;li&gt;IMAGE_SRC and MODEL are simple constants you can change to point to a different file or to select a different model.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. encode_image_pil&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accepts a PIL.Image.Image instance.&lt;/li&gt;
&lt;li&gt;Uses a BytesIO buffer and img.save(...) to serialize the image into its native or fallback format (PNG).&lt;/li&gt;
&lt;li&gt;Base64-encodes the bytes and returns a UTF-8 string.&lt;/li&gt;
&lt;li&gt;Why: A data: URL (data:image/png;base64,&amp;lt;...&amp;gt;) is a portable way to include an image inline in the request. Some providers accept binary uploads — check your client API if you prefer attachments instead of base64.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. analyze_image_pil&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Builds a clear, structured prompt asking for:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identification of blocks (services/modules)&lt;/li&gt;
&lt;li&gt;Exact data flows with data names and direction&lt;/li&gt;
&lt;li&gt;Verbatim visible text from the image&lt;/li&gt;
&lt;li&gt;System summary and issues/bottlenecks&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The function sends a single chat request that contains both a text item and an image_url item where the image_url is a data: URI containing the base64 image.&lt;/li&gt;
&lt;li&gt;temperature is set to 0.0 by default to maximize determinism for structural analysis. For more creative, higher-level interpretation you can raise it.&lt;/li&gt;
&lt;li&gt;Return: response.choices[0].message.content (this returns the model output in a provider-specific structure).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. &lt;strong&gt;main&lt;/strong&gt; usage&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Opens the image file with PIL and calls analyze_image_pil.&lt;/li&gt;
&lt;li&gt;Prints the model response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prompt engineering &amp;amp; output structure (why we ask for JSON)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Asking the model to return JSON with explicit keys (blocks, connections, visible_text, summary, issues) helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parse programmatically and validate results.&lt;/li&gt;
&lt;li&gt;Enforce consistent structure across different images.&lt;/li&gt;
&lt;li&gt;Avoid missed details (the model can be instructed to error if it can't find a key).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example JSON structure you should ask for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "blocks": [
    {
      "id": "AuthService",
      "label": "Auth Service",
      "role": "Issue JWT tokens",
      "data_in": ["credentials(username, password)"],
      "data_out": ["jwt_token"]
    }
  ],
  "connections": [
    {
      "from": "Frontend",
      "to": "AuthService",
      "data": ["login_request { username, password }"]
    }
  ],
  "visible_text": ["User Login", "DB: Postgres"],
  "summary": "...",
  "issues": ["AuthService is a single point of failure"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need stricter parsing, request content-type: application/json or ask the model to always wrap JSON in triple backticks and nothing else. Then validate with json.loads().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key gotchas &amp;amp; best practices&lt;/strong&gt;&lt;br&gt;
1) Image size and base64 length&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Base64 increases payload size by ~33%. Very large images can blow up request size or exceed API limits.&lt;/li&gt;
&lt;li&gt;Best practice: resize or compress images (downscale while preserving readability) before encoding. Use PNG for diagrams, JPEG for photos where acceptable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2) Format detection&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The code uses img.format if available, otherwise falls back to PNG. Ensure PIL recognized the format; otherwise save as PNG.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3) Model selection&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the multimodal model provided by your vendor. Replace MODEL value with the latest multimodal model name you have access to (e.g., gpt-5 or a vendor-specific alias).&lt;/li&gt;
&lt;li&gt;Some models are better at text extraction (OCR), others at structural reasoning; test and tune.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4) Temperature &amp;amp; determinism&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;temperature=0.0 yields deterministic, conservative output (good for structured extraction).&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Higher temperature gives more creative / speculative answers — useful for brainstorming but not for precise extraction.&lt;br&gt;
5) Costs &amp;amp; rate limits&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multimodal models are often more expensive and may have different quotas. Batch requests and cache results where possible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For bulk image processing, implement retry/backoff and monitor billing.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;6) Privacy &amp;amp; security&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Don’t send PII or sensitive diagrams to public APIs unless permitted by policy. If the image contains sensitive data, sanitize or host on a private, audited endpoint.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consider on-premise or enterprise offerings if compliance is required.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;7) OCR vs structural interpretation&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you only need text in the image, dedicated OCR tools may be cheaper and more deterministic.&lt;/li&gt;
&lt;li&gt;For structural interpretation (blocks, flows, architectural reasoning) multimodal LLMs offer richer semantic outputs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;8) Data URI vs binary uploads&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;data: URIs are simple and portable but large. Check your client library for binary upload methods (multipart/form-data or separate image input fields) — those are more efficient.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;9) Validation &amp;amp; fallback&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always validate JSON returned by the model. The model may return malformed JSON if the prompt isn’t strict.&lt;/li&gt;
&lt;li&gt;Add retries or a secondary prompt to reformat output if parsing fails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advanced tips&lt;/strong&gt;&lt;br&gt;
1) Use schema enforcement&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ask the model to validate its own JSON before returning, or run a JSON schema validator locally after receiving the reply.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2) Two-step pipeline for extreme reliability&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, ask the model to extract visible text and primitive OCR (low temperature).&lt;/li&gt;
&lt;li&gt;Second, feed the extracted text + simplified structural image to a second prompt for deeper reasoning (bottlenecks, verification).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3) Human-in-the-loop verification&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For critical architecture diagrams, present the structured output to a human reviewer who can correct or confirm before taking automated actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example: parse and validate JSON safely&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json

raw = analyze_image_pil(img)
# Model might return a markdown-wrapped JSON; strip code fences if needed
if isinstance(raw, str):
    raw = raw.strip()
    if raw.startswith("```

"):
        raw = raw.split("

```")[1] if "```

" in raw else raw

try:
    parsed = json.loads(raw)
except json.JSONDecodeError:
    raise ValueError("Model returned non-JSON output. Consider tightening your prompt.")



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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final checklist before productionizing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limit image resolution to what’s necessary for readability.&lt;/li&gt;
&lt;li&gt; Use deterministic prompts + temperature=0.0 for extraction tasks.&lt;/li&gt;
&lt;li&gt; Request JSON and validate locally.&lt;/li&gt;
&lt;li&gt; Protect sensitive images (don’t leak PII).&lt;/li&gt;
&lt;li&gt; Monitor API usage &amp;amp; costs.&lt;/li&gt;
&lt;li&gt; Add retries, exponential backoff, and rate-limiting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Multimodal GPT models make it straightforward to extract structured architecture insights from diagrams, but reliable production usage requires careful image handling, explicit prompt engineering, and robust validation. Use the cleaned code above as a starting point; iterate on prompts, model choice, and data handling to reach the reliability your product needs.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding app.config.ts in Angular 19 Standalone Applications — A Complete Guide</title>
      <dc:creator>Prateek Kr</dc:creator>
      <pubDate>Mon, 13 Oct 2025 11:37:18 +0000</pubDate>
      <link>https://dev.to/prateek_kr/understanding-appconfigts-in-angular-19-standalone-applications-a-complete-guide-5coh</link>
      <guid>https://dev.to/prateek_kr/understanding-appconfigts-in-angular-19-standalone-applications-a-complete-guide-5coh</guid>
      <description>&lt;p&gt;In this article, we’ll deep-dive into every line of a real-world app.config.ts file that integrates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Angular Standalone APIs&lt;/li&gt;
&lt;li&gt;PrimeNG theming (Lara theme)&lt;/li&gt;
&lt;li&gt;NgRx Store + Effects + DevTools&lt;/li&gt;
&lt;li&gt;HTTP Client with Fetch&lt;/li&gt;
&lt;li&gt;Markdown rendering (ngx-markdown + PrismJS highlighting)&lt;/li&gt;
&lt;li&gt;Zone optimization for better performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end, you’ll understand how to structure, configure, and optimize your Angular 19 standalone app configuration file like a pro.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Complete app.config.ts Code&lt;/strong&gt;&lt;br&gt;
Here’s the full configuration we’ll be dissecting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ApplicationConfig, provideZoneChangeDetection, SecurityContext, isDevMode } from '@angular/core';
import { provideRouter } from '@angular/router';

import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { providePrimeNG } from 'primeng/config';
import Lara from '@primeng/themes/lara';

import { routes } from './app.routes';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { CLIPBOARD_OPTIONS, ClipboardButtonComponent, MARKED_OPTIONS, MERMAID_OPTIONS, provideMarkdown } from 'ngx-markdown';
import 'prismjs';
import 'prismjs/components/prism-typescript.min.js';
import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
import 'prismjs/plugins/line-highlight/prism-line-highlight.js';
import { provideStore } from '@ngrx/store';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import { provideEffects } from '@ngrx/effects';
import { getModalsReducer } from './store/reducers';
import { Effects } from './store/effects';

export const appConfig: ApplicationConfig = {
  providers: [
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideRouter(routes),
    provideAnimationsAsync(),
    providePrimeNG({
        theme: {
            preset: Lara,
            options: {
                // prefix: 'p',
                darkModeSelector: 'false',
                // colorScheme:  'light',
                cssLayer: false
            }
        }
    }),
    provideHttpClient(withFetch()),
    provideMarkdown({
        mermaidOptions: {
            provide: MERMAID_OPTIONS,
            useValue: {
                darkMode: true,
                look: 'handDrawn',
            },
        },
        clipboardOptions: {
            provide: CLIPBOARD_OPTIONS,
            useValue: {
                buttonComponent: ClipboardButtonComponent,
            },
        },
        sanitize: SecurityContext.NONE,
        markedOptions: {
            provide: MARKED_OPTIONS,
            useValue: {
                gfm: true,
                breaks: false,
                pedantic: false,
            }
        },
    }),
    provideStore({ modals: getModalsReducer }),
    provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() }),
    provideEffects([Effects])
  ]
};

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is app.config.ts in Angular 19?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Angular 19 standalone apps, you don’t use AppModule anymore. Instead, you configure all global providers in one place — app.config.ts.&lt;/p&gt;

&lt;p&gt;This configuration object (ApplicationConfig) is passed to your app’s entry point:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bootstrapApplication(AppComponent, appConfig);

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

&lt;/div&gt;



&lt;p&gt;It defines everything your app needs globally: routing, HTTP, theming, markdown, animations, NgRx, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Line-by-Line Explanation&lt;/strong&gt;&lt;br&gt;
Let’s break it down step by step:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Core Angular Imports&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ApplicationConfig, provideZoneChangeDetection, SecurityContext, isDevMode } from '@angular/core';

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;ApplicationConfig — Type that defines app-wide providers for standalone apps.&lt;/li&gt;
&lt;li&gt;provideZoneChangeDetection — Configures Angular’s zone-based change detection.&lt;/li&gt;
&lt;li&gt;SecurityContext — Controls how Angular sanitizes content (used in Markdown rendering).&lt;/li&gt;
&lt;li&gt;isDevMode() — Detects if the app is running in development mode — handy for enabling debug tools conditionally.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Angular Router&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { provideRouter } from '@angular/router';
import { routes } from './app.routes';

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;provideRouter(routes) installs Angular Router without needing RouterModule.forRoot().&lt;/li&gt;
&lt;li&gt;Your route definitions live in app.routes.ts, typically as a Routes array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Animations Setup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Enables Angular’s animation engine asynchronously.&lt;/li&gt;
&lt;li&gt;The async variant helps tree-shake animation code and reduce bundle size when animations aren’t immediately needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;PrimeNG Theme Configuration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { providePrimeNG } from 'primeng/config';
import Lara from '@primeng/themes/lara';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then configured like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;providePrimeNG({
  theme: {
    preset: Lara,
    options: {
      darkModeSelector: 'false',
      cssLayer: false
    }
  }
})

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;providePrimeNG() globally sets up PrimeNG.&lt;/li&gt;
&lt;li&gt;preset: Lara applies the beautiful Lara theme.&lt;/li&gt;
&lt;li&gt;darkModeSelector — defines a CSS selector for dark mode (here it’s disabled).&lt;/li&gt;
&lt;li&gt;cssLayer — controls CSS layering behavior. Setting it false prevents layering issues if you manage your own global styles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can customize prefix, color scheme, or even dynamically switch themes later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Client with Fetch API&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { provideHttpClient, withFetch } from '@angular/common/http';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;provideHttpClient() — Bootstraps the modern Angular HTTP Client for standalone apps.&lt;/li&gt;
&lt;li&gt;withFetch() — Uses the native Fetch API under the hood (instead of XMLHttpRequest).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smaller bundle size&lt;/li&gt;
&lt;li&gt;Modern streaming support&lt;/li&gt;
&lt;li&gt;Better Service Worker integration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your app relies on progress events, verify behavior as Fetch doesn’t provide them the same way as XHR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Markdown Rendering with ngx-markdown&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { CLIPBOARD_OPTIONS, ClipboardButtonComponent, MARKED_OPTIONS, MERMAID_OPTIONS, provideMarkdown } from 'ngx-markdown';

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

&lt;/div&gt;



&lt;p&gt;Then configured as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provideMarkdown({
  mermaidOptions: {
    provide: MERMAID_OPTIONS,
    useValue: {
      darkMode: true,
      look: 'handDrawn',
    },
  },
  clipboardOptions: {
    provide: CLIPBOARD_OPTIONS,
    useValue: {
      buttonComponent: ClipboardButtonComponent,
    },
  },
  sanitize: SecurityContext.NONE,
  markedOptions: {
    provide: MARKED_OPTIONS,
    useValue: {
      gfm: true,
      breaks: false,
      pedantic: false,
    }
  },
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup enables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Markdown rendering via the marked library.&lt;/li&gt;
&lt;li&gt;Mermaid diagrams (MERMAID_OPTIONS) with dark mode and hand-drawn style.&lt;/li&gt;
&lt;li&gt;Clipboard copy button (ClipboardButtonComponent) for code snippets.&lt;/li&gt;
&lt;li&gt;sanitize: SecurityContext.NONE — disables sanitization, allowing raw HTML in Markdown.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security Tip:&lt;br&gt;
Only set SecurityContext.NONE if the Markdown content is 100% trusted. Otherwise, use SecurityContext.HTML to avoid XSS risks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax Highlighting with PrismJS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'prismjs';
import 'prismjs/components/prism-typescript.min.js';
import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
import 'prismjs/plugins/line-highlight/prism-line-highlight.js';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;These are side-effect imports.&lt;/li&gt;
&lt;li&gt;They load PrismJS with TypeScript syntax highlighting and plugins for line numbers and line highlighting.&lt;/li&gt;
&lt;li&gt;Perfect for rendering code blocks in documentation or Markdown.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can add more languages by importing other Prism components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;State Management with NgRx&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { provideStore } from '@ngrx/store';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import { provideEffects } from '@ngrx/effects';
import { getModalsReducer } from './store/reducers';
import { Effects } from './store/effects';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configured as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provideStore({ modals: getModalsReducer }),
provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() }),
provideEffects([Effects])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;provideStore() — Registers your global store with a reducer map.&lt;/li&gt;
&lt;li&gt;modals: getModalsReducer — Example slice managing modal dialogs.&lt;/li&gt;
&lt;li&gt;provideStoreDevtools() — Enables Redux DevTools integration (logs up to 25 states).&lt;/li&gt;
&lt;li&gt;logOnly: !isDevMode() — Prevents dispatching actions from DevTools in production.&lt;/li&gt;
&lt;li&gt;provideEffects() — Registers side effects for async logic (API calls, etc.).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Bonus: Zone Optimization&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;provideZoneChangeDetection({ eventCoalescing: true })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;eventCoalescing: true batches multiple synchronous DOM events to reduce unnecessary change detection cycles.&lt;/li&gt;
&lt;li&gt;Results in better performance for interactive UIs (forms, scroll events, etc.).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Putting It All Together&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This single file replaces what used to be spread across multiple NgModules, AppModules, and providers.&lt;/p&gt;

&lt;p&gt;Here’s how it connects to your main.ts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { appConfig } from './app.config';

bootstrapApplication(AppComponent, appConfig)
  .catch(err =&amp;gt; console.error(err));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And just like that — your Angular 19 standalone app is ready with routing, theming, Markdown rendering, Prism highlighting, and NgRx state management — all bootstrapped from a single file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best Practices &amp;amp; Recommendations&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoid SecurityContext.NONE unless Markdown is from a trusted source.&lt;/li&gt;
&lt;li&gt;Conditionally enable Store DevTools only in dev mode for smaller bundles.&lt;/li&gt;
&lt;li&gt;Lazy-load PrismJS if bundle size matters.&lt;/li&gt;
&lt;li&gt;Verify darkModeSelector — ensure it’s boolean or valid CSS selector per PrimeNG docs.&lt;/li&gt;
&lt;li&gt;Split providers logically (UI, State, Markdown) for easier maintenance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The app.config.ts in Angular 19 is the heart of your standalone app.&lt;br&gt;
It centralizes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routing (provideRouter)&lt;/li&gt;
&lt;li&gt;Animations (provideAnimationsAsync)&lt;/li&gt;
&lt;li&gt;PrimeNG theming (providePrimeNG)&lt;/li&gt;
&lt;li&gt;HTTP Client (provideHttpClient(withFetch))&lt;/li&gt;
&lt;li&gt;Markdown rendering (provideMarkdown)&lt;/li&gt;
&lt;li&gt;Syntax highlighting (PrismJS)&lt;/li&gt;
&lt;li&gt;State management (NgRx)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach is cleaner, faster, and easier to maintain — fully embracing the new Angular standalone paradigm.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With this setup, you’re not just configuring an app — you’re modernizing your Angular architecture for the standalone era.&lt;/p&gt;

&lt;p&gt;If you found this breakdown helpful, consider ❤️ reacting and bookmarking it on Dev.to — it helps others discover this guide too!&lt;/p&gt;

</description>
      <category>primeng</category>
      <category>webdev</category>
      <category>angular</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to download a file in Angular using document API</title>
      <dc:creator>Prateek Kr</dc:creator>
      <pubDate>Sun, 13 Oct 2024 15:08:39 +0000</pubDate>
      <link>https://dev.to/prateek_kr/how-to-download-a-file-in-angular-using-document-api-1j9j</link>
      <guid>https://dev.to/prateek_kr/how-to-download-a-file-in-angular-using-document-api-1j9j</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Downloading files is a common functionality in web applications, essential for exporting data, sharing documents, and more. In this guide, I’ll cover different techniques to download files in Angular, ensuring you have the flexibility to choose the best method for your specific needs.&lt;/p&gt;

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

&lt;p&gt;Before we dive in, ensure you have the following:&lt;/p&gt;

&lt;p&gt;Angular CLI installed&lt;/p&gt;

&lt;p&gt;A basic Angular project setup&lt;/p&gt;

&lt;p&gt;A server endpoint that provides the file&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Import HTTPClientModule
&lt;/h2&gt;

&lt;p&gt;First, ensure the HttpClientModule is imported in your AppModule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { HttpClientModule } from '@angular/common/http';

@NgModule({
  imports: [
    HttpClientModule,
    // other imports
  ],
})
export class AppModule {}

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create a Service for File Download
&lt;/h2&gt;

&lt;p&gt;Create a service to handle the file download:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root',
})
export class FileService {
  constructor(private http: HttpClient) {}

  downloadFile(url: string): Observable&amp;lt;Blob&amp;gt; {
    return this.http.get(url, { responseType: 'blob' });
  }
}

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Use the Service in a Component
&lt;/h2&gt;

&lt;p&gt;Use the service in your component to download the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Component } from '@angular/core';
import { FileService } from './file.service';

@Component({
  selector: 'app-file-download',
  template: `&amp;lt;button (click)="download()"&amp;gt;Download File&amp;lt;/button&amp;gt;`,
})
export class FileDownloadComponent {
  constructor(private fileService: FileService) {}

  download() {
    const url = 'https://example.com/file.pdf';
    this.fileService.downloadFile(url).subscribe((blob) =&amp;gt; {
      const a = document.createElement('a');
      const objectUrl = URL.createObjectURL(blob);
      a.href = objectUrl;
      a.download = 'file.pdf';
      a.click();
      URL.revokeObjectURL(objectUrl);
    });
  }
}

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

&lt;/div&gt;



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

&lt;p&gt;Downloading files in Angular can be accomplished using various methods, each with its own benefits. Whether you prefer using Angular’s built-in HttpClient or leveraging external libraries, understanding the techniques will empower you to handle file downloads effectively.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>download</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
