<?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 Joe Taylor on Medium]]></title>
        <description><![CDATA[Stories by Joe Taylor on Medium]]></description>
        <link>https://medium.com/@learningsomethingnew?source=rss-6c8f72bf7e04------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EPcdEyJPMRNR2LlzafGjhQ.jpeg</url>
            <title>Stories by Joe Taylor on Medium</title>
            <link>https://medium.com/@learningsomethingnew?source=rss-6c8f72bf7e04------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 07:42:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@learningsomethingnew/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[Part 4 Going Off Grid: Dynamic Traefik Configurations, Health Checks, and New Services]]></title>
            <link>https://medium.com/@learningsomethingnew/part-4-going-off-grid-dynamic-traefik-configurations-health-checks-and-new-services-4a929aab772b?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a929aab772b</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[self-hosted]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Mon, 14 Oct 2024 06:40:42 GMT</pubDate>
            <atom:updated>2024-10-14T06:40:42.897Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pI3SpDgD97VizOwg.png" /></figure><p>In my ongoing journey to optimize my Raspberry Pi homelab, I’ve implemented several significant changes that I believe are worth sharing.</p><p>Quick Recap of our previous chapters:</p><p>We first <a href="https://medium.com/@learningsomethingnew/going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-7ee2e0f61db3">set up our Pi Server</a>, we then <a href="https://medium.com/@learningsomethingnew/part-ii-going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-6f18410b6bb2">Installed Traefik and set up Cloudflare DNS</a> to access our apps off the local network, from there we <a href="https://medium.com/@learningsomethingnew/part-iii-going-off-grid-authentication-installing-authentik-in-our-homelab-d8960f8b8a79">set up Authentik</a> to protect our Pi Server… and then spent a chapter <a href="https://medium.com/@learningsomethingnew/part-3-2-going-off-grid-authentication-authentik-with-traefik-to-protect-other-services-3471bf4b50c3">integrating Traefik and Authentik</a>…. we even discussed <a href="https://medium.com/@learningsomethingnew/improving-security-of-hosted-content-b3fd94c7e4fd">SSH Hardening</a> and implementing some quick <a href="https://medium.com/@learningsomethingnew/quality-of-life-streamlining-docker-workflow-from-cli-commands-to-vs-code-and-lazydocker-0a6294c2f34d">Docker Container management tools</a>.</p><p>Now, in this post… I spend a little time revisiting our core setup.</p><p>I consulted our AI Advisors since our last post and the Dev Team and I agreed we should:</p><ol><li>Aabandon Trafik Service Labels and adopt Dynamic Configurations for Middlewares, Routers, and Servies.</li><li>Adopt Named Volumes instead of Bind Mounts</li><li>and Establish more robust Health Checks</li></ol><p>With that in place, we then go crazy and deploy all manner of open source tools!</p><p>I’ll also discuss the reasoning behind these changes, their advantages, and any potential drawbacks.</p><h3>Transition to Dynamic Traefik Configurations</h3><p>Previously, I managed Traefik’s routing, middleware, and service configurations directly within the docker-compose.yml file using labels. While this approach works, it can become cumbersome and less maintainable as the number of services grows. To address this, I&#39;ve transitioned to using dynamic configuration files located in the traefik/dynamic/ directory, specifically middlewares.yml, routers.yml, and services.yml.</p><p><strong>Pros:</strong></p><ul><li><strong>Improved Readability:</strong> Separating configurations into dedicated files makes it easier to navigate and manage each aspect of Traefik.</li><li><strong>Enhanced Maintainability:</strong> Changes to routes or middlewares can be made without altering the main docker-compose.yml, reducing the risk of introducing errors.</li><li><strong>Dynamic Reloading:</strong> Traefik can watch for changes in these files and reload configurations without requiring a full container restart.</li></ul><p><strong>Cons:</strong></p><ul><li><strong>Initial Setup Complexity:</strong> Setting up dynamic configuration files requires an initial investment of time to reorganize existing configurations.</li><li><strong>Learning Curve:</strong> For those new to Traefik, understanding the separation between static and dynamic configurations may add complexity.</li></ul><h3>Comparison with the Previous Approach</h3><p>In the past, all Traefik configurations were embedded as labels within each service in the docker-compose.yml file. While this made each service self-contained, it led to a bloated and less manageable compose file. The new approach promotes a cleaner separation of concerns, making the overall system more scalable.</p><p><strong>Previous Approach Example:</strong></p><p>Labels were utilized across each service:</p><pre>services:<br>  traefik:<br>    image: traefik:v3.1.4<br>    container_name: traefik<br>    restart: unless-stopped<br>    labels:<br>      - &quot;traefik.enable=true&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.rule=Host(traefik.joetaylor.me)&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.service=api@internal&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.tls.certresolver=cloudflare&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.middlewares=authentik-forward-auth@file&quot;<br>    # Additional configurations...</pre><p><strong>New Approach Example:</strong></p><p>Once we’ve redacted all the Traefik labels across each service within the docker-compose we need to establish the dynamic congifuration files. The purpose of the dynamic configuration files in Traefik — namely middlewares.yml, routers.yml, and services.yml—is to separate and organize the logic that governs how requests are processed, routed, and handled by different services. This separation allows for cleaner, more modular configurations, which enhances scalability and maintainability as the complexity of your homelab grows.</p><h3>middlewares.yml</h3><p>The middlewares.yml file defines Traefik middlewares, which act as filters or transformations applied to HTTP requests before they reach a service. Middlewares are useful for various tasks, such as enforcing HTTPS redirection, adding security headers, implementing authentication, or rate-limiting traffic.</p><p>For example, if you want all traffic to be securely redirected to HTTPS, you can configure a redirect middleware in middlewares.yml:</p><pre>http:<br>  middlewares:<br>    redirect-to-https:<br>      redirectScheme:<br>        scheme: https</pre><p>Another common use case is adding authentication to certain routes, such as enforcing authentication via an external service like Authentik:</p><pre>http:<br>  middlewares:<br>    authentik-forward-auth:<br>      forwardAuth:<br>        address: &quot;http://authentik_server:9000/outpost.goauthentik.io/auth/traefik&quot;<br>        trustForwardHeader: true<br>        authResponseHeaders:<br>          - X-authentik-username<br>          - X-authentik-email<br>          - X-authentik-name<br>          - X-authentik-groups</pre><h3>routers.yml</h3><p>The routers.yml file is responsible for defining how incoming requests are routed to the appropriate services. In Traefik, a router matches incoming requests to specific rules, which are based on parameters like the request’s host or path. Once a router matches a rule, it passes the request to the corresponding service.</p><p>For example, to route requests for https://dashy.joetaylor.me to the Dashy service, you would define the following in routers.yml:</p><pre>http:<br>  routers:<br>    dashy:<br>      rule: &quot;Host(`dashy.joetaylor.me`)&quot;<br>      entryPoints:<br>        - websecure<br>      tls:<br>        certResolver: cloudflare<br>      service: dashy-service<br>      middlewares:<br>        - authentik-forward-auth@file</pre><p>This router rule matches requests made to the dashy.joetaylor.me subdomain, ensures they use the websecure entry point (which listens on port 443 for HTTPS traffic), applies the Authentik authentication middleware, and forwards the requests to the dashy-service.</p><h3>services.yml</h3><p>The services.yml file defines the backend services that handle requests once they are routed. Each service in Traefik typically points to one or more servers (often Docker containers) where the actual application logic resides. Services are load-balanced and can be configured to point to multiple instances of an application for high availability.</p><p>Here’s an example of a service definition for Dashy:</p><pre>http:<br>  services:<br>    dashy-service:<br>      loadBalancer:<br>        servers:<br>          - url: &quot;http://dashy:8080&quot;</pre><p>In this case, the dashy-service service tells Traefik to forward all traffic to a server running on http://dashy:8080, which is the internal address of the Dashy container. Traefik handles the request routing and can add additional features like retry mechanisms or circuit breakers if necessary.</p><h3>Why Use Dynamic Files?</h3><p>By breaking out middlewares, routers, and services into separate dynamic configuration files, you achieve several key benefits:</p><ol><li><strong>Modularity</strong>: Each file focuses on a single responsibility, making configurations easier to understand and manage. As your homelab grows, the dynamic configuration system scales more effectively than embedding everything in a single docker-compose.yml.</li><li><strong>Reusability</strong>: You can reuse common middlewares or routers across different services. For instance, if you have a middleware that handles HTTPS redirection or authentication, it can be applied to multiple routers without needing to duplicate the configuration.</li><li><strong>Ease of Maintenance</strong>: If you need to update or add new services, you only need to modify the relevant services.yml or routers.yml file, without touching core Traefik settings or redeploying the entire stack.</li></ol><p>This structure promotes cleaner configurations, making it easier to manage and extend your homelab as more services are added.</p><p>Now, this can certainly be a matter of oppinion. In fact Sonnet 3.5 and o1-Preview each encouraged using labels over dynamic files at first but I was frustrated attempting to read long lines of labels and the more modular dynamic yml files made it much easier to understand what was going on. there was also the added benefit that as I made changes to teh dynamic files, Traefik was able to incorporate those changes without stoping and starting the container excessively.</p><p>For now, we’ll use the Dynamic Configuration and see how we like it long term…</p><h3>Restructuring Services with Named Volumes</h3><p>I’ve restructured the way services store their data by using named volumes in Docker. Instead of binding host directories to container paths, I’m now defining volumes within the docker-compose.yml file and referencing them in each service.</p><p><strong>Pros:</strong></p><ul><li><strong>Data Persistence:</strong> Named volumes ensure that data persists even if containers are removed or recreated.</li><li><strong>Isolation:</strong> Volumes are managed by Docker, providing better isolation between the host system and containers.</li><li><strong>Portability:</strong> The setup becomes more portable since the data management is abstracted away from the host filesystem paths.</li></ul><p><strong>Cons:</strong></p><ul><li><strong>Less Transparent Storage Location:</strong> By default, Docker stores volumes in a specific directory that’s not immediately visible, which might make manual data access slightly more complex.</li><li><strong>Potential Cleanup Required:</strong> Orphaned volumes can accumulate over time if not managed properly.</li></ul><h3>Advantages Over Previous Bind Mounts</h3><p>Previously, I used bind mounts, which directly map host directories to container paths. While this method provides straightforward access to files, it can lead to permission issues and less control over data management. Named volumes simplify these concerns and integrate more seamlessly with Docker’s ecosystem.</p><p>I was happy able to review the bind mount files on the host Pi but the our AI advisors strongly encourged migration to Bind Mounts so I decided to give this approach a shot and see how we like it…</p><p><strong>Bind Mount Example:</strong></p><pre>services:<br>  authentik:<br>    volumes:<br>      - ./authentik/media:/media<br>      - ./authentik/custom-templates:/templates</pre><p><strong>Named Volume Example:</strong></p><pre>services:<br>  authentik:<br>    volumes:<br>      - authentik_media:/media<br>      - authentik_templates:/templates<br><br>volumes:<br>  authentik_media:<br>    driver: local<br>  authentik_templates:<br>    driver: local</pre><h3>Introduction of Health Checks</h3><h3>Purpose of Health Checks</h3><p>Health checks are now incorporated into most of the services in the docker-compose.yml file. They allow Docker to monitor the health of a containerized service by periodically running a command or script to test its functionality.</p><p><strong>Benefits:</strong></p><ul><li><strong>Automatic Recovery:</strong> Docker can automatically restart unhealthy containers, increasing the resilience of the services.</li><li><strong>Load Balancing:</strong> For services behind a load balancer, health checks ensure traffic is only sent to healthy instances.</li><li><strong>Monitoring:</strong> Provides a built-in way to monitor the status of services without external tools.</li></ul><h3>Implementation Details</h3><p>Health checks are defined using the healthcheck parameter within each service, specifying the test command, intervals, timeouts, and retries. For example:</p><pre>services:<br>  traefik:<br>    # ... other configurations ...<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;traefik&quot;, &quot;healthcheck&quot;, &quot;--ping&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 3</pre><p><strong>Complete Health Check Example:</strong></p><pre>services:<br>  netdata:<br>    image: netdata/netdata:latest<br>    container_name: netdata<br>    restart: unless-stopped<br>    # ... other configurations ...<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;-f&quot;, &quot;http://localhost:19999&quot;]<br>      interval: 60s<br>      timeout: 10s<br>      retries: 3</pre><h3>Potential Drawbacks</h3><ul><li><strong>Resource Consumption:</strong> Health checks consume resources, which could be significant on a Raspberry Pi with limited capacity.</li><li><strong>Complexity:</strong> Misconfigured health checks might cause services to restart unnecessarily.</li></ul><h3>Addition of New Services</h3><p>In our previous chapters, I had not enabled many application services because I really wanted to get the structure down with a few containers and applications before I extended the approach across multiple containers.</p><p>With these final changes in place, I felt pretty good about extending this approach to deploy what I felt would be a great start to the homelab. And really begin to see how well we could adopt these alternative open source tools in luie of their paid SaaS counterparts…</p><p>The services can be categorized into two groups: infrastructure applications and productivity applications.</p><h3>Infrastructure Applications</h3><h4>Netdata</h4><p><strong>Description:</strong> Netdata is a real-time performance monitoring tool that provides comprehensive insights into system metrics such as CPU usage, memory consumption, disk activity, network traffic, and more. It offers interactive web dashboards that visualize these metrics, allowing for quick identification of issues and performance bottlenecks.</p><p>I was fairly eager to get this stood up so I could keep tabs on how much strain each additional app service would place on the Raspberry Pi…</p><ol><li><strong>Benefit:</strong> Offers insights into system metrics, aiding in optimization and troubleshooting.</li><li><strong>Alternatives:</strong> Consider alternatives like <strong>Prometheus</strong> with <strong>Grafana</strong> for custom metric collection and visualization, <strong>Zabbix</strong> for enterprise-grade monitoring, or <strong>Nagios</strong> for robust infrastructure monitoring.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>netdata:<br>    image: netdata/netdata:latest<br>    container_name: netdata<br>    restart: unless-stopped<br>    pid: host<br>    network_mode: host<br>    cap_add:<br>      - SYS_PTRACE<br>      - SYS_ADMIN<br>    security_opt:<br>      - apparmor:unconfined<br>    volumes:<br>      - netdataconfig:/etc/netdata<br>      - netdatalib:/var/lib/netdata<br>      - netdatacache:/var/cache/netdata<br>      - /:/host/root:ro,rslave<br>      - /etc/passwd:/host/etc/passwd:ro<br>      - /etc/group:/host/etc/group:ro<br>      - /etc/localtime:/etc/localtime:ro<br>      - /proc:/host/proc:ro<br>      - /sys:/host/sys:ro<br>      - /etc/os-release:/host/etc/os-release:ro<br>      - /var/log:/host/var/log:ro<br>      - /var/run/docker.sock:/var/run/docker.sock:ro<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;-f&quot;, &quot;http://localhost:19999&quot;]<br>      interval: 60s<br>      timeout: 10s<br>      retries: 3</pre><h4>Portainer</h4><p><strong>Description:</strong> Portainer is a lightweight management UI that allows you to easily manage your Docker environments. It provides a simple and intuitive interface for managing containers, images, networks, and volumes, simplifying tasks that would otherwise require command-line interaction.</p><p>I can’t emphasize enough how much help this tool has become now that we have a substantial amount of containrs deployed. In a previous post I highlighted how well Lazydocker was helping and I still use that as a light weight terminal dashboard, but Portainer really belw me away with its easy of use and amount of data and control you gain with the tool.</p><ol><li><strong>Benefit:</strong> Simplifies container management with a user-friendly interface.</li><li><strong>Alternatives:</strong> Alternatives include <strong>Rancher</strong> for managing Kubernetes clusters, <strong>Cockpit</strong> for server management, or using Docker’s native command-line tools for direct control.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>portainer:<br>    image: portainer/portainer-ce:2.21.3<br>    container_name: portainer<br>    restart: unless-stopped<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock<br>      - portainer_data:/data<br>    networks:<br>      - traefik_network</pre><h4>Uptime Kuma</h4><p><strong>Description:</strong> Uptime Kuma is a self-hosted monitoring tool that lets you track the uptime status of your websites and applications. It provides customizable dashboards and notifications via various channels, and can monitor services via HTTP(s), TCP, Ping, and more.</p><ol><li><strong>Benefit:</strong> Tracks the availability of services and sends alerts for downtime.</li><li><strong>Alternatives:</strong> Consider <strong>StatusCake</strong> for cloud-based monitoring, <strong>Upptime</strong> which uses GitHub pages and workflows, or <strong>Healthchecks.io</strong> for monitoring cron jobs and scheduled tasks.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>uptime-kuma:<br>    image: louislam/uptime-kuma:1<br>    container_name: uptime-kuma<br>    volumes:<br>      - uptime_kuma_data:/app/data<br>      - /var/run/docker.sock:/var/run/docker.sock<br>    ports:<br>      - &quot;3001:3001&quot;<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;-f&quot;, &quot;http://localhost:3001&quot;]<br>      interval: 60s<br>      timeout: 10s<br>      retries: 3<br>      start_period: 40s<br>    networks:<br>      - traefik_network</pre><h3>Productivity Applications</h3><h4>Fider</h4><p><strong>Description:</strong> Fider is an open-source platform for collecting and managing feedback from users. It allows you to gather ideas, feature requests, and bug reports, enabling a collaborative environment where users can vote and comment on suggestions.</p><ol><li><strong>Benefit:</strong> Enables structured feedback collection, useful for project development.</li><li><strong>Alternatives:</strong> Alternatives include <strong>UserVoice</strong> for customer feedback, <strong>Canny</strong> for product roadmap management, or <strong>Feedback Fish</strong> for lightweight feedback widgets.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>fider_db:<br>    image: postgres:12-alpine<br>    container_name: fider_db<br>    restart: unless-stopped<br>    environment:<br>      POSTGRES_USER: ${FIDER_DB_USER}<br>      POSTGRES_PASSWORD: ${FIDER_DB_PASSWORD}<br>      # POSTGRES_DB: ${FIDER_DB_NAME}<br>    volumes:<br>      - fider_pg_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -U ${FIDER_DB_USER} -d ${FIDER_DB_NAME}&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 5<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - fider_network<br><br>fider:<br>    image: getfider/fider:stable<br>    container_name: fider<br>    restart: unless-stopped<br>    environment:<br>      # Public Host Name<br>      BASE_URL: https://fider.joetaylor.me<br>      # Connection string to the PostgreSQL database<br>      DATABASE_URL: postgres://${FIDER_DB_USER}:${FIDER_DB_PASSWORD}@fider_db:5432/${FIDER_DB_NAME}?sslmode=disable<br>      # Generate a secure secret<br>      JWT_SECRET: ${FIDER_JWT_SECRET}<br>      # From which account e-mails will be sent<br>      EMAIL_NOREPLY: noreply@joetaylor.me<br>      # SMTP Configuration<br>      EMAIL_SMTP_HOST: ${FIDER_EMAIL_SMTP_HOST}<br>      EMAIL_SMTP_PORT: ${FIDER_EMAIL_SMTP_PORT}<br>      EMAIL_SMTP_USERNAME: ${FIDER_EMAIL_SMTP_USERNAME}<br>      EMAIL_SMTP_PASSWORD: ${FIDER_EMAIL_SMTP_PASSWORD}<br>      EMAIL_SMTP_ENABLE_STARTTLS: ${FIDER_EMAIL_SMTP_ENABLE_STARTTLS}<br>    volumes:<br>      - fider_uploads:/app/uploads<br>    depends_on:<br>      - fider_db<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;./fider ping&quot;]<br>      interval: 30s<br>      timeout: 5s<br>      retries: 3<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - fider_network</pre><h4>Dashy</h4><p><strong>Description:</strong> Dashy is a highly customizable home page for your homelab or web bookmarks. It allows you to create a dashboard with links to your most-used services, complete with icons, themes, and widgets, making navigation efficient.</p><ol><li><strong>Benefit:</strong> Provides a centralized place to access all services and tools.</li><li><strong>Alternatives:</strong> You might also consider <strong>Heimdall</strong>, which offers a similar feature set, <strong>Organizr</strong> for organizing services and web apps, or <strong>SUI</strong> (Startpage) for a minimalistic approach.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>dashy:<br>    image: lissy93/dashy<br>    container_name: dashy<br>    volumes:<br>      - dashy_conf:/app/public/conf.yml<br>    environment:<br>      - NODE_ENV=production<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;yarn&quot;, &quot;health-check&quot;]<br>      interval: 5m<br>      timeout: 5s<br>      retries: 3<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network</pre><h4>NocoDB</h4><ol><li><strong>Description:</strong> NocoDB is an open-source, no-code platform that turns your database into a smart spreadsheet. It allows you to interact with databases using a spreadsheet-like interface, enabling non-technical users to manage data effectively.</li><li><strong>Benefit:</strong> Transforms databases into smart spreadsheets, enhancing data interaction.</li><li><strong>Alternatives:</strong> Alternatives include <strong>Airtable</strong> for a cloud-based solution, <strong>Baserow</strong> as an open-source option, or <strong>Grist</strong> for relational data management.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>nocodb:<br>    image: nocodb/nocodb:0.255.2<br>    container_name: nocodb<br>    restart: unless-stopped<br>    volumes:<br>      - nocodb_data:/usr/app/data<br>    depends_on:<br>      - nocodb_db<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - nocodb_network<br><br>nocodb_db:<br>    image: postgres:13-alpine<br>    container_name: nocodb_db<br>    restart: unless-stopped<br>    environment:<br>      POSTGRES_USER: nocodb_user<br>      POSTGRES_PASSWORD: nocodb_pass<br>      POSTGRES_DB: nocodb_db<br>    volumes:<br>      - nocodb_pg_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -U nocodb_user -d nocodb_db&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 5<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - nocodb_network</pre><h4>Mattermost</h4><ol><li><strong>Description:</strong> Mattermost is an open-source messaging platform designed for team collaboration. It provides secure messaging, file sharing, and integrations with other tools, all hosted on your own server for complete control over your data.</li><li><strong>Benefit:</strong> Facilitates team communication and collaboration.</li><li><strong>Alternatives:</strong> Consider <strong>Slack</strong> for a popular hosted solution, <strong>Rocket.Chat</strong> for another open-source alternative, or <strong>Microsoft Teams</strong> if you’re integrated into the Microsoft ecosystem.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>mattermost_db:<br>    image: postgres:13-alpine<br>    container_name: mattermost_db<br>    restart: unless-stopped<br>    environment:<br>      POSTGRES_USER: ${MATTERMOST_DB_USER}<br>      POSTGRES_PASSWORD: ${MATTERMOST_DB_PASSWORD}<br>      POSTGRES_DB: ${MATTERMOST_DB_NAME}<br>    volumes:<br>      - mattermost_db_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&#39;CMD-SHELL&#39;, &#39;pg_isready -U ${MATTERMOST_DB_USER} -d ${MATTERMOST_DB_NAME}&#39;]<br>      interval: 10s<br>      timeout: 5s<br>      retries: 5<br>    env_file:<br>      - .env<br>    networks:<br>      - mattermost_network<br><br>mattermost:<br>    image: rheens/mattermost-app:v9.8.1<br>    container_name: mattermost<br>    depends_on:<br>      mattermost_db:<br>        condition: service_healthy<br>    restart: unless-stopped<br>    environment:<br>      MM_SERVICESETTINGS_LISTENADDRESS: &quot;:8065&quot;<br>      MM_SQLSETTINGS_DATASOURCE: postgres://${MATTERMOST_DB_USER}:${MATTERMOST_DB_PASSWORD}@mattermost_db:5432/${MATTERMOST_DB_NAME}?sslmode=disable&amp;connect_timeout=10<br>      MM_SQLSETTINGS_DRIVERNAME: postgres<br>      MM_ADMIN_USERNAME: ${MM_ADMIN_USERNAME}<br>      MM_ADMIN_PASSWORD: ${MM_ADMIN_PASSWORD}<br>      MM_ADMIN_EMAIL: ${MM_ADMIN_EMAIL}<br>      MM_SERVICESETTINGS_SITEURL: https://mattermost.joetaylor.me<br>    volumes:<br>      - mattermost_data:/mattermost/data<br>      - mattermost_config:/mattermost/config<br>      - mattermost_plugins:/mattermost/plugins<br>      - mattermost_client_plugins:/mattermost/client/plugins<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;-f&quot;, &quot;http://localhost:8065/api/v4/system/ping&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 3<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - mattermost_network</pre><p><strong>AFFiNE</strong></p><p><strong>Description:</strong> AFFiNE is an open-source collaborative workspace that combines note-taking, whiteboarding, and knowledge management. It supports real-time collaboration, making it ideal for team projects and brainstorming sessions.</p><ol><li><strong>Benefit:</strong> Combines knowledge base, whiteboard, and notes for enhanced productivity.</li><li><strong>Alternatives:</strong> Alternatives include <strong>Notion</strong> for an all-in-one workspace, <strong>Obsidian</strong> for a local-first note-taking app, or <strong>Evernote</strong> for comprehensive note management.</li><li><strong>Docker Compose Snippet:</strong></li></ol><pre>affine:<br>    image: ghcr.io/toeverything/affine-graphql:stable<br>    container_name: affine<br>    depends_on:<br>      affine_redis:<br>        condition: service_healthy<br>      affine_postgres:<br>        condition: service_healthy<br>    command:<br>      [&#39;sh&#39;, &#39;-c&#39;, &#39;node ./scripts/self-host-predeploy &amp;&amp; node ./dist/index.js&#39;]<br>    volumes:<br>      - affine_config:/root/.affine/config<br>      - affine_storage:/root/.affine/storage<br>    logging:<br>      driver: &#39;json-file&#39;<br>      options:<br>        max-size: &#39;1000m&#39;<br>    restart: unless-stopped<br>    environment:<br>      - NODE_OPTIONS=&quot;--import=./scripts/register.js&quot;<br>      - AFFINE_CONFIG_PATH=/root/.affine/config<br>      - REDIS_SERVER_HOST=affine_redis<br>      - DATABASE_URL=postgres://affine:affine@affine_postgres:5432/affine<br>      - NODE_ENV=production<br>      - AFFINE_SERVER_EXTERNAL_URL=https://affine.joetaylor.me<br>      - AFFINE_SERVER_PORT=3010<br>      - MAILER_HOST=smtp.resend.com<br>      - MAILER_PORT=587<br>      - MAILER_USER=resend<br>      - MAILER_PASSWORD=${AFFINE_MAILER_PASSWORD}<br>      - MAILER_SENDER=noreply@joetaylor.me<br>      # Telemetry allows us to collect data on how you use the affine. This data will helps us improve the app and provide better features.<br>      # Uncomment next line if you wish to quit telemetry.<br>      # - TELEMETRY_ENABLE=false<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - affine_network<br><br>affine_redis:<br>    image: redis<br>    container_name: affine_redis<br>    restart: unless-stopped<br>    volumes:<br>      - affine_redis_data:/data<br>    healthcheck:<br>      test: [&#39;CMD&#39;, &#39;redis-cli&#39;, &#39;--raw&#39;, &#39;PING&#39;]<br>      interval: 10s<br>      timeout: 5s<br>      retries: 5<br>    env_file:<br>      - .env<br>    networks:<br>      - affine_network<br>  affine_postgres:<br>    image: postgres:16<br>    container_name: affine_postgres<br>    restart: unless-stopped<br>    volumes:<br>      - affine_postgres_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&#39;CMD-SHELL&#39;, &#39;pg_isready -U affine&#39;]<br>      interval: 10s<br>      timeout: 5s<br>      retries: 5<br>    environment:<br>      POSTGRES_USER: affine<br>      POSTGRES_PASSWORD: ${AFFINE_DB_PASSWORD}<br>      POSTGRES_DB: affine<br>      PGDATA: /var/lib/postgresql/data/pgdata<br>    env_file:<br>      - .env<br>    networks:<br>      - affine_network</pre><h3>Future Plans</h3><p>The following applications are planned for future integration:</p><p><strong>Vaultwarden:</strong> A self-hosted password manager compatible with Bitwarden clients.</p><ul><li><strong>Description:</strong> Vaultwarden provides a secure way to store and manage passwords, offering compatibility with Bitwarden clients. It ensures your sensitive data remains under your control without relying on third-party services.</li><li><strong>Alternatives:</strong> <strong>Bitwarden</strong> for a hosted solution, <strong>KeePass</strong> for a local database, or <strong>LastPass</strong> for a cloud-based option.</li></ul><p><strong>Nextcloud:</strong> An open-source personal cloud solution for file storage and collaboration.</p><ul><li><strong>Description:</strong> Nextcloud allows you to create your own cloud storage service, offering file synchronization, sharing, and collaboration tools similar to commercial services like Dropbox or Google Drive.</li><li><strong>Alternatives:</strong> <strong>OwnCloud</strong> as another self-hosted option, <strong>Seafile</strong> for high-performance file syncing, or <strong>Dropbox</strong> for a hosted service.</li></ul><p><strong>Ghost:</strong> An open-source headless CMS for blogging and content creation.</p><ul><li><strong>Description:</strong> Ghost is a modern publishing platform that allows you to create and manage content efficiently. It’s optimized for speed and simplicity, making it ideal for bloggers and content creators.</li><li><strong>Alternatives:</strong> <strong>WordPress</strong> for a full-featured CMS, <strong>Jekyll</strong> for static site generation, or <strong>Hugo</strong> for fast static websites.</li></ul><p><strong>Supabase:</strong> An open-source Firebase alternative offering database, authentication, and storage.</p><ul><li><strong>Description:</strong> Supabase provides a suite of backend services, including a PostgreSQL database, authentication, and storage solutions, enabling rapid development of applications without managing infrastructure.</li><li><strong>Alternatives:</strong> <strong>Firebase</strong> for a hosted backend, <strong>Parse</strong> for open-source backend as a service, or <strong>Amplify</strong> by AWS.</li></ul><p><strong>Pi-hole:</strong> A network-wide ad blocker acting as a DNS sinkhole.</p><ul><li><strong>Description:</strong> Pi-hole filters unwanted content at the DNS level, effectively blocking ads, trackers, and malicious domains across all devices on your network.</li><li><strong>Alternatives:</strong> <strong>AdGuard Home</strong> for similar functionality, <strong>uBlock Origin</strong> for browser-level blocking, or <strong>NextDNS</strong> for cloud-based filtering.</li></ul><p><strong>Excalidraw:</strong> A virtual whiteboard for sketching and collaboration.</p><ul><li><strong>Description:</strong> Excalidraw offers a simple and intuitive interface for creating sketches, diagrams, and collaborative drawings, making it perfect for brainstorming sessions and visual planning.</li><li><strong>Alternatives:</strong> <strong>Miro</strong> for an online collaborative whiteboard, <strong>Draw.io</strong> for diagramming, or <strong>Microsoft Whiteboard</strong> for integrated solutions.</li></ul><p>These applications will be added to the Docker Compose setup in future updates.</p><h3>Benefits of the New Services</h3><h4>Enhanced Monitoring and Management</h4><ul><li><strong>Netdata</strong> and <strong>Portainer</strong> provide comprehensive monitoring and simplified management of the Docker environment, which is crucial for maintaining a healthy homelab.</li></ul><h4>Improved Productivity and Collaboration</h4><ul><li><strong>Mattermost</strong> and <strong>AFFiNE</strong> offer platforms for communication and collaborative work, essential for team projects or personal organization.</li></ul><h4>Centralized Access and Control</h4><ul><li><strong>Dashy</strong> serves as a centralized dashboard, making it easier to access and manage all services from one place.</li></ul><h4>Feedback and Development</h4><ul><li><strong>Fider</strong> allows for efficient feedback collection, instrumental in iterative development processes.</li></ul><h3>Conclusion</h3><p>The recent upgrades to my Raspberry Pi homelab have significantly improved its functionality, maintainability, and scalability. By transitioning to dynamic Traefik configurations, restructuring service setups with named volumes, and introducing health checks, the system is now more robust and easier to manage. The addition of new services not only enhances infrastructure monitoring and management but also boosts productivity and collaboration capabilities.</p><p><strong>Your Thoughts</strong></p><p>I’m eager to hear your thoughts on these changes. Have you implemented similar upgrades in your homelab? Share your experiences in the comments below!</p><p><strong>Stay Tuned</strong></p><p>Keep an eye out for future updates where I’ll delve into the integration of the planned applications and share more insights into optimizing a Raspberry Pi homelab.</p><h3>Full docker-compose.yml Example</h3><p>For those interested in the complete setup, here’s an excerpt of the updated docker-compose.yml showcasing the integration of dynamic Traefik configurations, named volumes, and health checks:</p><pre>services:<br>  traefik:<br>    image: traefik:v3.1.4<br>    container_name: traefik<br>    restart: unless-stopped<br>    command:<br>      - &quot;--api.insecure=false&quot;<br>      - &quot;--providers.docker=true&quot;<br>      - &quot;--providers.file.directory=/traefik/dynamic&quot;<br>      - &quot;--providers.file.watch=true&quot;<br>      - &quot;--entrypoints.web.address=:80&quot;<br>      - &quot;--entrypoints.websecure.address=:443&quot;<br>      - &quot;--entrypoints.traefik.address=:8080&quot;<br>      - &quot;--ping=true&quot;<br>      - &quot;--ping.entrypoint=traefik&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge=true&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge.provider=cloudflare&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.email=${CLOUDFLARE_API_EMAIL}&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.storage=/traefik/letsencrypt/acme.json&quot;<br>    ports:<br>      - &quot;80:80&quot;<br>      - &quot;443:443&quot;<br>    volumes:<br>      - &quot;/var/run/docker.sock:/var/run/docker.sock:ro&quot;<br>      - ./traefik/letsencrypt:/traefik/letsencrypt<br>      - ./traefik/dynamic:/traefik/dynamic:ro<br>    environment:<br>      - CLOUDFLARE_API_EMAIL=${CLOUDFLARE_API_EMAIL}<br>      - CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN}<br>    extra_hosts:<br>      - &quot;host.docker.internal:host-gateway&quot;  # Maps host.docker.internal to the host&#39;s gateway<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;traefik&quot;, &quot;healthcheck&quot;, &quot;--ping&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 3<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br><br>  # **Netdata Service Addition**<br>  netdata:<br>    image: netdata/netdata:latest<br>    container_name: netdata<br>    restart: unless-stopped<br>    pid: host<br>    network_mode: host<br>    cap_add:<br>      - SYS_PTRACE<br>      - SYS_ADMIN<br>    security_opt:<br>      - apparmor:unconfined<br>    volumes:<br>      - netdataconfig:/etc/netdata<br>      - netdatalib:/var/lib/netdata<br>      - netdatacache:/var/cache/netdata<br>      - /:/host/root:ro,rslave<br>      - /etc/passwd:/host/etc/passwd:ro<br>      - /etc/group:/host/etc/group:ro<br>      - /etc/localtime:/etc/localtime:ro<br>      - /proc:/host/proc:ro<br>      - /sys:/host/sys:ro<br>      - /etc/os-release:/host/etc/os-release:ro<br>      - /var/log:/host/var/log:ro<br>      - /var/run/docker.sock:/var/run/docker.sock:ro<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;-f&quot;, &quot;http://localhost:19999&quot;]<br>      interval: 60s<br>      timeout: 10s<br>      retries: 3<br><br>  portainer:<br>    image: portainer/portainer-ce:2.21.3<br>    container_name: portainer<br>    restart: unless-stopped<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock<br>      - portainer_data:/data<br>    networks:<br>      - traefik_network<br><br>  noop:<br>    image: nginx:alpine<br>    container_name: noop<br>    restart: unless-stopped<br>    labels:<br>      - &quot;traefik.enable=false&quot;<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;wget&quot;, &quot;-qO-&quot;, &quot;http://localhost&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 3<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br><br>  uptime-kuma:<br>    image: louislam/uptime-kuma:1<br>    container_name: uptime-kuma<br>    volumes:<br>      - uptime_kuma_data:/app/data<br>      - /var/run/docker.sock:/var/run/docker.sock<br>    ports:<br>      - &quot;3001:3001&quot;<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;-f&quot;, &quot;http://localhost:3001&quot;]<br>      interval: 60s<br>      timeout: 10s<br>      retries: 3<br>      start_period: 40s<br>    networks:<br>      - traefik_network<br><br>  n8n:<br>    image: docker.n8n.io/n8nio/n8n<br>    container_name: n8n<br>    restart: unless-stopped<br>    volumes:<br>      - n8n_data:/home/node/.n8n<br>    environment:<br>      - N8N_HOST=n8n.joetaylor.me<br>      - N8N_PORT=5678<br>      - N8N_PROTOCOL=https<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;nc -z localhost 5678&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 5<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br><br>  fider_db:<br>    image: postgres:12-alpine<br>    container_name: fider_db<br>    restart: unless-stopped<br>    environment:<br>      POSTGRES_USER: ${FIDER_DB_USER}<br>      POSTGRES_PASSWORD: ${FIDER_DB_PASSWORD}<br>      # POSTGRES_DB: ${FIDER_DB_NAME}<br>    volumes:<br>      - fider_pg_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -U ${FIDER_DB_USER} -d ${FIDER_DB_NAME}&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 5<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - fider_network<br><br>  fider:<br>    image: getfider/fider:stable<br>    container_name: fider<br>    restart: unless-stopped<br>    environment:<br>      # Public Host Name<br>      BASE_URL: https://fider.joetaylor.me<br>      # Connection string to the PostgreSQL database<br>      DATABASE_URL: postgres://${FIDER_DB_USER}:${FIDER_DB_PASSWORD}@fider_db:5432/${FIDER_DB_NAME}?sslmode=disable<br>      # Generate a secure secret<br>      JWT_SECRET: ${FIDER_JWT_SECRET}<br>      # From which account e-mails will be sent<br>      EMAIL_NOREPLY: noreply@joetaylor.me<br>      # SMTP Configuration<br>      EMAIL_SMTP_HOST: ${FIDER_EMAIL_SMTP_HOST}<br>      EMAIL_SMTP_PORT: ${FIDER_EMAIL_SMTP_PORT}<br>      EMAIL_SMTP_USERNAME: ${FIDER_EMAIL_SMTP_USERNAME}<br>      EMAIL_SMTP_PASSWORD: ${FIDER_EMAIL_SMTP_PASSWORD}<br>      EMAIL_SMTP_ENABLE_STARTTLS: ${FIDER_EMAIL_SMTP_ENABLE_STARTTLS}<br>    volumes:<br>      - fider_uploads:/app/uploads<br>    depends_on:<br>      - fider_db<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;./fider ping&quot;]<br>      interval: 30s<br>      timeout: 5s<br>      retries: 3<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - fider_network<br><br>  dashy:<br>    image: lissy93/dashy<br>    container_name: dashy<br>    volumes:<br>      - dashy_conf:/app/public/conf.yml<br>    environment:<br>      - NODE_ENV=production<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;yarn&quot;, &quot;health-check&quot;]<br>      interval: 5m<br>      timeout: 5s<br>      retries: 3<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br><br>  nocodb:<br>    image: nocodb/nocodb:0.255.2<br>    container_name: nocodb<br>    restart: unless-stopped<br>    volumes:<br>      - nocodb_data:/usr/app/data<br>    depends_on:<br>      - nocodb_db<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - nocodb_network<br><br>  nocodb_db:<br>    image: postgres:13-alpine<br>    container_name: nocodb_db<br>    restart: unless-stopped<br>    environment:<br>      POSTGRES_USER: nocodb_user<br>      POSTGRES_PASSWORD: nocodb_pass<br>      POSTGRES_DB: nocodb_db<br>    volumes:<br>      - nocodb_pg_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -U nocodb_user -d nocodb_db&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 5<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - nocodb_network<br><br>  mattermost_db:<br>    image: postgres:13-alpine<br>    container_name: mattermost_db<br>    restart: unless-stopped<br>    environment:<br>      POSTGRES_USER: ${MATTERMOST_DB_USER}<br>      POSTGRES_PASSWORD: ${MATTERMOST_DB_PASSWORD}<br>      POSTGRES_DB: ${MATTERMOST_DB_NAME}<br>    volumes:<br>      - mattermost_db_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&#39;CMD-SHELL&#39;, &#39;pg_isready -U ${MATTERMOST_DB_USER} -d ${MATTERMOST_DB_NAME}&#39;]<br>      interval: 10s<br>      timeout: 5s<br>      retries: 5<br>    env_file:<br>      - .env<br>    networks:<br>      - mattermost_network<br><br>  mattermost:<br>    image: rheens/mattermost-app:v9.8.1<br>    container_name: mattermost<br>    depends_on:<br>      mattermost_db:<br>        condition: service_healthy<br>    restart: unless-stopped<br>    environment:<br>      MM_SERVICESETTINGS_LISTENADDRESS: &quot;:8065&quot;<br>      MM_SQLSETTINGS_DATASOURCE: postgres://${MATTERMOST_DB_USER}:${MATTERMOST_DB_PASSWORD}@mattermost_db:5432/${MATTERMOST_DB_NAME}?sslmode=disable&amp;connect_timeout=10<br>      MM_SQLSETTINGS_DRIVERNAME: postgres<br>      MM_ADMIN_USERNAME: ${MM_ADMIN_USERNAME}<br>      MM_ADMIN_PASSWORD: ${MM_ADMIN_PASSWORD}<br>      MM_ADMIN_EMAIL: ${MM_ADMIN_EMAIL}<br>      MM_SERVICESETTINGS_SITEURL: https://mattermost.joetaylor.me<br>    volumes:<br>      - mattermost_data:/mattermost/data<br>      - mattermost_config:/mattermost/config<br>      - mattermost_plugins:/mattermost/plugins<br>      - mattermost_client_plugins:/mattermost/client/plugins<br>    healthcheck:<br>      test: [&quot;CMD&quot;, &quot;curl&quot;, &quot;-f&quot;, &quot;http://localhost:8065/api/v4/system/ping&quot;]<br>      interval: 30s<br>      timeout: 10s<br>      retries: 3<br>      start_period: 30s<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - mattermost_network<br><br>  affine:<br>    image: ghcr.io/toeverything/affine-graphql:stable<br>    container_name: affine<br>    depends_on:<br>      affine_redis:<br>        condition: service_healthy<br>      affine_postgres:<br>        condition: service_healthy<br>    command:<br>      [&#39;sh&#39;, &#39;-c&#39;, &#39;node ./scripts/self-host-predeploy &amp;&amp; node ./dist/index.js&#39;]<br>    volumes:<br>      - affine_config:/root/.affine/config<br>      - affine_storage:/root/.affine/storage<br>    logging:<br>      driver: &#39;json-file&#39;<br>      options:<br>        max-size: &#39;1000m&#39;<br>    restart: unless-stopped<br>    environment:<br>      - NODE_OPTIONS=&quot;--import=./scripts/register.js&quot;<br>      - AFFINE_CONFIG_PATH=/root/.affine/config<br>      - REDIS_SERVER_HOST=affine_redis<br>      - DATABASE_URL=postgres://affine:affine@affine_postgres:5432/affine<br>      - NODE_ENV=production<br>      - AFFINE_SERVER_EXTERNAL_URL=https://affine.joetaylor.me<br>      - AFFINE_SERVER_PORT=3010<br>      - MAILER_HOST=smtp.resend.com<br>      - MAILER_PORT=587<br>      - MAILER_USER=resend<br>      - MAILER_PASSWORD=${AFFINE_MAILER_PASSWORD}<br>      - MAILER_SENDER=noreply@joetaylor.me<br>      # Telemetry allows us to collect data on how you use the affine. This data will helps us improve the app and provide better features.<br>      # Uncomment next line if you wish to quit telemetry.<br>      # - TELEMETRY_ENABLE=false<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br>      - affine_network<br><br>  affine_redis:<br>    image: redis<br>    container_name: affine_redis<br>    restart: unless-stopped<br>    volumes:<br>      - affine_redis_data:/data<br>    healthcheck:<br>      test: [&#39;CMD&#39;, &#39;redis-cli&#39;, &#39;--raw&#39;, &#39;PING&#39;]<br>      interval: 10s<br>      timeout: 5s<br>      retries: 5<br>    env_file:<br>      - .env<br>    networks:<br>      - affine_network<br><br>  affine_postgres:<br>    image: postgres:16<br>    container_name: affine_postgres<br>    restart: unless-stopped<br>    volumes:<br>      - affine_postgres_data:/var/lib/postgresql/data<br>    healthcheck:<br>      test: [&#39;CMD-SHELL&#39;, &#39;pg_isready -U affine&#39;]<br>      interval: 10s<br>      timeout: 5s<br>      retries: 5<br>    environment:<br>      POSTGRES_USER: affine<br>      POSTGRES_PASSWORD: ${AFFINE_DB_PASSWORD}<br>      POSTGRES_DB: affine<br>      PGDATA: /var/lib/postgresql/data/pgdata<br>    env_file:<br>      - .env<br>    networks:<br>      - affine_network<br><br>  # Authentik Services<br>  postgresql:<br>    image: postgres:16-alpine<br>    container_name: authentik_postgresql<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -d ${PG_DB:-authentik} -U ${PG_USER:-authentik}&quot;]<br>      start_period: 20s<br>      interval: 30s<br>      retries: 5<br>      timeout: 5s<br>    environment:<br>      POSTGRES_PASSWORD: ${PG_PASS}<br>      POSTGRES_USER: ${PG_USER:-authentik}<br>      POSTGRES_DB: ${PG_DB:-authentik}<br>    volumes:<br>      - database:/var/lib/postgresql/data<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br><br>  redis:<br>    image: redis:alpine<br>    container_name: authentik_redis<br>    command: --save 60 1 --loglevel warning<br>    restart: unless-stopped<br>    volumes:<br>      - redis:/data<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;redis-cli ping | grep PONG&quot;]<br>      start_period: 20s<br>      interval: 30s<br>      retries: 5<br>      timeout: 3s<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br><br>  authentik_server:<br>    image: ghcr.io/goauthentik/server:2024.8.3<br>    container_name: authentik_server<br>    restart: unless-stopped<br>    command: server<br>    environment:<br>      AUTHENTIK_REDIS__HOST: redis<br>      AUTHENTIK_POSTGRESQL__HOST: postgresql<br>      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}<br>      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}<br>      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}<br>      AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}<br>      AUTHENTIK_ERROR_REPORTING__ENABLED: ${AUTHENTIK_ERROR_REPORTING__ENABLED}<br>    volumes:<br>      - authentik_media:/media<br>      - authentik_templates:/templates<br>    env_file:<br>      - .env<br>    depends_on:<br>      - postgresql<br>      - redis<br>    networks:<br>      - traefik_network<br><br>  authentik_worker:<br>    image: ghcr.io/goauthentik/server:2024.8.3<br>    container_name: authentik_worker<br>    restart: unless-stopped<br>    command: worker<br>    user: root<br>    environment:<br>      AUTHENTIK_REDIS__HOST: redis<br>      AUTHENTIK_POSTGRESQL__HOST: postgresql<br>      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}<br>      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}<br>      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}<br>      AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock<br>      - authentik_media:/media<br>      - authentik_certs:/certs<br>      - authentik_templates:/templates<br>    env_file:<br>      - .env<br>    depends_on:<br>      - postgresql<br>      - redis<br>    networks:<br>      - traefik_network<br><br>volumes:<br>  traefik_letsencrypt:<br>    driver: local<br>  traefik_dynamic:<br>    driver: local<br>  netdataconfig:<br>    driver: local<br>  netdatalib:<br>    driver: local<br>  netdatacache:<br>    driver: local<br>  portainer_data:<br>    driver: local<br>  uptime_kuma_data:<br>    driver: local<br>  n8n_data:<br>    driver: local<br>  fider_pg_data:<br>    driver: local<br>  fider_uploads:<br>    driver: local<br>  dashy_conf:<br>    driver: local<br>  nocodb_data:<br>    driver: local<br>  nocodb_pg_data:<br>    driver: local<br>  mattermost_db_data:<br>    driver: local<br>  mattermost_data:<br>    driver: local<br>  mattermost_config:<br>    driver: local<br>  mattermost_plugins:<br>    driver: local<br>  mattermost_client_plugins:<br>    driver: local<br>  affine_config:<br>    driver: local<br>  affine_storage:<br>    driver: local<br>  affine_redis_data:<br>    driver: local<br>  affine_postgres_data:<br>    driver: local<br>  authentik_media:<br>    driver: local<br>  authentik_templates:<br>    driver: local<br>  authentik_certs:<br>    driver: local<br>  database:<br>    driver: local<br>  redis:<br>    driver: local<br><br>networks:<br>  traefik_network:<br>    external: true<br>  fider_network:<br>    driver: bridge<br>  nocodb_network:<br>    driver: bridge<br>  mattermost_network:<br>    driver: bridge<br>  affine_network:<br>    driver: bridge</pre><p>This setup ensures that all services are well-organized, easily maintainable, and scalable as your homelab grows.</p><p>Feel free to reach out if you have any questions or need further assistance with setting up your Raspberry Pi homelab!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a929aab772b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 3.2 Going Off Grid: Authentication —Authentik with Traefik to Protect other Services]]></title>
            <link>https://medium.com/@learningsomethingnew/part-3-2-going-off-grid-authentication-authentik-with-traefik-to-protect-other-services-3471bf4b50c3?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/3471bf4b50c3</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Fri, 04 Oct 2024 02:42:56 GMT</pubDate>
            <atom:updated>2024-10-04T02:42:56.830Z</atom:updated>
            <content:encoded><![CDATA[<p>In our previous post we installed Authentik with the goal of leveraging the authentication capabilities to consolidate access for services running on our Raspberry Pi.</p><p>Now lets finish this initial implementation and integrate Authentik with Traefik to protect our services.</p><h3>Our Target State</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nXUtaNgX9XQEBPH0kxNC_Q.png" /></figure><ol><li>The user requests a service (e.g., home.joetaylor.me).</li><li>Cloudflare forwards this request to Traefik.</li><li>Traefik checks with Authentik if the user is authenticated.</li><li>If not authenticated:</li></ol><ul><li>Traefik redirects the user to Authentik’s login page.</li><li>The user logs in at authentik.joetaylor.me.</li><li>Authentik redirects the user back to the original URL.</li><li>The process starts again, but this time with valid authentication.</li></ul><p>5. If authenticated (or after successful login):</p><ul><li>Authentik confirms authentication to Traefik.</li><li>Traefik allows access to the requested service.</li><li>The service serves the requested content to the user.</li></ul><p>This flow demonstrates how Traefik acts as the initial point of contact within your network, working with Authentik to ensure users are authenticated before accessing any services.</p><h3>Configure Traefik to Use Authentik</h3><p>We’ll configure Traefik to use Authentik as a forward authentication provider.</p><p><strong>A. Modify </strong><strong>traefik.yml</strong></p><p>Add the file provider to allow dynamic configuration:</p><pre>providers:<br>  docker:<br>    endpoint: &quot;unix:///var/run/docker.sock&quot;<br>    exposedByDefault: false<br>  file:<br>    directory: &quot;/etc/traefik/dynamic&quot;<br>    watch: true</pre><p><strong>B. Create Dynamic Configuration</strong></p><p>Create a directory for dynamic configurations:</p><pre><br>mkdir ./traefik/dynamic</pre><p>Create a file authentik.yml in ./traefik/dynamic/ with the following content:</p><pre>http:<br>  middlewares:<br>    authentik-auth:<br>      forwardAuth:<br>        address: &quot;http://authentik_server:9000/outpost.goauthentik.io/auth/traefik&quot;<br>        trustForwardHeader: true<br>        authResponseHeaders:<br>          - X-authentik-username<br>          - X-authentik-email<br>          - X-authentik-name<br>          - X-authentik-groups</pre><p><strong>C. Update Traefik Service in </strong><strong>docker-compose.yml</strong></p><p>Include the dynamic configuration directory:</p><pre>services:<br>  traefik:<br>    # ... existing configuration ...<br>    volumes:<br>      - &quot;/var/run/docker.sock:/var/run/docker.sock:ro&quot;<br>      - &quot;./traefik/letsencrypt:/letsencrypt&quot;<br>      - &quot;./traefik/traefik.yml:/traefik.yml:ro&quot;<br>      - &quot;./traefik/dynamic:/etc/traefik/dynamic:ro&quot;  # Add this line</pre><h3>3. Set Up Authentik</h3><p><strong>Create Provider and Application</strong></p><p><strong>1. Create a Provider</strong></p><ul><li>Navigate to Applications &gt; Providers &gt; Create.</li><li>Choose Proxy Provider.</li><li>Configure:</li><li><strong>Name:</strong> Traefik Forward Auth Provider</li><li><strong>Type:</strong> Forward Auth (Single Application)</li><li><strong>External Host:</strong> https://yourdomain.com (replace with your domain)</li><li><strong>Authentication Flow:</strong> Default or as per your needs</li><li><strong>Authorization Flow:</strong> default-provider-authorization-implicit-consent</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pIYcniElmo9qXkIoLKhnpw.png" /></figure><p><strong>2. Create an Application</strong></p><ul><li>Go to Applications &gt; Applications &gt; Create.</li><li>Configure:</li><li><strong>Name:</strong> Traefik Forward Auth Application</li><li><strong>Slug:</strong> traefik-forward-auth</li><li><strong>Provider:</strong> Select the provider created earlier</li><li><strong>Launch URL:</strong> Leave blank</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31aOQhdgE1Hcw-ELcrckSw.png" /></figure><p><strong>C. Configure Embedded Outpost</strong></p><ul><li>Go to Outposts &gt; Embedded Outpost.</li><li>Edit and add your application to Selected Applications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I31V-lMvuQWPQQPw6icsww.png" /></figure><h3>4. Modify Existing Service Configurations</h3><p><strong>Update your services</strong> to use the Authentik middleware in Traefik.</p><p><strong>A. Update Service Labels</strong></p><p>For each service, add the middleware label. Example for n8n:</p><pre>services:<br>  n8n:<br>    # ... existing configuration ...<br>    labels:<br>      - &quot;traefik.enable=true&quot;<br>      - &quot;traefik.http.routers.n8n.rule=Host(`n8n.yourdomain.com`)&quot;<br>      - &quot;traefik.http.routers.n8n.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.n8n.tls.certresolver=cloudflare&quot;<br>      - &quot;traefik.http.services.n8n.loadbalancer.server.port=5678&quot;<br>      - &quot;traefik.http.routers.n8n.middlewares=authentik-auth@file&quot;  # Add this line</pre><p>Repeat for other services like welcome-home.</p><p><strong>A. Restart Services</strong></p><pre>docker-compose down<br>docker-compose up -d</pre><p><strong>B. Access Services</strong></p><ul><li>Go to <a href="https://n8n.yourdomain.com./">https://n8n.joetaylor.me</a></li><li>You should be redirected to Authentik’s login page.</li><li>After logging in, you should be redirected back to n8n.</li></ul><p>Congrats! We now have Authentication enabled across our apps via Authentik!</p><h3>Is there Another Option To Consider?</h3><p>So, this is great but is there another option? We had selected Single Application, what about Domain Level?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q65MkCoJjapqkg8_TG9XlA.png" /></figure><h3>Recap and Challenges</h3><p><strong>DNS Record Proliferation</strong>: Each Docker service has a specific Cloudflare DNS record:</p><ul><li>home.joetaylor.me</li><li>n8n.joetaylor.me</li><li>traefik.joetaylor.me</li><li>authentik.joetaylor.me</li></ul><p>This can become cumbersome as we anticipate adding more tools and services, necessitating frequent updates to Cloudflare DNS records.</p><p><strong>Multiple Authentication Points</strong>: The app-level approach in Authentik demanded creating an Application in admin mode for each service, and will require users (me) to authenticate separately for each app.</p><h3>Exploring Alternatives</h3><p>To address these challenges, we’re considering two key changes:</p><ol><li>Implementing a wildcard domain in Cloudflare: *.joetaylor.me</li><li>Shifting to Domain Level authentication</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NJxXjLXEaBVWf9aRKejqhA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvpyGKzqDg6I55ROoHVEJg.png" /></figure><h3>Configure Cloudflare with a Wildcard DNS Record</h3><p>First, we’ll set up a wildcard DNS record in Cloudflare to point all subdomains of joetaylor.me to your public IP.</p><h4>Steps:</h4><ol><li><strong>Log in to Cloudflare Dashboard</strong></li></ol><ul><li>Go to Cloudflare Dashboard and select your domain joetaylor.me.</li></ul><p><strong>2. Add a Wildcard DNS A Record</strong></p><ul><li>Navigate to the <strong>DNS</strong> section.</li><li>Add a new <strong>A Record</strong>:</li><li><strong>Name:</strong> *</li><li><strong>IPv4 address:</strong> Your public IP address</li><li><strong>TTL:</strong> Auto</li><li><strong>Proxy status:</strong> DNS Only (Recommended for wildcard records)</li></ul><p><strong>3. Ensure Proper DNS Resolution</strong></p><ul><li>Verify that subdomains like n8n.joetaylor.me, home.joetaylor.me, and traefik.joetaylor.me resolve to your public IP.</li><li>You can use nslookup or dig to confirm:</li></ul><pre>nslookup n8n.joetaylor.me</pre><h3>Authentik Adjustments</h3><p>Fortunately Authentik makes this process pretty simple. We can update our Traefik Service in our Docker Compose to :</p><pre>services:<br>  traefik:<br>    image: traefik:v3.1.4<br>    container_name: traefik<br>    restart: unless-stopped<br>    labels:<br>      - &quot;traefik.enable=true&quot;<br>      # Dashboard<br>      - &quot;traefik.http.routers.traefik-dashboard.rule=Host(`traefik.joetaylor.me`)&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.service=api@internal&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.tls.certresolver=cloudflare&quot;<br>      - &quot;traefik.http.routers.traefik-dashboard.middlewares=authentik-forward-auth@file&quot;<br>      # Global redirect to HTTPS<br>      - &quot;traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)&quot;<br>      - &quot;traefik.http.routers.http-catchall.entrypoints=web&quot;<br>      - &quot;traefik.http.routers.http-catchall.middlewares=redirect-to-https&quot;<br>      # Middleware for HTTPS redirect<br>      - &quot;traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https&quot;<br>      # Global HTTPS catchall<br>      - &quot;traefik.http.routers.catchall-router.rule=HostRegexp(`{host:.+}`)&quot;<br>      - &quot;traefik.http.routers.catchall-router.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.catchall-router.middlewares=authentik-forward-auth@file&quot;<br>      - &quot;traefik.http.routers.catchall-router.tls.certresolver=cloudflare&quot;<br>      # Dummy service for the catchall router<br>      - &quot;traefik.http.services.noop-service.loadbalancer.server.port=80&quot;<br>    command:<br>      - &quot;--api.insecure=false&quot;<br>      - &quot;--providers.docker=true&quot;<br>      - &quot;--entrypoints.web.address=:80&quot;<br>      - &quot;--entrypoints.websecure.address=:443&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge=true&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge.provider=cloudflare&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.email=${CLOUDFLARE_API_EMAIL}&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.storage=/traefik/letsencrypt/acme.json&quot;<br>    ports:<br>      - &quot;80:80&quot;<br>      - &quot;443:443&quot;<br>    volumes:<br>      - &quot;/var/run/docker.sock:/var/run/docker.sock:ro&quot;<br>      - &quot;./traefik/letsencrypt:/letsencrypt&quot;<br>      - &quot;./traefik/traefik.yml:/traefik.yml:ro&quot;  <br>      - &quot;./traefik/dynamic:/etc/traefik/dynamic:ro&quot;<br>    environment:<br>      - CLOUDFLARE_API_EMAIL=${CLOUDFLARE_API_EMAIL}<br>      - CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN}<br>    networks:<br>      - traefik_network</pre><p>And we are going to modify our dynamic/authentik.yml to be a bit more of a descriptive middlewares name.</p><pre>http:<br>  middlewares:<br>    authentik-forward-auth:<br>      forwardAuth:<br>        address: &quot;http://authentik_server:9000/outpost.goauthentik.io/auth/traefik&quot;<br>        trustForwardHeader: true<br>        authResponseHeaders:<br>          - X-authentik-username<br>          - X-authentik-email<br>          - X-authentik-name<br>          - X-authentik-groups</pre><p>Now we just need to make a new Provider and Application and add the Application to our Outpost:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKbaMwI2YSpRKEayxQVAtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chE_MM294a02A8uzA1ZMTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3VZNuTOD_W2LzXO56fJpcA.png" /></figure><h3>Recap of Accomplishments</h3><h3>1. Wildcard DNS Configuration</h3><p><strong>Objective:</strong> Point all subdomains (*.joetaylor.me) to your public IP address.</p><p><strong>Actions Taken:</strong></p><ul><li><strong>Cloudflare Setup:</strong> Created a wildcard DNS A record (*) in Cloudflare pointing to your public IP.</li><li><strong>Verification:</strong> Ensured that subdomains like n8n.joetaylor.me, home.joetaylor.me, and traefik.joetaylor.me resolve correctly to your public IP.</li></ul><h3>2. Traefik Configuration Adjustments</h3><p><strong>Objective:</strong> Configure Traefik to handle wildcard domains and integrate with Authentik for centralized authentication.</p><p><strong>Actions Taken:</strong></p><ul><li><strong>Traefik Version Update:</strong> Upgraded to Traefik v3.1.4.</li><li><strong>Static Configuration (</strong><strong>traefik.yml):</strong></li><li><strong>Providers:</strong> Configured both Docker and File providers to manage dynamic configurations.</li><li><strong>EntryPoints:</strong> Defined web (port 80) and websecure (port 443).</li><li><strong>Certificates Resolvers:</strong> Set up Cloudflare DNS challenge for Let’s Encrypt to obtain wildcard SSL certificates.</li><li><strong>Removed Incorrect </strong><strong>domains Field:</strong> Fixed the Traefik error by removing the unsupported domains field under certificatesResolvers.</li><li><strong>Dynamic Configuration (</strong><strong>middlewares.yml):</strong></li><li><strong>Middleware Definition:</strong> Created authentik-forward-auth middleware to handle forward authentication with Authentik.</li><li><strong>Catch-All Router:</strong> Set up a catch-all router that applies the Authentik middleware to all subdomains under *.joetaylor.me.</li><li><strong>Docker Compose (</strong><strong>docker-compose.yml):</strong></li><li><strong>Traefik Service:</strong> Updated to include dynamic configuration directory and corrected middleware references from authentik-auth@file to authentik-forward-auth@file.</li><li><strong>Service Labels:</strong> Ensured all services (n8n, welcome-home, authentik_server) reference the updated middleware.</li><li><strong>Network Configuration:</strong> Verified that all services are connected to the traefik_network.</li></ul><h3>3. Authentik Integration</h3><p><strong>Objective:</strong> Implement Authentik as the centralized authentication provider for all services.</p><p><strong>Actions Taken:</strong></p><ul><li><strong>Authentik Services:</strong> Defined Authentik server, worker, PostgreSQL, and Redis services in docker-compose.yml.</li><li><strong>Provider and Application Setup:</strong></li><li><strong>Provider:</strong> Created a domain-wide forward authentication provider in Authentik.</li><li><strong>Application:</strong> Set up a corresponding application linked to the provider.</li><li><strong>Embedded Outpost:</strong> Configured the embedded outpost to include the new Authentik application for handling authentication flows.</li><li><strong>Middleware Application:</strong> Applied the authentik-forward-auth middleware globally to all subdomains via Traefik’s dynamic configuration.</li></ul><h3>5. Verification and Testing</h3><ul><li><strong>Objective:</strong> Ensure that all configurations work as intended.</li><li><strong>Actions Taken:</strong></li><li><strong>Service Access:</strong> Verified that accessing services like https://n8n.joetaylor.me and https://home.joetaylor.me redirects to Authentik’s login page.</li><li><strong>Authentication Flow:</strong> Confirmed that after successful login via Authentik, users are redirected back to the respective services.</li><li><strong>SSL Certificates:</strong> Ensured that Traefik successfully obtained and applied wildcard SSL certificates for *.joetaylor.me.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3471bf4b50c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quality of Life - Streamlining Docker Workflow: From CLI Commands to VS Code and Lazydocker]]></title>
            <link>https://medium.com/@learningsomethingnew/quality-of-life-streamlining-docker-workflow-from-cli-commands-to-vs-code-and-lazydocker-0a6294c2f34d?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a6294c2f34d</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Wed, 02 Oct 2024 21:09:26 GMT</pubDate>
            <atom:updated>2024-10-02T21:09:26.594Z</atom:updated>
            <content:encoded><![CDATA[<p>Utilizing Docker through CLI Commands was great to start learning… but there has to be a better way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rM078IXAfB1fcVcoMGjURw.png" /></figure><p>As we have been building out our Off Grid Pi, I found myself repeatedly typing the same commands in the terminal:</p><ul><li>docker ps</li><li>docker-compose down</li><li>docker-compose up -d</li><li>docker logs [container] --tail 100</li></ul><p>While these commands are essential, the repetitive nature of typing them over and over became a significant drain on my productivity. I knew there had to be a better way to manage my Docker containers more efficiently. That’s when I discovered the power of the Docker extension in Visual Studio Code and a nifty tool called <a href="https://github.com/jesseduffield/lazydocker"><strong>lazydocker</strong></a>.</p><h3>The Problem: Repetitive Docker Commands</h3><p>Using the terminal for Docker commands is straightforward but can become cumbersome:</p><ul><li><strong>Monitoring Containers</strong>: Constantly checking the status of containers with docker ps.</li><li><strong>Managing Services</strong>: Bringing services up and down with docker-compose up -d and docker-compose down.</li><li><strong>Viewing Logs</strong>: Tailoring logs for specific containers using docker logs.</li></ul><p>While these commands are powerful, they lack a user-friendly interface that can streamline the workflow.</p><h3>The Solution: VS Code Docker Extension and Lazydocker</h3><h3>VS Code Docker Extension</h3><p>I was already using Visual Studio Code (VS Code) for development, and I learned about the <strong>Docker extension</strong>:</p><ul><li><strong>Installation</strong>: You can install it directly from the VS Code marketplace.</li></ul><h4><strong>Features</strong>:</h4><p><strong>Visual Management</strong>: View all your Docker containers, images, and networks in a graphical interface.</p><p><strong>Easy Commands</strong>: Start, stop, and remove containers with a click.</p><p><strong>Integration</strong>: Works seamlessly with other VS Code features like debugging and task running.</p><h4><strong>How It Helped</strong>:</h4><ul><li><strong>Efficiency</strong>: No more switching between the editor and terminal.</li><li><strong>Visibility</strong>: Quickly identify running containers and their statuses.</li><li><strong>Convenience</strong>: Manage Docker Compose files directly within the editor.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*PHp_pXWgtttP7POvVTyy2Q.png" /></figure><h3>Lazydocker in Warp Terminal</h3><p>Ok, so thats a clear win leveraging the official VS Code exstension for Docker.</p><blockquote>Small note, I use Cursor but all of the same exstension’s work as it is a fork of VS Code</blockquote><p>But I also use <a href="https://www.warp.dev/">WARP</a> as my preferred terminal because of the AI integrations… after a brief consultation with <a href="https://openai.com/index/searchgpt-prototype/">OpenAI Search</a> I stumbled on <a href="https://github.com/jesseduffield/lazydocker">Lazydocker</a>, a simple terminal UI for Docker and Docker Compose:</p><p>Currently we are working on a project utilizing a Raspberry Pi 4, so we are going to install Lazydocker on the Pi which we access through Warp via SHH.</p><h4>Step-by-Step Guide: Setting Up Lazydocker on Raspberry Pi</h4><p>Here’s how I set it up:</p><p><strong>SSH into Raspberry Pi</strong>:</p><pre>ssh pi@your-pi-ip-address</pre><p><strong>Create a Tools Directory</strong>:</p><pre>mkdir ~/Tools<br>cd ~/Tools</pre><p><strong>Install Lazydocker</strong>:</p><pre>curl -Lo install.sh https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh</pre><p><strong>Update PATH Variable</strong>:</p><pre>echo &#39;export PATH=$PATH:$HOME/.local/bin&#39; &gt;&gt; ~/.bashrc source ~/.bashrc</pre><p><strong>Run Lazydocker</strong>:</p><pre>lazydocker</pre><p>Now, you can manage your Docker containers on the Raspberry Pi through an intuitive UI directly from your terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5z4APZDazF4537u3Ukvxog.png" /></figure><h3>Benefits Realized</h3><ul><li><strong>Time Savings</strong>: Reduced the time spent typing repetitive commands.</li><li><strong>Improved Workflow</strong>: Seamless integration between development and Docker management.</li><li><strong>Better Oversight</strong>: Enhanced ability to monitor and troubleshoot containers.</li></ul><h3>Conclusion</h3><p>Transitioning from repetitive CLI commands to using the VS Code Docker extension and Lazydocker has significantly improved my productivity.</p><p>If you find yourself in the same cycle of typing the same Docker commands repeatedly, I highly recommend giving these tools a try.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a6294c2f34d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 3.1 Going Off Grid: Authentication - Installing Authentik in Our Homelab]]></title>
            <link>https://medium.com/@learningsomethingnew/part-iii-going-off-grid-authentication-installing-authentik-in-our-homelab-d8960f8b8a79?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8960f8b8a79</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[authentik]]></category>
            <category><![CDATA[homelab]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Wed, 02 Oct 2024 18:27:57 GMT</pubDate>
            <atom:updated>2024-10-03T20:24:05.760Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*l6AuFY4DIMs02x1bl5yJhg.png" /></figure><p>In this guide, we’ll walk through setting up <a href="https://goauthentik.io/">Authentik</a> in our homelab using Docker Compose. Authentik is an open-source identity provider that can help you manage authentication across your services. We’ll integrate it into an existing Docker Compose setup that uses Traefik as a reverse proxy.</p><p><em>Credit to </em><a href="https://www.youtube.com/watch?v=N5unsATNpJk&amp;t=157s"><em>Christian Lempa</em></a><em> for his excellent tutorial on setting up Authentik.</em></p><h3>Prerequisites</h3><ul><li><a href="https://medium.com/@learningsomethingnew/going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-7ee2e0f61db3">Complete Part 1: Setting up the Pi</a></li><li><a href="https://medium.com/@learningsomethingnew/part-ii-going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-6f18410b6bb2">Complete Part 2: Setting up some Apps</a></li><li><a href="https://medium.com/@learningsomethingnew/improving-security-of-hosted-content-b3fd94c7e4fd">Complete Security Checkpoint 1: SSH</a></li></ul><h3>Current Homelab Structure</h3><p>Here’s the current structure of our homelab directory:</p><pre>homelab/<br>├── n8n/<br>├── traefik/<br>│   ├── letsencrypt/<br>│   │   └── acme.json<br>│   └── traefik.yml<br>├── welcome_home/<br>│   └── index.html<br>├── .env<br>└── docker-compose.yml</pre><p>We’ll be adding Authentik to this setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QPZ950wH_J7d7flZS28RFQ.png" /></figure><h3>Step 1: Set Up the Authentik Directory</h3><p>Navigate to your homelab directory and create a new directory for Authentik:</p><pre>cd homelab<br>mkdir authentik</pre><h3>Step 2: Download the Authentik Docker Compose Template</h3><p>Inside the authentik directory, download the default Docker Compose file provided by Authentik:</p><pre>curl -O https://goauthentik.io/docker-compose.yml</pre><p>This will create a docker-compose.yml file with the necessary services.</p><pre>services:<br>  postgresql:<br>    image: docker.io/library/postgres:16-alpine<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}&quot;]<br>      start_period: 20s<br>      interval: 30s<br>      retries: 5<br>      timeout: 5s<br>    volumes:<br>      - database:/var/lib/postgresql/data<br>    environment:<br>      POSTGRES_PASSWORD: ${PG_PASS:?database password required}<br>      POSTGRES_USER: ${PG_USER:-authentik}<br>      POSTGRES_DB: ${PG_DB:-authentik}<br>    env_file:<br>      - .env<br>  redis:<br>    image: docker.io/library/redis:alpine<br>    command: --save 60 1 --loglevel warning<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;redis-cli ping | grep PONG&quot;]<br>      start_period: 20s<br>      interval: 30s<br>      retries: 5<br>      timeout: 3s<br>    volumes:<br>      - redis:/data<br>  server:<br>    image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2024.8.3}<br>    restart: unless-stopped<br>    command: server<br>    environment:<br>      AUTHENTIK_REDIS__HOST: redis<br>      AUTHENTIK_POSTGRESQL__HOST: postgresql<br>      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}<br>      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}<br>      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}<br>    volumes:<br>      - ./media:/media<br>      - ./custom-templates:/templates<br>    env_file:<br>      - .env<br>    ports:<br>      - &quot;${COMPOSE_PORT_HTTP:-9000}:9000&quot;<br>      - &quot;${COMPOSE_PORT_HTTPS:-9443}:9443&quot;<br>    depends_on:<br>      - postgresql<br>      - redis<br>  worker:<br>    image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2024.8.3}<br>    restart: unless-stopped<br>    command: worker<br>    environment:<br>      AUTHENTIK_REDIS__HOST: redis<br>      AUTHENTIK_POSTGRESQL__HOST: postgresql<br>      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}<br>      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}<br>      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}<br>    # `user: root` and the docker socket volume are optional.<br>    # See more for the docker socket integration here:<br>    # https://goauthentik.io/docs/outposts/integrations/docker<br>    # Removing `user: root` also prevents the worker from fixing the permissions<br>    # on the mounted folders, so when removing this make sure the folders have the correct UID/GID<br>    # (1000:1000 by default)<br>    user: root<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock<br>      - ./media:/media<br>      - ./certs:/certs<br>      - ./custom-templates:/templates<br>    env_file:<br>      - .env<br>    depends_on:<br>      - postgresql<br>      - redis<br><br>volumes:<br>  database:<br>    driver: local<br>  redis:<br>    driver: local</pre><h3>Step 3: Configure Environment Variables</h3><p>Create a .env file to store environment variables for PostgreSQL and Authentik&#39;s secret key:</p><pre>echo &quot;PG_PASS=$(openssl rand -base64 36 | tr -d &#39;\n&#39;)&quot; &gt;&gt; .env<br>echo &quot;AUTHENTIK_SECRET_KEY=$(openssl rand -base64 60 | tr -d &#39;\n&#39;)&quot; &gt;&gt; .env</pre><p>Since we already have a .env file in our homelab directory (containing Cloudflare credentials), we&#39;ll merge these new variables into that file and remove the .env in the authentik directory to avoid conflicts.</p><p>Optionally, enable error reporting:</p><pre># Optional: Enable error reporting<br>AUTHENTIK_ERROR_REPORTING__ENABLED=true</pre><h3>Step 4: Configure Email Settings</h3><p>Authentik requires an SMTP server for email notifications (e.g., password resets). Instead of using Gmail, we’ll use <a href="https://resend.com/">Resend</a>, which offers a free tier.</p><p>Theres a great setup video on the Authentik YouTube channel thats worth a watch.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FO1qUbrk4Yc8%3Fstart%3D374%26feature%3Doembed%26start%3D374&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DO1qUbrk4Yc8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FO1qUbrk4Yc8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4801af8d5b1a16a1d87e44acc2e79b0/href">https://medium.com/media/d4801af8d5b1a16a1d87e44acc2e79b0/href</a></iframe><p>In it they touch on using Gmail but… I’m not thrilled about that approach and want to test out Resend, so lets do that.</p><h3>Setting Up Resend</h3><ol><li><strong>Create an Account</strong>: Sign up at <a href="https://resend.com/">Resend</a>.</li><li><strong>Add Your Domain</strong>: Add your domain (e.g., joetaylor.me) to Resend.</li><li><strong>Configure DNS Settings</strong>: Follow Resend’s instructions to update DNS records in Cloudflare.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47H0klEM7iroci7G9a4yJA.png" /></figure><p><strong>4. Generate an API Key</strong>: In Resend, navigate to <strong>API Keys</strong> and generate a new key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ifQX-GctCwgFjjku0oY2Pg.png" /></figure><h3>Update .env with Resend SMTP Settings</h3><p>Add the following to your .env file (replace [resend_api_key] with your actual API key):</p><pre># Email Configuration<br>AUTHENTIK_EMAIL__HOST=smtp.resend.com<br>AUTHENTIK_EMAIL__PORT=587<br>AUTHENTIK_EMAIL__USERNAME=resend<br>AUTHENTIK_EMAIL__PASSWORD=[resend_api_key]<br>AUTHENTIK_EMAIL__USE_TLS=true<br>AUTHENTIK_EMAIL__USE_SSL=false<br>AUTHENTIK_EMAIL__TIMEOUT=10<br>AUTHENTIK_EMAIL__FROM=authentik@joetaylor.me</pre><p>You can tripple check the SMTP Resend settings from you Resent Account as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2LNFnC78kmcSs98YyFOYA.png" /></figure><h3>Step 5: Update Your Docker Compose File</h3><p>We’ll integrate Authentik into our existing docker-compose.yml file.</p><h3>Existing Services</h3><p>Your current services include Traefik, n8n, and a welcome page. We’ll add the Authentik services alongside them.</p><h3>Updated docker-compose.yml</h3><pre>services:<br>  traefik:<br>    image: traefik:v2.9<br>    container_name: traefik<br>    restart: unless-stopped<br>    labels:<br>      - &quot;traefik.enable=true&quot;<br>      - &quot;traefik.http.routers.dashboard.rule=Host(`traefik.home.joetaylor.me`)&quot;<br>      - &quot;traefik.http.routers.dashboard.service=api@internal&quot;<br>      - &quot;traefik.http.routers.dashboard.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.dashboard.tls.certresolver=cloudflare&quot;<br>    command:<br>      - &quot;--api.insecure=false&quot;<br>      - &quot;--providers.docker=true&quot;<br>      - &quot;--entrypoints.web.address=:80&quot;<br>      - &quot;--entrypoints.websecure.address=:443&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge=true&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge.provider=cloudflare&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.email=${CLOUDFLARE_API_EMAIL}&quot;<br>      - &quot;--certificatesresolvers.cloudflare.acme.storage=/traefik/letsencrypt/acme.json&quot;<br>    ports:<br>      - &quot;80:80&quot;<br>      - &quot;443:443&quot;<br>    volumes:<br>      - &quot;/var/run/docker.sock:/var/run/docker.sock:ro&quot;<br>      - &quot;./traefik/letsencrypt:/letsencrypt&quot;<br>      - &quot;./traefik/traefik.yml:/traefik.yml:ro&quot;  <br>    environment:<br>      - CLOUDFLARE_API_EMAIL=${CLOUDFLARE_API_EMAIL}<br>      - CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN}<br>    networks:<br>      - traefik_network<br><br>  n8n:<br>    image: docker.n8n.io/n8nio/n8n<br>    container_name: n8n<br>    restart: unless-stopped<br>    environment:<br>      - N8N_HOST=n8n.joetaylor.me<br>      - N8N_PORT=5678<br>      - N8N_PROTOCOL=https<br>    labels:<br>      - &quot;traefik.enable=true&quot;<br>      - &quot;traefik.http.routers.n8n.rule=Host(`n8n.joetaylor.me`)&quot;<br>      - &quot;traefik.http.routers.n8n.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.n8n.tls=true&quot;<br>      - &quot;traefik.http.routers.n8n.tls.certresolver=cloudflare&quot;<br>      - &quot;traefik.http.services.n8n.loadbalancer.server.port=5678&quot;<br>    networks:<br>      - traefik_network<br><br>  welcome-home:<br>    image: nginx:alpine<br>    container_name: welcome-home<br>    volumes:<br>      - ./welcome_home/index.html:/usr/share/nginx/html/index.html:ro<br>    labels:<br>      - &quot;traefik.enable=true&quot;<br>      - &quot;traefik.http.routers.welcome-home.rule=Host(`home.joetaylor.me`)&quot;<br>      - &quot;traefik.http.routers.welcome-home.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.welcome-home.tls=true&quot;<br>      - &quot;traefik.http.routers.welcome-home.tls.certresolver=cloudflare&quot;<br>      - &quot;traefik.http.routers.welcome-home-http.rule=Host(`home.joetaylor.me`)&quot;<br>      - &quot;traefik.http.routers.welcome-home-http.entrypoints=web&quot;<br>      - &quot;traefik.http.routers.welcome-home-http.middlewares=welcome-home-https-redirect&quot;<br>      - &quot;traefik.http.middlewares.welcome-home-https-redirect.redirectscheme.scheme=https&quot;<br>    networks:<br>      - traefik_network<br><br>  # Authentik Services<br>  postgresql:<br>    image: postgres:16-alpine<br>    container_name: authentik_postgresql<br>    restart: unless-stopped<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -d ${PG_DB:-authentik} -U ${PG_USER:-authentik}&quot;]<br>      start_period: 20s<br>      interval: 30s<br>      retries: 5<br>      timeout: 5s<br>    environment:<br>      POSTGRES_PASSWORD: ${PG_PASS}<br>      POSTGRES_USER: ${PG_USER:-authentik}<br>      POSTGRES_DB: ${PG_DB:-authentik}<br>    volumes:<br>      - database:/var/lib/postgresql/data<br>    env_file:<br>      - .env<br>    networks:<br>      - traefik_network<br><br>  redis:<br>    image: redis:alpine<br>    container_name: authentik_redis<br>    command: --save 60 1 --loglevel warning<br>    restart: unless-stopped<br>    volumes:<br>      - redis:/data<br>    healthcheck:<br>      test: [&quot;CMD-SHELL&quot;, &quot;redis-cli ping | grep PONG&quot;]<br>      start_period: 20s<br>      interval: 30s<br>      retries: 5<br>      timeout: 3s<br>    networks:<br>      - traefik_network<br><br>  authentik_server:<br>    image: ghcr.io/goauthentik/server:2024.8.3<br>    container_name: authentik_server<br>    restart: unless-stopped<br>    command: server<br>    environment:<br>      AUTHENTIK_REDIS__HOST: redis<br>      AUTHENTIK_POSTGRESQL__HOST: postgresql<br>      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}<br>      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}<br>      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}<br>      AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}<br>      AUTHENTIK_ERROR_REPORTING__ENABLED: ${AUTHENTIK_ERROR_REPORTING__ENABLED}<br>    volumes:<br>      - ./authentik/media:/media<br>      - ./authentik/custom-templates:/templates<br>    env_file:<br>      - .env<br>    labels:<br>      - &quot;traefik.enable=true&quot;<br>      - &quot;traefik.http.routers.authentik.rule=Host(`authentik.joetaylor.me`)&quot;<br>      - &quot;traefik.http.routers.authentik.entrypoints=websecure&quot;<br>      - &quot;traefik.http.routers.authentik.tls=true&quot;<br>      - &quot;traefik.http.routers.authentik.tls.certresolver=cloudflare&quot;<br>      - &quot;traefik.http.services.authentik.loadbalancer.server.port=9000&quot;<br>    depends_on:<br>      - postgresql<br>      - redis<br>    networks:<br>      - traefik_network<br><br>  authentik_worker:<br>    image: ghcr.io/goauthentik/server:2024.8.3<br>    container_name: authentik_worker<br>    restart: unless-stopped<br>    command: worker<br>    user: root<br>    environment:<br>      AUTHENTIK_REDIS__HOST: redis<br>      AUTHENTIK_POSTGRESQL__HOST: postgresql<br>      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}<br>      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}<br>      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}<br>      AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY}<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock<br>      - ./authentik/media:/media<br>      - ./media:/media/public<br>      - ./authentik/certs:/certs<br>      - ./authentik/custom-templates:/templates<br>    env_file:<br>      - .env<br>    depends_on:<br>      - postgresql<br>      - redis<br>    networks:<br>      - traefik_network<br><br>volumes:<br>  database:<br>    driver: local<br>  redis:<br>    driver: local<br><br>networks:<br>  traefik_network:<br>    external: true</pre><p><strong>Notes:</strong></p><ul><li>We’ve added the Authentik services (postgresql, redis, authentik_server, and authentik_worker) to our existing Docker Compose file.</li><li>All services are connected to the traefik_network for networking.</li></ul><h3>Step 6: Deploy the Services</h3><p>Bring down any existing containers and deploy the updated configuration:</p><pre>docker-compose down<br>docker-compose up -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oH7BYd-Vmtj9Sh14P9_v7Q.png" /></figure><p>Wait a few moments for all services to start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*PjutfmFZJADkRqY-vNR2lg.png" /></figure><h3>Step 7: Access Authentik</h3><p>Ensure you’ve created an A record in Cloudflare pointing authentik.joetaylor.me to your server&#39;s IP address.</p><p>Navigate to https://authentik.joetaylor.me in your web browser. You should see the Authentik setup page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cDYZ3jn4NRhF6ZwxnIbJyA.png" /></figure><h3>Step 8: Complete Initial Setup</h3><p>To complete the initial setup:</p><ol><li>Navigate to <a href="https://authentik.joetaylor.me/if/flow/initial-setup/">https://authentik.joetaylor.me/if/flow/initial-setup/.</a></li><li>Set up the initial admin account (akadmin) by providing an email and secure password.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*wBRLYd_fVLdDF-1F_UKl7g.png" /></figure><p>You’ll be greeted with the account page and have access to the Admin Portal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ceYFdHYLEV84bR01rxVLYA.png" /></figure><p>You can also toggle the Admin Interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ceYFdHYLEV84bR01rxVLYA.png" /></figure><h3>Step 9: Create a Personal Admin Account</h3><p>For better security:</p><ul><li>Create a new administrator account for yourself.</li><li>Set up multi-factor authentication (MFA).</li><li>Disable the akadmin account.</li></ul><p>I really don’t think I could explain this last part any better than Christian so please give his video a watch:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FN5unsATNpJk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DN5unsATNpJk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FN5unsATNpJk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a192c106a9c77cca34bf835507983083/href">https://medium.com/media/a192c106a9c77cca34bf835507983083/href</a></iframe><h3>Conclusion</h3><p>You’ve successfully installed Authentik in your homelab and integrated it with your existing Docker Compose setup. With Authentik, you now have a centralized authentication system to manage access across all your services.</p><h4>Next Steps: Integrate Authentik with Your Services</h4><p>Now that Authentik is up and running, you can integrate it with your existing services to manage authentication centrally.</p><ul><li><strong>Homepage Portal</strong>: Instead of individual subdomains for each app, use a central portal like <a href="https://github.com/gethomepage/homepage/">Homepage</a> at home.joetaylor.me as a launch point.</li><li><strong>Service Integration</strong>: Configure your services (e.g., n8n, Netdata) to use Authentik for authentication.</li><li><strong>Traefik Middleware</strong>: Use Traefik’s middleware to enforce authentication via Authentik on your services.</li></ul><p>… we’ll pick this up in the next one!</p><p><strong>References:</strong></p><ul><li><a href="https://goauthentik.io/docs/installation/docker-compose">Authentik Documentation</a></li><li><a href="https://www.youtube.com/watch?v=N5unsATNpJk">Christian Lempa’s Authentik Tutorial</a></li><li><a href="https://resend.com/">Resend SMTP Service</a></li></ul><p><strong>Disclaimer:</strong> Ensure you keep your environment variables secure and avoid sharing sensitive information like API keys or passwords.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8960f8b8a79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fortifying Your Raspberry Pi: Essential SSH Security for Home Web Servers]]></title>
            <link>https://medium.com/@learningsomethingnew/improving-security-of-hosted-content-b3fd94c7e4fd?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3fd94c7e4fd</guid>
            <category><![CDATA[ssh-security]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 19:41:39 GMT</pubDate>
            <atom:updated>2024-10-02T17:45:07.166Z</atom:updated>
            <content:encoded><![CDATA[<p>A Step-by-Step Guide to Protecting Your Pi-Hosted Content from Unauthorized Access</p><h3>Revisit: Strengthening SSH Security on Local Wi-Fi</h3><p>After successfully setting up the Raspberry Pi in <a href="https://medium.com/@learningsomethingnew/going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-7ee2e0f61db3">Part 1</a> and deploying several apps in <a href="https://medium.com/@learningsomethingnew/part-ii-going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-6f18410b6bb2">Part 2</a>, we now have n8n running locally and accessible over the internet. At this point, it’s a good time to step back and review the security around SSH access.</p><p>I’ve primarily been using SSH via the <a href="https://www.cursor.com/">Cursor IDE</a> within my local network, which is a good practice since we haven’t opened external SSH access yet. Although I currently don’t need to access the Pi via SSH when I’m outside of the local Wi-Fi, it’s important to reinforce security measures for any local access. Even within the confines of your home network, adding extra layers of protection can help prevent unauthorized access to your Raspberry Pi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZhiq5y_9pEYj9UtfuBtNQ.png" /></figure><h3>Introduction</h3><p>If you’re running a Raspberry Pi 4 as a web server at home, especially one that’s accessible from the internet, it’s crucial to secure your SSH access. This guide will walk you through the process of enhancing your SSH security, which is particularly important when you have ports 80 and 443 open for web traffic and are using port forwarding on your Google Nest WiFi.</p><h3>Why Secure SSH?</h3><ol><li><strong>Prevent Unauthorized Access</strong>: By default, SSH can be a target for brute-force attacks.</li><li><strong>Protect Your Network</strong>: A compromised Pi could be used to attack other devices on your network.</li><li><strong>Safeguard Your Web Content</strong>: Ensure that only you can modify the content served by your Pi.</li></ol><h3>Step-by-Step Guide</h3><h3>1. Update Your System</h3><p>First, ensure your system is up to date:</p><pre>sudo apt update &amp;&amp; sudo apt upgrade -y</pre><h3>2. Change Your Password</h3><p>If you haven’t already, change the default password:</p><pre>passwd</pre><p>Follow the prompts to enter a strong, unique password.</p><h3>3. Edit SSH Configuration</h3><p>Open the SSH configuration file:</p><pre>sudo nano /etc/ssh/sshd_config</pre><p>Make the following changes:</p><ul><li>Find the line #PermitRootLogin prohibit-password and change it to: PermitRootLogin no</li><li>Ensure PubkeyAuthentication yes is uncommented</li><li>Change PasswordAuthentication yes to: PasswordAuthentication no</li></ul><p>Save the file and exit (in nano, use Ctrl+X, then Y, then Enter).</p><h3>4. Set Up SSH Key Authentication</h3><p>On your local machine (not the Pi), generate an SSH key pair if you haven’t already:</p><pre>ssh-keygen -t ed25519 -C &quot;your_email@example.com&quot;</pre><p>Copy your public key to the Pi:</p><pre>ssh-copy-id username@your_pi_ip_address</pre><p>Replace username and your_pi_ip_address with your Pi&#39;s details.</p><h3>5. Restart SSH Service</h3><p>After making these changes, restart the SSH service:</p><pre>sudo systemctl restart ssh</pre><h3>6. Test Your Configuration</h3><p>Try to SSH into your Pi from another device. You should only be able to log in using your SSH key, not with a password.</p><h3>Additional Security Measures</h3><ol><li><strong>Change SSH Port</strong>: Consider changing the default SSH port (22) to a non-standard port.</li><li><strong>Use a Firewall</strong>: Set up and configure a firewall like ufw.</li><li><strong>Enable Two-Factor Authentication</strong>: For an extra layer of security, consider setting up 2FA for SSH.</li></ol><h3>Re-cap</h3><p>By following this guide, you’ve significantly improved the security of your Raspberry Pi 4 web server. Remember to keep your system updated and regularly review your security settings. With these measures in place, you can more confidently expose your web services to the internet through your Google Nest WiFi.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3fd94c7e4fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 2 Going Off-Grid: Self-Hosting Open-Source SaaS Replacements on Raspberry Pi]]></title>
            <link>https://medium.com/@learningsomethingnew/part-ii-going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-6f18410b6bb2?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f18410b6bb2</guid>
            <category><![CDATA[self-hosting]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[homelab]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 18:12:18 GMT</pubDate>
            <atom:updated>2024-10-03T20:24:34.130Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BkaGDJiI0zkD45cP.png" /></figure><p>Welcome back to my self-hosting journey!</p><p>In <a href="https://medium.com/@learningsomethingnew/going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-7ee2e0f61db3">Part 1</a>, I shared how I’m transitioning from various SaaS tools to a self-hosted ecosystem on a Raspberry Pi 4.</p><p>Previously, I shared progress starting up Coolify to help manage deployments since I’m familiar with Vercel and happy using the tool. As Coolify has been brought up as a Vercel alternative for self hosting I figured I’d give it a shot.</p><p>However, we’ve pivoted. Setting up a secure https connection was not as straight forward as I had hoped and I needed to simplify the stack.</p><p>In this installment, I’ll walk you through how I set up <strong>n8n</strong> and a static placeholder home dashboard, securing them with <strong>Traefik</strong> and <strong>Cloudflare</strong>.</p><h3>Recap of Part 1</h3><p>In the first part of this series, I detailed my motivation to move away from multiple SaaS subscriptions to a self-hosted setup on a Raspberry Pi 4 (8GB).</p><p>I highlighted the benefits of self-hosting, such as cost-efficiency, enhanced control, and skill development.</p><p>I also introduced Coolify as a tool to manage Docker deployments, aiming to simplify the process of deploying and managing applications like <strong>n8n</strong> for workflow automation.</p><p>While we scraped Coolify, we may come back to it…</p><h3>Why Abandon Coolify?</h3><p>While <strong>Coolify</strong> promised an all-in-one alternative to Vercel for managing deployments, I ran into a few roadblocks:</p><ol><li><strong>Errors and Stability Issues</strong>: During installation and initial configuration, we were getting errors accessing n8n via secure https of local network connections. Page wouldn’t load.</li><li><strong>Limited Granular Control</strong>: Coolify abstracts many configurations to simplify deployment, but this abstraction limited my ability to follow what was going wrong.</li><li><strong>Learning Curve</strong>: Balancing the need to learn Coolify while simultaneously trying to secure and deploy <strong>n8n</strong> added complexity and delayed progress.</li></ol><p>Given these challenges, I decided to proceed without Coolify, opting instead for a more hands-on approach using <strong>Docker Compose</strong> and <strong>Traefik</strong>.</p><p>This not only provided me with the granular control I needed but also deepened my understanding of Docker and reverse proxy configurations and Cloudflare DNS management.</p><h3>Back to Work:</h3><h3>Setting Up Traefik for HTTPS and Reverse Proxy</h3><p>Again, to secure my services and manage traffic routing, I chose <strong>Traefik</strong> as my reverse proxy and SSL manager with <strong>LetsEncrypt</strong>. Traefik seamlessly integrates with Docker and supports automatic SSL certificate management via <strong>Cloudflare</strong>.</p><h3>Step 1: Organize Your Project Directory</h3><p>Lets make things simple.</p><p>In fact I deleted everything on the Pi from Post 1 since they were all runing in Docker Containers the process was super simple.</p><p>But now we are going to create a Directory for our entire home lab setup. this is what we’re going for:</p><pre>homelab/<br>├── n8n/<br>├── traefik/<br>│   ├── letsencrypt/<br>│   │   └── acme.json<br>│   └── traefik.yml<br>├── welcome_home/<br>│   └── index.html<br>├── .env<br>└── docker-compose.yml</pre><p>Very simple and clean if you ask me. Nothing is in n8n for now, but I have it there in case something comes up. Its also a bit of a visual remind I have that installed and running…</p><p>Start by organizing your project structure on the Raspberry Pi:</p><pre>mkdir -p ~/homelab<br>cd ~/homelab<br>mkdir n8n traefik welcome_home</pre><h3>Step 2: Create a docker-compose.yml File</h3><p>Within the ~/homelab directory, create a docker-compose.yml file with the following content:</p><pre>    services:<br>      traefik:<br>        image: traefik:v2.9<br>        container_name: traefik<br>        restart: unless-stopped<br>        labels:<br>          - &quot;traefik.enable=true&quot;<br>          - &quot;traefik.http.routers.dashboard.rule=Host(`traefik.home.joetaylor.me`)&quot;<br>          - &quot;traefik.http.routers.dashboard.service=api@internal&quot;<br>          - &quot;traefik.http.routers.dashboard.entrypoints=websecure&quot;<br>          - &quot;traefik.http.routers.dashboard.tls.certresolver=cloudflare&quot;<br>        command:<br>          - &quot;--api.insecure=false&quot;<br>          - &quot;--providers.docker=true&quot;<br>          - &quot;--entrypoints.web.address=:80&quot;<br>          - &quot;--entrypoints.websecure.address=:443&quot;<br>          - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge=true&quot;<br>          - &quot;--certificatesresolvers.cloudflare.acme.dnschallenge.provider=cloudflare&quot;<br>          - &quot;--certificatesresolvers.cloudflare.acme.email=${CLOUDFLARE_API_EMAIL}&quot;<br>          - &quot;--certificatesresolvers.cloudflare.acme.storage=/traefik/letsencrypt/acme.json&quot;<br>        ports:<br>          - &quot;80:80&quot;<br>          - &quot;443:443&quot;<br>        volumes:<br>          - &quot;/var/run/docker.sock:/var/run/docker.sock:ro&quot;<br>          - &quot;./traefik/letsencrypt:/letsencrypt&quot;<br>          - &quot;./traefik/traefik.yml:/traefik.yml:ro&quot;  <br>        environment:<br>          - CLOUDFLARE_API_EMAIL=${CLOUDFLARE_API_EMAIL}<br>          - CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN}<br>        networks:<br>          - traefik_network<br><br>      n8n:<br>        image: docker.n8n.io/n8nio/n8n<br>        container_name: n8n<br>        restart: unless-stopped<br>        environment:<br>          - N8N_HOST=n8n.joetaylor.me<br>          - N8N_PORT=5678<br>          - N8N_PROTOCOL=https<br>        labels:<br>          - &quot;traefik.enable=true&quot;<br>          - &quot;traefik.http.routers.n8n.rule=Host(`n8n.joetaylor.me`)&quot;<br>          - &quot;traefik.http.routers.n8n.entrypoints=websecure&quot;<br>          - &quot;traefik.http.routers.n8n.tls=true&quot;<br>          - &quot;traefik.http.routers.n8n.tls.certresolver=cloudflare&quot;<br>          - &quot;traefik.http.services.n8n.loadbalancer.server.port=5678&quot;<br>        networks:<br>          - traefik_network<br><br>      welcome-home:<br>        image: nginx:alpine<br>        container_name: welcome-home<br>        volumes:<br>          - ./welcome_home/index.html:/usr/share/nginx/html/index.html:ro<br>        labels:<br>          - &quot;traefik.enable=true&quot;<br>          - &quot;traefik.http.routers.welcome-home.rule=Host(`home.joetaylor.me`)&quot;<br>          - &quot;traefik.http.routers.welcome-home.entrypoints=websecure&quot;<br>          - &quot;traefik.http.routers.welcome-home.tls=true&quot;<br>          - &quot;traefik.http.routers.welcome-home.tls.certresolver=cloudflare&quot;<br>          - &quot;traefik.http.routers.welcome-home-http.rule=Host(`home.joetaylor.me`)&quot;<br>          - &quot;traefik.http.routers.welcome-home-http.entrypoints=web&quot;<br>          - &quot;traefik.http.routers.welcome-home-http.middlewares=welcome-home-https-redirect&quot;<br>          - &quot;traefik.http.middlewares.welcome-home-https-redirect.redirectscheme.scheme=https&quot;<br>        networks:<br>          - traefik_network<br><br>    networks:<br>      traefik_network:<br>        external: true</pre><p><strong>Create a .env File</strong></p><pre>CLOUDFLARE_API_EMAIL=[cloudflare account email<br>CLOUDFLARE_DNS_API_TOKEN=[cloudflare api token we will get later]</pre><h3>Step 3: Configure Traefik</h3><p>Create the traefik.yml configuration file in ~/homelab/traefik/traefik.yml:</p><pre>api:<br>  dashboard: true<br><br>entryPoints:<br>  web:<br>    address: &quot;:80&quot;<br>  websecure:<br>    address: &quot;:443&quot;<br><br>providers:<br>  docker:<br>    endpoint: &quot;unix:///var/run/docker.sock&quot;<br>    exposedByDefault: false<br><br>certificatesResolvers:<br>  cloudflare:<br>    acme:<br>      email: ${CLOUDFLARE_API_EMAIL}<br>      storage: /letsencrypt/acme.json<br>      dnsChallenge:<br>        provider: cloudflare<br>        resolvers:<br>          - &quot;1.1.1.1:53&quot;<br>          - &quot;1.0.0.1:53&quot;</pre><h3>Step 4: Create an External Docker Network</h3><p>Traefik and your services need to communicate over a shared Docker network. Create it using the terminal command:</p><pre>docker network create traefik_network</pre><h3>Step 5: Configure Cloudflare DNS</h3><h3>5.1. Log in to Cloudflare</h3><p>Access your Cloudflare dashboard and select your domain, in my case:joetaylor.me.</p><h3>5.2. Add DNS Records for Subdomains</h3><p>You need to create A or CNAME records for your subdomains pointing to your home IP.</p><p><strong>Option 1: Using </strong><strong>A Records (If You Have a Static IP)</strong></p><ol><li><strong>n8n Subdomain</strong></li></ol><ul><li><strong>Type</strong>: A</li><li><strong>Name</strong>: home</li><li><strong>Content</strong>: Your public IP address</li><li><strong>Proxy Status</strong>: Proxied (Orange cloud)</li></ul><p><strong>Option 2: Using </strong><strong>CNAME Records with Dynamic DNS (If You Have a Dynamic IP)</strong></p><ol><li><strong>Set Up Dynamic DNS</strong>: Use a dynamic DNS provider (e.g., No-IP, DuckDNS) to get a dynamic subdomain that points to your home IP.</li><li><strong>n8n Subdomain</strong></li></ol><ul><li><strong>Type</strong>: CNAME</li><li><strong>Name</strong>: home</li><li><strong>Content</strong>: Your dynamic DNS hostname (e.g., home.yourddns.com)</li><li><strong>Proxy Status</strong>: Proxied (Orange cloud)</li><li><strong>Type</strong>: CNAME</li></ul><p><em>Note: Ensure your dynamic DNS updates automatically when your IP changes.</em></p><h3>NOTE: You Most Likely Have a Dynamic IP at Home</h3><p>In this case, the AI suggests using No-IP or DuckDNS. I’d suggest we use <a href="https://github.com/n8n-io/n8n">n8n’s automation tool</a> (a forth-coming install on our Pi in a later post) to build a workflow to monitor for the IP changes and update the A records for us.</p><p>Thats my plan once we get up and running!</p><h3>Step 6: Configure Your Router for Port Forwarding</h3><p>To allow external access to Traefik, you need to forward ports from your router to the Raspberry Pi.</p><ol><li><strong>Access Router Settings</strong>: Log in to your router’s admin panel.</li><li><strong>Set Up Port Forwarding</strong>:</li></ol><ul><li><strong>Port 80 (HTTP) → Raspberry Pi’s Internal IP:80</strong></li><li><strong>Port 443 (HTTPS) → Raspberry Pi’s Internal IP:443</strong></li></ul><p><strong>3. Assign a Static Local IP to Raspberry Pi</strong>: Ensure your Raspberry Pi always has the same internal IP (e.g., 192.168.1.100).</p><p><em>Refer to your router’s documentation for specific instructions on setting up port forwarding and assigning static IPs.</em></p><h3>NOTE: Working with a Google Nest Wifi</h3><p>Since I have a Google Nest Wifi these are the more specific steps:</p><ol><li>Open the Google Home app on your smartphone or tablet.</li><li>Tap on the “Wi-Fi” icon at the top of the home screen.</li><li>Tap on “Settings” (gear icon) in the top right corner.</li><li>Scroll down and tap on “Advanced networking”.</li><li>Select “Port management” or “Port forwarding”.</li><li>Tap on the “+” button to add a new port forwarding rule.</li><li>Fill in the required information:</li></ol><ul><li>Device: Choose the device you want to forward ports to (your Raspberry Pi in this case)</li><li>Protocol: Select TCP, UDP, or Both (for Traefik, you’ll need TCP)</li><li>External ports: Enter 80 and 443 (you’ll need to create separate rules for each)</li><li>Internal ports: Enter 80 and 443 respectively</li><li>Name: Give your rule a descriptive name (e.g., “Traefik HTTP” and “Traefik HTTPS”)</li></ul><p>8. Tap “Save” to create the rule.</p><p>9. Repeat the process for both port 80 and 443.</p><p>10. We will also need to ensure your Raspberry Pi’s IP doesn’t change. For that we have two main options:</p><ol><li>Static IP configuration on the Pi: You can configure the Raspberry Pi itself to use a static IP address. This is done by editing the network configuration files on the Pi.</li><li>DHCP reservation on your router: This is often the preferred method. You configure your router to always assign the same IP address to your Raspberry Pi’s MAC address. With Google Nest WiFi, you can do this in the Google Home app:</li></ol><ul><li>Go to Wi-Fi &gt; Settings &gt; Advanced networking &gt; DHCP IP reservations</li><li>Add a reservation for your Raspberry Pi</li></ul><p>Using DHCP reservation is generally recommended because it’s easier to manage and less prone to conflicts with other devices on your network.</p><h3>Step 7: Creating a Static Home Dashboard</h3><p>A centralized dashboard simplifies access to all your self-hosted applications. I’m thinking about using <a href="https://gethomepage.dev/">Homepage</a> but for now we’ll just stand up a placeholder html page.</p><h3>Create the index.html File</h3><p>In the ~/homelab/welcome_home directory, create an index.html file:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Welcome Home&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: Arial, sans-serif;<br>            display: flex;<br>            justify-content: center;<br>            align-items: center;<br>            height: 100vh;<br>            margin: 0;<br>            background-color: #f0f0f0;<br>        }<br>        .container {<br>            text-align: center;<br>            padding: 20px;<br>            background-color: white;<br>            border-radius: 10px;<br>            box-shadow: 0 0 10px rgba(0,0,0,0.1);<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div class=&quot;container&quot;&gt;<br>        &lt;h1&gt;Welcome Home!&lt;/h1&gt;<br>        &lt;p&gt;This is your personal Raspberry Pi web server.&lt;/p&gt;<br>    &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Without Coolify, managing Docker deployments involves directly interacting with Docker Compose files. While this approach requires a bit more manual configuration, it offers greater flexibility and control.</p><h3>Step 8: Fire ‘er Up:</h3><p>With everything in place we can now navigate to our homlab directory and run:</p><pre>docker-compose up -d</pre><h3>Step 1: Verify SSL Certificates</h3><p>Ensure that each subdomain (n8n.joetaylor.me, home.joetaylor.me) is accessible via HTTPS without any certificate warnings.</p><p>Traefik, integrated with Cloudflare, should automatically handle SSL certificate issuance and renewal.</p><h3>Step 2: Check Service Accessibility</h3><p>Access each service through its designated subdomain to confirm they’re operational:</p><ul><li><strong>n8n</strong>: <a href="https://n8n.joetaylor.me/">https://n8n.joetaylor.me</a></li><li><strong>Home Dashboard</strong>: <a href="https://home.joetaylor.me/">https://home.joetaylor.me</a></li></ul><h3>Step 3: Monitor System Performance</h3><p>Use <strong>Netdata</strong> (if previously set up) or other monitoring tools to keep an eye on your Raspberry Pi’s resource usage. Ensure that CPU, memory, and network usage remain within acceptable limits, especially as you add more services.</p><p>Which can still be accessed on the local network via the Pi’s Local IP address + 199999</p><h3>Step 4: Implement Security Best Practices</h3><ul><li><strong>Regular Updates</strong>: Keep your Raspberry Pi OS and Docker containers updated to patch vulnerabilities.</li><li><strong>Strong Passwords</strong>: Use strong, unique passwords for all services, especially those accessible over the internet.</li><li><strong>Firewall Configuration</strong>: Consider configuring a firewall (like ufw) to restrict access to necessary ports only.</li><li><strong>Backup Strategies</strong>: Regularly back up important data, configurations, and acme.json to prevent data loss.</li></ul><h3>Conclusion and Next Steps</h3><p>Welp now we are up with n8n and a placeholder home landing page. So our network connection is secure when connecting off our local network.</p><p>We can now set up credentials in our n8n workflows finally where callbacks wont error out with localhost domain redirects.</p><p>As a next step I’d like to beef up our security and in preliminiary research implement Authentik or some other option when initialyy navigating to home.joetaylor.me… and I don’t like the idea of revisiting the cloudflare dns records for each tool I stand up like n8n and future tools I have planned… so we will likely reconfigre stuff again. But I’m loving Docker and Docker-Compse which makes these deployment tear downs supper easy.</p><p>So catch ya on the next one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f18410b6bb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1 — Going Off-Grid: Self-Hosting Open-Source SaaS Replacements on Raspberry Pi]]></title>
            <link>https://medium.com/@learningsomethingnew/going-off-grid-self-hosting-open-source-saas-replacements-on-raspberry-pi-7ee2e0f61db3?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ee2e0f61db3</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[self-hosted]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Wed, 25 Sep 2024 21:41:33 GMT</pubDate>
            <atom:updated>2024-10-03T20:24:59.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z14Gj5BIidJ0AYCurRT6QQ.png" /></figure><h3><strong>Introduction</strong></h3><p>After watching <a href="https://www.youtube.com/watch?v=e5dhaQm_J6U&amp;t=290s">Fireship’s video</a> titled “<em>Paying for software is stupid… 10 free and open-source SaaS replacements</em>,” I had to give it a shot.</p><p>I had already been a little fed up with all of the tools I found myself having signed up for… and I found myself drifting more and more towards self hosted alternatives.</p><p>A progression had begun, from Office 365… to Google Suite… to Notion, Coda, ClickUp, Trello, Asana, Slack, HubSpot, Zapier, and Make. All the tools I found myself signing-up for free and then being either converted after 14 days to a paid plan or opting in after having reached some free tier limit.</p><p>Doing the head math and thinking to myself I’m paying probably a couple hundred in half used tools scattered across the web continued to nag at me.</p><p>So the idea of self-hosting a suite of tools only fanned the flame of a few warm embers.</p><p>This is the story of how I took the next step and ordered a Raspberry Pi.</p><h3><strong>Why Self-Host?</strong></h3><p>My decision to transition from SaaS to self-hosting was driven by three primary motivations:</p><ol><li><strong>Learning and Skill Development</strong>:<br>Self-hosting provides a hands-on learning experience that no SaaS subscription can replicate. Setting up, managing, and troubleshooting software deployments on my own hardware has significantly expanded my technical skills and understanding of software ecosystems.</li><li><strong>Simplifying Finances</strong>:<br>Subscription fatigue is real. Managing a multitude of subscriptions for tools I use occasionally was not only cumbersome but also financially draining. By consolidating these services into self-hosted alternatives, I aimed to declutter my bank account and eliminate unnecessary recurring expenses.</li><li><strong>Enhanced Control and Customization</strong>:<br>SaaS tools are designed to serve a broad audience, often limiting customization and integration capabilities. Self-hosting allows me to tweak, customize, and integrate services via APIs to fit my specific needs perfectly — no more compromises or one-size-fits-all solutions.</li></ol><p>Additionally, I’ve always wanted to tinker with a Raspberry Pi and explore the realm of home automation. Combining these interests made self-hosting an ideal project.</p><h3><strong>Choosing the Right Hardware: Raspberry Pi 4</strong></h3><p>After careful consideration, I opted for the <strong>Raspberry Pi 4</strong> with <strong>8GB of RAM</strong> and a <strong>256GB microSD card</strong>.</p><p>I asked Sonnet 3.5 for my options and the Pi 4 stood out… why not the 5? I don’t recall.</p><p>As for the 4, you can opt for the 1GB, 2GB, 4GB or 8GB options. I figured I might as well get the 8GB so long as it doesn’t break the bank, and at $75 I figured why not. I got mine at <a href="https://www.adafruit.com/search?q=Raspberry%20Pi%204%20Model%20B#filterSort">Adafruit</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xM53dlUzey9Op3R2nouTDQ.png" /></figure><p>I got the <a href="https://www.amazon.com/gp/product/B09X7DMBVF/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&amp;psc=1">SD Card from Amazon</a> for $30 at the time, and got the SanDisk Extreme PRO because Sonnet 3.5 recommended the fastest read/write speeds will help a lot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pkhz9IE6-gQ8L8tA4LLZgQ.png" /></figure><p>I was basically just buying the best specs for $100. I figured that would be a decent place to start.</p><p>To answer the question you didn’t ask.. why not just self host on a cloud provider rather?</p><p>I had been spinning up a VPS here and there on AWS, GCP, Azure and Digital Ocean on occasion… I was happy with the performance but it was clear to me I would have 1 or 2 running all the time so it nagged me that I might as well stand up something more dedicated.</p><p>I also had a biased mental thought that if the cloud providers were offering me compute resources where by it was the equivalent of a 3 year investment. Meaning I was being charged $2.75 monthly to rent the compute — I’d stick with it and lease vs buy. Why 3 years. Couldn’t tell ya — I figured there was a 3 year obselesance to the hardware based on pure wet thumb in the air. There clearly was a point at which renting was better than buying and I just thought the number was 3. A case could be made for 1 year sure… and that monthly cost would be $8.33.</p><p>So before I hit the checkout button I asked Sonnet 3.5 what the cost would likely be across cloud providers it looked a lil like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uoZuS2300vQaNJ6FUqewdw.png" /></figure><p>OMG, a 2 month payback?! I did spot check the numbers and looked directionally correct. So the price of Security, Power Redundancy… not needed for my lil toy projects.</p><p>Here’s why the Raspberry Pi stood out:</p><ul><li><strong>Cost-Efficiency</strong>:<br>The initial investment in a Raspberry Pi is minimal compared to the ongoing costs of cloud subscriptions. Over time, the Pi proves to be a steal, especially when running multiple services.</li><li><strong>Dedicated Platform</strong>:<br>Unlike using my personal computer, which would tie up resources, the Pi serves as a dedicated platform for experimentation and deployment, ensuring my main machine remains unaffected.</li><li><strong>Learn Something New: </strong>Priceless</li></ul><p>And if I wasn’t convinced to purchase the Pi… enter the <a href="https://www.adafruit.com/product/4318">Rainbow Pibow Coupé 4 for Raspberry Pi 4</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uKEpkZrQYpp1Xsvn4HiFlw.png" /></figure><p>Now that is one sweet looking ride.</p><h3>She’s Arrived</h3><p>So a few weeks go by, and she finally arrives. And setting up the Raspberry Pi was straightforward.</p><p>I followed the general <a href="https://www.raspberrypi.com/documentation/computers/getting-started.html">guide</a> and was surprised how quick and easy it was. We were able to load the os onto the micro SD from my personal laptop and then plug into the Pi along with the usb-c power supply.</p><p>I would say, there are instructions to have the Pi self boot-up and jump on the wifi with password with preloaded instructions on the SD card. That didn’t work for me and I didn’t care to trouble shoot. So make sure you got a <a href="https://www.amazon.com/dp/B003NREDC8?ref=ppx_yo2ov_dt_b_fed_asin_title">USB mouse, keyboard</a> and way to <a href="https://www.amazon.com/dp/B0C2314XLQ?ref=ppx_yo2ov_dt_b_fed_asin_title">hook up to a monitor</a>.</p><p>I plugged in the wired peripherals and could quickly select my wifi, and while I was at it I could pair my preferred wireless devices, the <a href="https://www.logitech.com/en-us/products/mice/mx-master-3s.910-006556.html">Logitech MX Master 3S Wireless Mouse</a> and the <a href="https://iqunix.store/products/iqunix-f97-dark-side">IQUNIX F97 Dark Side Wireless Mechanical Keyboard</a>.</p><p>Note the Pi paired really quick and smoothly to both bluetooth devices. So very impressed with the bluetooth support. The Wifi also connected very fast so the Wifi on board is legit.</p><h3>Setting Up the Raspberry Pi</h3><p>First thing I wanted to do was SSH into the Pi from my personal laptop. And also set up some sort of observation tool I could access on a browser while on the network… with those goals in mind we:</p><p><strong>Initial Setup and SSH Configuration</strong>:<br>Upon powering up the Pi, I immediately enabled SSH to facilitate a headless setup — eliminating the need for a monitor, keyboard, or mouse. This streamlined the deployment process and allowed me to manage the Pi remotely.</p><p><strong>Deploying </strong><a href="https://github.com/netdata/netdata"><strong>Netdata</strong></a><strong> for Monitoring</strong>:<br>Before diving into deploying applications, I installed <strong>Netdata</strong> to monitor the Pi’s vitals. Netdata provides real-time insights into CPU usage, memory consumption, network traffic, and disk health, which are crucial for maintaining smooth operations.</p><p>I liked Netdata cause they had 70k+ Stars on Github and a hosted plan I can opt into. I know the goal is to self host but I like know I can opt into more robust support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WSbGgxpLgrbFz3fuFniURQ.png" /></figure><p>Right about now, I’m feeling really pumped. We are live with our Pi and have our first self hosted solution deployed on her monitoring the vitals. I’m anxious to get n8n up and running.</p><p>But the guides say using HTTP connection is discouraged. I know I’m on my local network just tinkering but I do plan to access these tools while out and about, so perhaps getting the HTTPS set up done is for the better… especially with n8n insisting.</p><p><strong>Setting Up Traefik for HTTPS</strong>:<br>To ensure secure remote access, I installed <strong>Traefik</strong>, a reverse proxy that simplifies handling HTTPS connections. Traefik manages SSL certificates and routes traffic to the appropriate services, making it easier to maintain secure deployments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2EJPy60LJ-LTZjIF1qvcKQ.png" /></figure><p>Sweet, so now lets get n8n up so we can stop the one running on my lap top.</p><p><strong>Deploying n8n for Automation</strong>:<br>One of my key motivations was to host <strong>n8n</strong>, a no-code workflow automation tool that integrates with various services. Previously running n8n on my MacBook Air M1, migrating it to the Pi freed up resources on my main machine and provided a more stable environment for automation tasks.</p><p>I posted about my initial <a href="https://medium.com/@learningsomethingnew/building-an-ai-powered-news-aggregator-my-first-n8n-workflow-40cf3753a387">n8n deployment</a>, feel free to give that a read…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiRECWjSfadtRxw6j6k8Uw.png" /></figure><p>So now time to automate a gmail account…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqjSu8BPm_Qeuc_5k_ScFA.png" /></figure><p>But now we hit a snag… and it was the same snag we hit when we tried to deploy our twitter agent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2llAVkTahjVXsQObYduSgQ.png" /></figure><p>Our authentication callback is stuck… I haven’t consulted Sonnet 3.5 but my hunch is we have a callback env variable stuck on local host and I’m running this from an ip on my local network via ssh. I could connect to teh pi directly with a monitor and mouse/keyboard to complete the OAuth2.0 requests but blah — thats no fun I bet I can just redploy with docker compose.</p><p>But now I’m thinking, there has to be a better way to manage my deployments on the pi. Ive got 3 so far and gonna add more and more and using CLI is fine but I’m very visual I need an interface.</p><p>Fortunately Fireship mentioned Coolify…</p><h3><strong>Introducing Coolify: Streamlining Deployments</strong></h3><p>To address the complexities of managing multiple deployments, I turned to <a href="https://coolify.io/"><strong>Coolify</strong></a>, a comprehensive tool for deploying, managing, and monitoring applications. Recommended by Fireship and supported by community feedback on Reddit, Coolify promised to simplify the deployment process significantly.</p><ul><li><strong>Why Coolify?</strong><br>Coolify offers an all-in-one solution for handling databases, managing services, and monitoring deployments. While it’s resource-intensive, my Raspberry Pi 4 with 8GB of RAM handled it well for the time being.</li><li><strong>Future Scalability</strong>:<br>To ensure optimal performance as I add more services, I’m considering acquiring an additional Raspberry Pi — possibly the Pi 5 with 2GB or 4GB of RAM — dedicated solely to running Coolify. This setup would offload deployment management from the main Pi, allowing each device to operate efficiently without overloading resources.</li></ul><h3><strong>Next Steps</strong></h3><p>So thats where were at.</p><p>I hit pause to share some progress but once we publish this the plan is to:</p><ol><li><strong>Complete Coolify Installation</strong>:<br>Finalizing the setup of Coolify to manage all current and future deployments, ensuring streamlined operations and easier maintenance.</li><li><strong>Redeploy Existing Services Under Coolify</strong>:<br>Migrating Netdata, Traefik, and n8n under Coolify’s management to centralize control and simplify monitoring.</li><li><strong>Monitor and Optimize Resource Usage</strong>:<br>Utilizing Netdata to keep a vigilant eye on system performance, ensuring that the Raspberry Pi operates within optimal parameters and addressing any bottlenecks promptly.</li><li><strong>Expand Hardware for Scalability</strong>:<br>Acquiring an additional Raspberry Pi to dedicate to Coolify, ensuring that deployment management does not strain the primary device, and maintaining smooth operation as more services are added.</li><li><strong>Explore Home Automation Projects</strong>:<br>Leveraging the Raspberry Pi’s capabilities to delve into home automation, integrating IoT devices, and creating a smart home environment tailored to personal preferences.</li></ol><h3><strong>Conclusion</strong></h3><p>For anyone considering a similar path, I encourage you to take the plunge. Start small, be patient with yourself as you navigate the complexities, and relish the satisfaction of building and controlling your own digital ecosystem. In an era where our data and digital experiences are increasingly shaped by large corporations, self-hosting represents a powerful way to assert independence and cultivate technical mastery.</p><p>The road ahead is filled with exciting possibilities, and I eagerly anticipate where this journey will lead next. Who knows? Maybe you’ll be inspired to start your own self-hosting adventure. If you do, I’d love to hear about it!</p><h3><strong>Tips for Getting Started with Self-Hosting</strong></h3><p>My current plan is to take advantage of tools that have 50k+ GitHub Stars that I can self host but make available an option to leverage their cloud services for a nominal fee.</p><ol><li><strong>Choose the Right Hardware</strong>:<br>Start with a reliable platform like the Raspberry Pi 4, which offers a good balance of performance and cost.</li><li><strong>Prioritize Security</strong>:<br>Implement strong security measures from the outset, such as using HTTPS, setting up firewalls, and regularly updating software to protect against vulnerabilities.</li><li><strong>Leverage Community Resources</strong>:<br>Utilize forums, Reddit threads, and tutorials to troubleshoot issues and discover best practices shared by the self-hosting community.</li><li><strong>Start with Essential Services</strong>:<br>Begin by self-hosting a few key services to get accustomed to the process before expanding your ecosystem.</li><li><strong>Monitor System Performance</strong>:<br>Use tools like Netdata to keep track of system health and ensure that your deployments are running smoothly without overloading your hardware.</li><li><strong>Plan for Scalability</strong>:<br>As your self-hosted ecosystem grows, consider additional hardware or more efficient deployment managers to handle the increased load.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ee2e0f61db3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an AI-Powered News Aggregator: My First n8n Workflow]]></title>
            <link>https://medium.com/@learningsomethingnew/building-an-ai-powered-news-aggregator-my-first-n8n-workflow-40cf3753a387?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/40cf3753a387</guid>
            <category><![CDATA[workflow-automation]]></category>
            <category><![CDATA[n8n]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 01:35:39 GMT</pubDate>
            <atom:updated>2024-09-11T01:35:39.364Z</atom:updated>
            <content:encoded><![CDATA[<h3>TL;DR</h3><ul><li>Created an n8n workflow to aggregate and analyze tech news from multiple sources</li><li>Workflow fetches RSS feeds, filters for AI-related content, and generates detailed articles</li><li>Uses AI services like OpenAI’s GPT models for content analysis and article generation</li><li>Demonstrates the power of workflow automation for content curation and creation</li></ul><h3>Introduction</h3><p>I recently discovered n8n, which piqued my interest in the world of workflow automation tools. While friends had previously mentioned <a href="https://zapier.com/">Zappier</a> and <a href="https://www.make.com/en">Make</a>, I was hesitant to commit to another $20 monthly subscription.</p><p><a href="https://n8n.io/">n8n</a>, however, caught my attention for two compelling reasons:</p><ol><li>It offers a self-hosted option</li><li>It boasts an impressive 45,000+ GitHub stars</li></ol><p>There’s also a paid version for those who prefer their hosting service, reminiscent of Supabase, which I’ve had positive experiences with. I’m particularly drawn to projects that allow me to host the core platform and tweak the code as needed.</p><p>Intrigued by n8n’s potential, I decided to create my first workflow to tackle a pressing issue: the overwhelming influx of AI-related news in my inbox.</p><p>My Gmail account was bursting at the seams with largely unopened email notifications.</p><p>My goal was to automate the process of collecting, filtering, and summarizing AI news. Join me as we explore how I leveraged n8n to tame my chaotic inbox and stay on top of the latest AI developments…</p><h4>Quick Screen Shot of the Final Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtVb7e-tl8NXDcwirsEScA.png" /><figcaption>The Dream of a Custom News Feed</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Vu-SuOjtELFe4e-BBSDvQ.png" /><figcaption>Complete with AI summaries</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jS1CMa-xWJyHKqO2H1dV8A.png" /><figcaption>That Will Cite Sources</figcaption></figure><h3>What is n8n?</h3><p>Before diving into the workflow details, let’s briefly discuss what n8n is. n8n (pronounced as “n-eight-n”) is an open-source workflow automation tool that allows you to connect various services and automate tasks without writing code. It provides a visual interface to create complex workflows by linking different nodes, each representing a specific action or service.</p><h3>The Workflow Overview</h3><p>Again, the task at hand was to clean up my gmail account, and a key use case that stood out to me was utilizing AI summarize all the key news headlines related to AI. I could then unsubscribe from all these notifications.</p><p>I decided to build an n8n workflow that would:</p><ol><li>Fetch RSS feeds from multiple news sources</li><li>Parse the RSS content</li><li>Filter for AI-related articles</li><li>Perform a quick internet search on the topic</li><li>Generate expanded articles using AI based on the internet search results</li><li>Save the results to a database</li><li>Publish to a website</li></ol><p>Let’s break down each component of the workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFdGD268e2CoAmPMn_iFZA.png" /><figcaption>The Full Workflow</figcaption></figure><h3>Fetching RSS Feeds</h3><p>The workflow starts by fetching RSS feeds from several prominent tech news sources:</p><ul><li>The New York Times (Technology section)</li><li>Financial Times</li><li>BBC News (Technology section)</li><li>The Washington Post (Technology section)</li><li>The Wall Street Journal (Tech section)</li></ul><p>This is accomplished using the “HTTP Request” nodes, which are configured to fetch the XML content from each RSS feed URL.</p><h3>Parsing RSS Content</h3><p>After fetching the RSS feeds, the workflow uses “XML” nodes to parse the XML content into a structured format that can be easily processed in subsequent steps.</p><h3>Filtering for AI-Related Content</h3><p>One of the most interesting aspects of this workflow is its ability to filter for AI-related content. This is done using OpenAI’s GPT models. For each article in the RSS feed:</p><ol><li>The title and content snippet are extracted</li><li>GPT4o-mini is prompted to determine if the article is AI-related</li><li>If the article is deemed AI-related, it’s passed on to the next stage; otherwise, it’s skipped</li></ol><p>This filtering step ensures that only relevant AI news makes it through the pipeline. I considered using Llama 3.1 70b via Groq but while I’m a big fan of Groq, the rate limiting makes the platform all but unusable. I’m really hoping they come out with their paid option which seems to only be available for paid enterprise accounts.</p><h3>Generating Expanded Articles</h3><p>For articles that pass the AI-related filter, the workflow goes a step further by generating expanded, more detailed articles. This is done using a combination of services:</p><ol><li><a href="https://jina.ai/">JinaAI</a> Search is used — which I cannot speak more highly off. I’ve used their service in a number of projects without issue.</li><li>The original article snippet, along with the search results, are fed into OpenAI GPT4o-mini. I did test other models and I didn’t observe much of a quality difference in the article output. Sure GPT-4o did better and so did Sonnet but not so much butter I would pay 16x-20x more.</li><li>The AI then generates a comprehensive article, complete with:</li></ol><ul><li>A TL;DR section</li><li>Markdown formatting</li><li>Proper citations</li><li>A metadata section with keywords</li></ul><p>This step transforms brief news snippets into full-fledged articles, providing readers (yours truly) with more context and depth.</p><h3>Saving Results</h3><p>The final step in the workflow involves saving the generated articles and metadata to a database. The workflow uses Supabase, my current prefered database option.</p><ul><li>The original RSS item details</li><li>The AI-generated article content</li><li>Associated metadata like publication date, source, and image URLs</li></ul><h3>Workflow Scheduling</h3><p>To keep the news feed fresh, the entire workflow is scheduled to run periodically using n8n’s “Schedule Trigger” node. This ensures that new articles are regularly fetched, processed, and added to the database.</p><h3>Success?</h3><p>So, after this I was able to run the workflow and review the results… and I was quite pleased. I ran the workflow and observed 53 articles drafted at a cost of $0.007 an article. I also didn’t notice any difference in substantive content within the AI Articles as compared to the actual article from the original publisher… with that, I don’t see how<strong> </strong>or why I would continue to spend $99 a month across these news outlets when I can just pass in the title and the results of a google search into the base model at OpenAI. This really begs the question on the future of what is the traditional journalism infrastructure.</p><p>Another article for another day on that topic.</p><h3>Code:</h3><pre>{<br>  &quot;meta&quot;: {<br>    &quot;instanceId&quot;: &quot;2b378d4b73951813863a038ece98d49c1d584c4e4ec592c16ed4a68cc5f28162&quot;<br>  },<br>  &quot;nodes&quot;: [<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://rss.nytimes.com/services/xml/rss/nyt/Technology.xml&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;aeccb68b-d6da-4f28-988f-56252884351a&quot;,<br>      &quot;name&quot;: &quot;HTTP Request1&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        1060,<br>        760<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;1955e9a6-1063-4cba-b3ca-40df6fd390c0&quot;,<br>      &quot;name&quot;: &quot;XML1&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.xml&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1280,<br>        760<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;fieldToSplitOut&quot;: &quot;rss.channel.item&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;144bfd63-7f64-49b8-bc11-1f309914d46b&quot;,<br>      &quot;name&quot;: &quot;Split Out1&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitOut&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1500,<br>        760<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;9f45e2b0-418d-4362-b8d6-28534522d300&quot;,<br>      &quot;name&quot;: &quot;Loop Over Items2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitInBatches&quot;,<br>      &quot;typeVersion&quot;: 3,<br>      &quot;position&quot;: [<br>        1740,<br>        760<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;=https://s.jina.ai/ {{ encodeURIComponent($json.title) }}&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;69b20423-d9ed-4be7-b973-dc0f4ed0c8da&quot;,<br>      &quot;name&quot;: &quot;JinaAI Search3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3100,<br>        800<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;d81fd6ae-ab6f-4239-9ed4-ce20f1704273&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model5&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3320,<br>        1020<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;ai_articles&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;rss_feed_id&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase3&#39;).item.json.id }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase3&#39;).item.json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.text }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;857b7101-40f6-419f-91b6-02031c622e20&quot;,<br>      &quot;name&quot;: &quot;Save Article3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3660,<br>        800<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;83745ea7-fdb7-4c05-b4de-9965feed5585&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model6&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2340,<br>        1060<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;link&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.link }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;pub_date&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.pubDate }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content_snippet&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;guid&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.guid }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;categories&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.category }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json[&#39;media:content&#39;].url }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;source&quot;,<br>              &quot;fieldValue&quot;: &quot;The New York Times&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;e9ca40cd-43b1-40ba-80fa-ea501156ccba&quot;,<br>      &quot;name&quot;: &quot;Create RSS Item2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1960,<br>        780<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.text }}&quot;,<br>              &quot;rightValue&quot;: &quot;true&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;contains&quot;<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;9ac40e39-9621-489e-9df0-d252447f8b68&quot;,<br>      &quot;name&quot;: &quot;If - Is AI2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2640,<br>        840<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.error }}&quot;,<br>              &quot;rightValue&quot;: &quot;&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;exists&quot;,<br>                &quot;singleValue&quot;: true<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;950f2e2e-db05-4925-9d02-8d8e80a65cfc&quot;,<br>      &quot;name&quot;: &quot;If - Exists Already2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2120,<br>        780<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Create RSS Item2&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;should_draft_article&quot;,<br>              &quot;fieldValue&quot;: &quot;True&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;b7ae19a7-58a6-41b7-b674-b37f98c0dc84&quot;,<br>      &quot;name&quot;: &quot;Supabase3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2900,<br>        800<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;rule&quot;: {<br>          &quot;interval&quot;: [<br>            {<br>              &quot;field&quot;: &quot;cronExpression&quot;,<br>              &quot;expression&quot;: &quot;*/30 8-20 * * *&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;ec09f75c-4140-4309-8a4e-0421cbd2b415&quot;,<br>      &quot;name&quot;: &quot;Schedule Trigger&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.scheduleTrigger&quot;,<br>      &quot;typeVersion&quot;: 1.2,<br>      &quot;position&quot;: [<br>        320,<br>        -320<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=Analyze the following article headline and content snippet.  \n\nDetermin if it is AI related.\n\nout put single word as either true or false\n\ndo not output codeblocks or markdown, just the word true or false.\n\n&lt;article_title&gt;\n{{ $(&#39;Create RSS Item2&#39;).item.json.title }}\n&lt;/article_title&gt;\n\n&lt;article_snippet&gt;\n{{ $(&#39;Create RSS Item2&#39;).item.json.content_snippet }}\n&lt;/article_snippet&gt;&quot;,<br>        &quot;hasOutputParser&quot;: true<br>      },<br>      &quot;id&quot;: &quot;8a5caac9-a1a1-4e52-a232-c79d58cd23a6&quot;,<br>      &quot;name&quot;: &quot;Is AI Related2&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        2320,<br>        840<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://www.ft.com/myft/following/6362d893-8d20-4ab6-b60f-4fcfc8c3e3fc.rss&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;f7ec7c24-99f1-4dd6-b9e8-46286a7393c2&quot;,<br>      &quot;name&quot;: &quot;HTTP Request&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        1060,<br>        1220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;6262922a-11b1-4a8f-a942-f38272f51a91&quot;,<br>      &quot;name&quot;: &quot;XML&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.xml&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1280,<br>        1220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;fieldToSplitOut&quot;: &quot;rss.channel.item&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;105bfd4d-34de-488c-94a2-bbe3f6ceff26&quot;,<br>      &quot;name&quot;: &quot;Split Out&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitOut&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1500,<br>        1220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;9d8db46f-a393-41f3-aa0e-b6eb8ffbf3e8&quot;,<br>      &quot;name&quot;: &quot;Loop Over Items3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitInBatches&quot;,<br>      &quot;typeVersion&quot;: 3,<br>      &quot;position&quot;: [<br>        1740,<br>        1220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;=https://s.jina.ai/ {{ encodeURIComponent($json.title) }}&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;84b870bf-536b-4a8d-ae57-7fa74ab14764&quot;,<br>      &quot;name&quot;: &quot;JinaAI Search4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3340,<br>        1260<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;51d2dd1a-8d9c-46ec-85c0-b73d2b4d5820&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model7&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3560,<br>        1480<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;ai_articles&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;rss_feed_id&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase4&#39;).item.json.id }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase4&#39;).item.json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.text }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;db8701c4-dc15-492c-91d0-7ebb86794be3&quot;,<br>      &quot;name&quot;: &quot;Save Article4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3900,<br>        1260<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;0c90c9fb-a9b0-48a7-8560-78531663c04b&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model8&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2580,<br>        1520<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;link&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.link }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;pub_date&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.pubDate }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.descriptionText }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content_snippet&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.descriptionText }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;guid&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.guid._ }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.imageURL }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;source&quot;,<br>              &quot;fieldValue&quot;: &quot;The Financial Times&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;7185fa8c-b212-4742-9892-defc14a12c5e&quot;,<br>      &quot;name&quot;: &quot;Create RSS Item3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2180,<br>        1240<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.text }}&quot;,<br>              &quot;rightValue&quot;: &quot;true&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;contains&quot;<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;77dfad1d-e155-4567-98b2-2a1818af9a05&quot;,<br>      &quot;name&quot;: &quot;If - Is AI3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2880,<br>        1300<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.error }}&quot;,<br>              &quot;rightValue&quot;: &quot;&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;exists&quot;,<br>                &quot;singleValue&quot;: true<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;6dbed84f-77c3-4793-aab2-bac773d49362&quot;,<br>      &quot;name&quot;: &quot;If - Exists Already3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2360,<br>        1240<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Create RSS Item3&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;should_draft_article&quot;,<br>              &quot;fieldValue&quot;: &quot;True&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;8a18cac2-3458-45f5-8b84-4b523c478fb3&quot;,<br>      &quot;name&quot;: &quot;Supabase4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3140,<br>        1260<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=Analyze the following article headline and content snippet.  \n\nDetermin if it is AI related.\n\nout put single word as either true or false\n\ndo not output codeblocks or markdown, just the word true or false.\n\n&lt;article_title&gt;\n{{ $(&#39;Create RSS Item3&#39;).item.json.title }}\n&lt;/article_title&gt;\n\n&lt;article_snippet&gt;\n{{ $(&#39;Create RSS Item3&#39;).item.json.content_snippet }}\n&lt;/article_snippet&gt;&quot;,<br>        &quot;hasOutputParser&quot;: true<br>      },<br>      &quot;id&quot;: &quot;d2131dfe-13dc-4966-b0d0-358b14925175&quot;,<br>      &quot;name&quot;: &quot;Is AI Related3&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        2560,<br>        1300<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;jsCode&quot;: &quot;function processDescription(description) {\n  const imgSrcRegex = /&lt;img.*?src=\&quot;(.*?)\&quot;/;\n  const imageURL = description.match(imgSrcRegex)?.[1] || &#39;&#39;;\n\n  const textRegex = /&lt;img.*?&gt;(.*?)&lt;br/;\n  const descriptionText = description.match(textRegex)?.[1]?.trim() || &#39;&#39;;\n\n  return { imageURL, descriptionText };\n}\n\nconst processedItems = items.map(item =&gt; {\n  const { imageURL, descriptionText } = processDescription(item.json.description);\n  \n  return {\n    ...item.json,\n    imageURL,\n    descriptionText\n  };\n});\n\nreturn processedItems;&quot;<br>      },<br>      &quot;id&quot;: &quot;af697f7f-ed41-47c9-a139-9ed15db669a3&quot;,<br>      &quot;name&quot;: &quot;Extract Img and Description&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.code&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        1980,<br>        1240<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=You are an AI assistant tasked with writing a news article based on an RSS title, content snippet, and reference material from a Google search. Follow these instructions carefully:\n\n1. You will be provided with an RSS title and content snippet from a news feed:\n\n   ```\n   &lt;rss_title&gt;\n  {{ $(&#39;Supabase4&#39;).item.json.title }}\n   &lt;/rss_title&gt;\n\n   &lt;content_snippet&gt;\n  {{ $(&#39;Supabase4&#39;).item.json.content_snippet }}\n   &lt;/content_snippet&gt;\n   ```\n\n2. You will also be given content from a Google search related to the headline:\n\n   ```\n   &lt;google_search_content&gt;\n{{ JSON.stringify($json.data.substring(0, 400000)) }}\n   &lt;/google_search_content&gt;\n   ```\n\n3. Write an article that expands on the RSS headline and content snippet, using information from the Google search content. The article should be:\n   - Informative\n   - Engaging\n   - Well-structured\n\n4. Format the article using Markdown. Use appropriate Markdown syntax for:\n   - Headings (use ## for the main title, ### for subheadings)\n   - Paragraphs (separate with blank lines)\n   - Bold and italic text where appropriate\n   - Bullet points or numbered lists if needed\n   - Blockquotes for any direct quotes from sources\n\n5. Incorporate information from both the RSS headline/snippet and the Google search content:\n   - Use the headline to guide the main topic\n   - Use the search content to provide additional details and context\n\n6. Maintain a neutral, journalistic tone throughout the article:\n   - Present facts objectively\n   - Do not include personal opinions or biases\n   - Use third-person perspective\n\n7. Structure your article with:\n   - Begin with a TL;DR section. Provide quick bullet points that capture the highlights of the article.\n   - A compelling introduction that summarizes the key points\n   - A conclusion that wraps up the article and potentially suggests future implications\n\n8. If applicable, include:\n   - Relevant statistics or data points\n   - Brief mentions of key stakeholders or experts\n   - Context on why this news is important or impactful\n\n9. Use Wikipedia-style citations in Markdown format:\n   - In the text, use footnote-style references like [^1], [^2], etc.\n   - Use footnotes sequentially without skipping any numbers\n   - At the end of the article, include a ## References section\n   - Format each reference as follows:\n     [^1]: Author Name (if available) (Date). \&quot;[Article Title](URL)\&quot;. Publication Name. Retrieved [Current Date].\n   - If an author name is not available, start with the article title\n   - Ensure all article titles are clickable links using Markdown syntax\n   - Include ALL sources provided in the Google search content in the References section, even if not directly cited in the text\n\n10. Begin your response with &lt;article&gt; and end it with &lt;/article&gt;. The entire article, including the Markdown formatting and references, should be contained within these tags.\n\n11. After the article, provide a brief metadata section with:\n    - Main keywords or tags (do not include links in this section)\n\n12. Double-check your footnotes before completing the article:\n    - Ensure all footnote numbers used in the text have corresponding entries in the References section\n    - Verify that footnote numbers are sequential (1, 2, 3, etc.) without any gaps\n\nRemember to adhere to journalistic standards and ethics in your writing. Stick to the facts presented in the provided sources and avoid sensationalism.&quot;<br>      },<br>      &quot;id&quot;: &quot;855cb2d2-4104-44b5-aa7b-d6ae67558d29&quot;,<br>      &quot;name&quot;: &quot;Write Article4&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        3540,<br>        1260<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://feeds.bbci.co.uk/news/technology/rss.xml&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;024fe7f0-30ee-4482-9533-23f2c953b72d&quot;,<br>      &quot;name&quot;: &quot;HTTP Request2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        1060,<br>        1680<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;f8e1920b-4a32-4b0f-a8dd-bfd30b027089&quot;,<br>      &quot;name&quot;: &quot;XML2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.xml&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1280,<br>        1680<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;fieldToSplitOut&quot;: &quot;rss.channel.item&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;8dc0ce33-d166-4ec8-a990-d0d823689b6e&quot;,<br>      &quot;name&quot;: &quot;Split Out2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitOut&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1500,<br>        1680<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;f699edfa-fd74-45aa-ac3f-3105ba10a509&quot;,<br>      &quot;name&quot;: &quot;Loop Over Items4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitInBatches&quot;,<br>      &quot;typeVersion&quot;: 3,<br>      &quot;position&quot;: [<br>        1740,<br>        1680<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;=https://s.jina.ai/ {{ encodeURIComponent($json.title) }}&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;a5fa0411-9818-460f-8691-a9f18a8d29d5&quot;,<br>      &quot;name&quot;: &quot;JinaAI Search5&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3180,<br>        1720<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;011a4dd6-78e8-42d3-ad75-25045006b419&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model9&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3300,<br>        1860<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;39c9512a-3536-49de-9f1c-bbba719bf4cd&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model10&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2300,<br>        1840<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;link&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.link }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;pub_date&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.pubDate }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content_snippet&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json[&#39;media:thumbnail&#39;].url }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;source&quot;,<br>              &quot;fieldValue&quot;: &quot;BBC News&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;guid&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.guid._ }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;fbdd03b2-3676-47e3-a3bd-fa23a6d4dff7&quot;,<br>      &quot;name&quot;: &quot;Create RSS Item4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2000,<br>        1700<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.text }}&quot;,<br>              &quot;rightValue&quot;: &quot;true&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;contains&quot;<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;246801e0-54a2-41f3-94df-7d59f6bf6c58&quot;,<br>      &quot;name&quot;: &quot;If - Is AI4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2720,<br>        1760<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.error }}&quot;,<br>              &quot;rightValue&quot;: &quot;&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;exists&quot;,<br>                &quot;singleValue&quot;: true<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;6f539020-50ed-44de-845d-ebef97682965&quot;,<br>      &quot;name&quot;: &quot;If - Exists Already4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2200,<br>        1700<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Create RSS Item4&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;should_draft_article&quot;,<br>              &quot;fieldValue&quot;: &quot;True&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;44753353-5591-4981-816b-b3bcaf42ada1&quot;,<br>      &quot;name&quot;: &quot;Supabase5&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2980,<br>        1720<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=Analyze the following article headline and content snippet.  \n\nDetermin if it is AI related.\n\nout put single word as either true or false\n\ndo not output codeblocks or markdown, just the word true or false.\n\n&lt;article_title&gt;\n{{ $(&#39;Create RSS Item4&#39;).item.json.title }}\n&lt;/article_title&gt;\n\n&lt;article_snippet&gt;\n{{ $(&#39;Create RSS Item4&#39;).item.json.content_snippet }}\n&lt;/article_snippet&gt;&quot;,<br>        &quot;hasOutputParser&quot;: true<br>      },<br>      &quot;id&quot;: &quot;1f77c84e-8097-4b0a-a4ae-139586365693&quot;,<br>      &quot;name&quot;: &quot;Is AI Related4&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        2400,<br>        1760<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=You are an AI assistant tasked with writing a news article based on an RSS title, content snippet, and reference material from a Google search. Follow these instructions carefully:\n\n1. You will be provided with an RSS title and content snippet from a news feed:\n\n   ```\n   &lt;rss_title&gt;\n  {{ $(&#39;Supabase5&#39;).item.json.title }}\n   &lt;/rss_title&gt;\n\n   &lt;content_snippet&gt;\n  {{ $(&#39;Supabase5&#39;).item.json.content_snippet }}\n   &lt;/content_snippet&gt;\n   ```\n\n2. You will also be given content from a Google search related to the headline:\n\n   ```\n   &lt;google_search_content&gt;\n{{ JSON.stringify($json.data.substring(0, 300000)) }}\n   &lt;/google_search_content&gt;\n   ```\n\n3. Write an article that expands on the RSS headline and content snippet, using information from the Google search content. The article should be:\n   - Informative\n   - Engaging\n   - Well-structured\n\n4. Format the article using Markdown. Use appropriate Markdown syntax for:\n   - Headings (use ## for the main title, ### for subheadings)\n   - Paragraphs (separate with blank lines)\n   - Bold and italic text where appropriate\n   - Bullet points or numbered lists if needed\n   - Blockquotes for any direct quotes from sources\n\n5. Incorporate information from both the RSS headline/snippet and the Google search content:\n   - Use the headline to guide the main topic\n   - Use the search content to provide additional details and context\n\n6. Maintain a neutral, journalistic tone throughout the article:\n   - Present facts objectively\n   - Do not include personal opinions or biases\n   - Use third-person perspective\n\n7. Structure your article with:\n   - Begin with a TL;DR section. Provide quick bullet points that capture the highlights of the article.\n   - A compelling introduction that summarizes the key points\n   - A conclusion that wraps up the article and potentially suggests future implications\n\n8. If applicable, include:\n   - Relevant statistics or data points\n   - Brief mentions of key stakeholders or experts\n   - Context on why this news is important or impactful\n\n9. Use Wikipedia-style citations in Markdown format:\n   - In the text, use footnote-style references like [^1], [^2], etc.\n   - Use footnotes sequentially without skipping any numbers\n   - At the end of the article, include a ## References section\n   - Format each reference as follows:\n     [^1]: Author Name (if available) (Date). \&quot;[Article Title](URL)\&quot;. Publication Name. Retrieved [Current Date].\n   - If an author name is not available, start with the article title\n   - Ensure all article titles are clickable links using Markdown syntax\n   - Include ALL sources provided in the Google search content in the References section, even if not directly cited in the text\n\n10. Begin your response with &lt;article&gt; and end it with &lt;/article&gt;. The entire article, including the Markdown formatting and references, should be contained within these tags.\n\n11. After the article, provide a brief metadata section with:\n    - Main keywords or tags (do not include links in this section)\n\n12. Double-check your footnotes before completing the article:\n    - Ensure all footnote numbers used in the text have corresponding entries in the References section\n    - Verify that footnote numbers are sequential (1, 2, 3, etc.) without any gaps\n\nRemember to adhere to journalistic standards and ethics in your writing. Stick to the facts presented in the provided sources and avoid sensationalism.&quot;<br>      },<br>      &quot;id&quot;: &quot;d2356b63-beec-4dfd-8a29-8ccd3e301b81&quot;,<br>      &quot;name&quot;: &quot;Write Article5&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        3380,<br>        1720<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;ai_articles&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;rss_feed_id&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase5&#39;).item.json.id }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase5&#39;).item.json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Write Article5&#39;).item.json.text }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;c0c9e6f7-97b3-4d86-b4de-dfb1e20a41ad&quot;,<br>      &quot;name&quot;: &quot;Save Article5&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        4080,<br>        1720<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://www.googleapis.com/customsearch/v1&quot;,<br>        &quot;authentication&quot;: &quot;genericCredentialType&quot;,<br>        &quot;genericAuthType&quot;: &quot;httpQueryAuth&quot;,<br>        &quot;sendQuery&quot;: true,<br>        &quot;queryParameters&quot;: {<br>          &quot;parameters&quot;: [<br>            {<br>              &quot;name&quot;: &quot;q&quot;,<br>              &quot;value&quot;: &quot;={{ $(&#39;Supabase5&#39;).item.json.title }} &quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;cx&quot;,<br>              &quot;value&quot;: &quot;{{ String($(&#39;Globals1&#39;).item.json.google_search_cx).trim() }}&quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;searchType&quot;,<br>              &quot;value&quot;: &quot;image&quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;num&quot;,<br>              &quot;value&quot;: &quot;1&quot;<br>            }<br>          ]<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;8958d252-26b9-460c-b7c1-ea954750084d&quot;,<br>      &quot;name&quot;: &quot;Get Image&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3720,<br>        1720<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;httpQueryAuth&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Google Search Key&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Supabase5&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.items[0].link }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;5c68e57a-7713-4bb4-955f-08885c8edc86&quot;,<br>      &quot;name&quot;: &quot;Supabase6&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3900,<br>        1720<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;content&quot;: &quot;# NYT&quot;,<br>        &quot;height&quot;: 80,<br>        &quot;color&quot;: 5<br>      },<br>      &quot;id&quot;: &quot;05f3ca26-4611-4255-a4d0-5a60f2af34af&quot;,<br>      &quot;name&quot;: &quot;Sticky Note1&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.stickyNote&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        740,<br>        760<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;content&quot;: &quot;# FT&quot;,<br>        &quot;height&quot;: 80,<br>        &quot;color&quot;: 5<br>      },<br>      &quot;id&quot;: &quot;d4dd9943-1315-4ed6-90cc-f7a71f3bdda3&quot;,<br>      &quot;name&quot;: &quot;Sticky Note2&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.stickyNote&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        740,<br>        1240<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;content&quot;: &quot;# BBC&quot;,<br>        &quot;height&quot;: 80,<br>        &quot;color&quot;: 5<br>      },<br>      &quot;id&quot;: &quot;ccf15d80-a500-4368-b210-78c7d94a00d2&quot;,<br>      &quot;name&quot;: &quot;Sticky Note3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.stickyNote&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        740,<br>        1700<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://feeds.washingtonpost.com/rss/business/technology&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;462860b1-2f25-4103-9419-41c03045cf85&quot;,<br>      &quot;name&quot;: &quot;HTTP Request5&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        1060,<br>        -220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;34a43fdb-ab78-4005-8639-046ff048c64b&quot;,<br>      &quot;name&quot;: &quot;XML5&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.xml&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1280,<br>        -220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;fieldToSplitOut&quot;: &quot;rss.channel.item&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;34bddc2c-0fc1-4baf-bb1c-ed1ec96b91bc&quot;,<br>      &quot;name&quot;: &quot;Split Out5&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitOut&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1500,<br>        -220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;73937277-fb32-4591-9c0a-286607aaa4b1&quot;,<br>      &quot;name&quot;: &quot;Loop Over Items7&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitInBatches&quot;,<br>      &quot;typeVersion&quot;: 3,<br>      &quot;position&quot;: [<br>        1740,<br>        -220<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;=https://s.jina.ai/ {{ encodeURIComponent($json.title) }}&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;a21cc7bd-6c12-47c6-902b-86f85075b7a2&quot;,<br>      &quot;name&quot;: &quot;JinaAI Search8&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3180,<br>        -180<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;70de1d46-7b9d-4cc2-aa6c-4ef77cc994a1&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model15&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3380,<br>        40<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;ai_articles&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;rss_feed_id&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase9&#39;).item.json.id }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase9&#39;).item.json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Write Article8&#39;).item.json.text }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;09a3c049-e17a-41eb-b45d-79dfcaebb667&quot;,<br>      &quot;name&quot;: &quot;Save Article8&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        4100,<br>        -180<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;fbc569d5-1c64-4526-bfed-6848761d1a3a&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model16&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2420,<br>        80<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;link&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.link }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;pub_date&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.pubDate }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content_snippet&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;=&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;source&quot;,<br>              &quot;fieldValue&quot;: &quot;The Washington Post&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;guid&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.guid._ }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;06c121d5-fbd8-41c3-819a-7819008372d9&quot;,<br>      &quot;name&quot;: &quot;Create RSS Item7&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2000,<br>        -200<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.text }}&quot;,<br>              &quot;rightValue&quot;: &quot;true&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;contains&quot;<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;b15a7a5a-fea8-4c9c-81eb-ffe16d160806&quot;,<br>      &quot;name&quot;: &quot;If - Is AI7&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2720,<br>        -140<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.error }}&quot;,<br>              &quot;rightValue&quot;: &quot;&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;exists&quot;,<br>                &quot;singleValue&quot;: true<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;7d651663-afc4-4e8a-9ed4-c554aa1dd575&quot;,<br>      &quot;name&quot;: &quot;If - Exists Already7&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2200,<br>        -200<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Create RSS Item7&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;should_draft_article&quot;,<br>              &quot;fieldValue&quot;: &quot;True&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;7fda4ea9-b458-463c-9b1f-c3100810ee18&quot;,<br>      &quot;name&quot;: &quot;Supabase9&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2980,<br>        -180<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://www.googleapis.com/customsearch/v1&quot;,<br>        &quot;authentication&quot;: &quot;genericCredentialType&quot;,<br>        &quot;genericAuthType&quot;: &quot;httpQueryAuth&quot;,<br>        &quot;sendQuery&quot;: true,<br>        &quot;queryParameters&quot;: {<br>          &quot;parameters&quot;: [<br>            {<br>              &quot;name&quot;: &quot;q&quot;,<br>              &quot;value&quot;: &quot;={{ $(&#39;Supabase9&#39;).item.json.title }} &quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;cx&quot;,<br>              &quot;value&quot;: &quot;={{ String($(&#39;Globals1&#39;).item.json.google_search_cx).trim() }}&quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;searchType&quot;,<br>              &quot;value&quot;: &quot;image&quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;num&quot;,<br>              &quot;value&quot;: &quot;1&quot;<br>            }<br>          ]<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;87f48a74-5909-42e7-8449-385916815251&quot;,<br>      &quot;name&quot;: &quot;Get Image3&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3740,<br>        -180<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;httpQueryAuth&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Google Search Key&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Supabase9&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.items[0].link }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;c4913f2c-aacb-4922-bfda-090d45f8ef87&quot;,<br>      &quot;name&quot;: &quot;Supabase10&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3920,<br>        -180<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;content&quot;: &quot;# Washington Post&quot;,<br>        &quot;height&quot;: 126.69426322803548,<br>        &quot;color&quot;: 5<br>      },<br>      &quot;id&quot;: &quot;88f0ed34-2190-4a3a-ac6b-03281360f57f&quot;,<br>      &quot;name&quot;: &quot;Sticky Note6&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.stickyNote&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        740,<br>        -200<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=Analyze the following article headline and content snippet.  \n\nDetermin if it is AI related.\n\nout put single word as either true or false\n\ndo not output codeblocks or markdown, just the word true or false.\n\n&lt;article_title&gt;\n{{ $(&#39;Create RSS Item7&#39;).item.json.title }}\n&lt;/article_title&gt;\n\n&lt;article_snippet&gt;\n{{ $(&#39;Create RSS Item7&#39;).item.json.content_snippet }}\n&lt;/article_snippet&gt;&quot;,<br>        &quot;hasOutputParser&quot;: true<br>      },<br>      &quot;id&quot;: &quot;c006886f-aa7f-440e-bb3b-145b23f89450&quot;,<br>      &quot;name&quot;: &quot;Is AI Related7&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        2400,<br>        -140<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=You are an AI assistant tasked with writing a news article based on an RSS title, content snippet, and reference material from a Google search. Follow these instructions carefully:\n\n1. You will be provided with an RSS title and content snippet from a news feed:\n\n   ```\n   &lt;rss_title&gt;\n  {{ $(&#39;Supabase3&#39;).item.json.title }}\n   &lt;/rss_title&gt;\n\n   &lt;content_snippet&gt;\n  {{ $(&#39;Supabase3&#39;).item.json.content_snippet }}\n   &lt;/content_snippet&gt;\n   ```\n\n2. You will also be given content from a Google search related to the headline:\n\n   ```\n   &lt;google_search_content&gt;\n{{ JSON.stringify($json.data.substring(0, 400000)) }}\n   &lt;/google_search_content&gt;\n   ```\n\n3. Write an article that expands on the RSS headline and content snippet, using information from the Google search content. The article should be:\n   - Informative\n   - Engaging\n   - Well-structured\n\n4. Format the article using Markdown. Use appropriate Markdown syntax for:\n   - Headings (use ## for the main title, ### for subheadings)\n   - Paragraphs (separate with blank lines)\n   - Bold and italic text where appropriate\n   - Bullet points or numbered lists if needed\n   - Blockquotes for any direct quotes from sources\n\n5. Incorporate information from both the RSS headline/snippet and the Google search content:\n   - Use the headline to guide the main topic\n   - Use the search content to provide additional details and context\n\n6. Maintain a neutral, journalistic tone throughout the article:\n   - Present facts objectively\n   - Do not include personal opinions or biases\n   - Use third-person perspective\n\n7. Structure your article with:\n   - Begin with a TL;DR section. Provide quick bullet points that capture the highlights of the article.\n   - A compelling introduction that summarizes the key points\n   - A conclusion that wraps up the article and potentially suggests future implications\n\n8. If applicable, include:\n   - Relevant statistics or data points\n   - Brief mentions of key stakeholders or experts\n   - Context on why this news is important or impactful\n\n9. Use Wikipedia-style citations in Markdown format:\n   - In the text, use footnote-style references like [^1], [^2], etc.\n   - Use footnotes sequentially without skipping any numbers\n   - At the end of the article, include a ## References section\n   - Format each reference as follows:\n     [^1]: Author Name (if available) (Date). \&quot;[Article Title](URL)\&quot;. Publication Name. Retrieved [Current Date].\n   - If an author name is not available, start with the article title\n   - Ensure all article titles are clickable links using Markdown syntax\n   - Include ALL sources provided in the Google search content in the References section, even if not directly cited in the text\n\n10. Begin your response with &lt;article&gt; and end it with &lt;/article&gt;. The entire article, including the Markdown formatting and references, should be contained within these tags.\n\n11. After the article, provide a brief metadata section with:\n    - Main keywords or tags (do not include links in this section)\n\n12. Double-check your footnotes before completing the article:\n    - Ensure all footnote numbers used in the text have corresponding entries in the References section\n    - Verify that footnote numbers are sequential (1, 2, 3, etc.) without any gaps\n\nRemember to adhere to journalistic standards and ethics in your writing. Stick to the facts presented in the provided sources and avoid sensationalism.&quot;<br>      },<br>      &quot;id&quot;: &quot;947ad72b-ae1a-42b5-b95d-b6224266b432&quot;,<br>      &quot;name&quot;: &quot;Write Article3&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        3300,<br>        800<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;content&quot;: &quot;# WSJ&quot;,<br>        &quot;height&quot;: 80,<br>        &quot;color&quot;: 5<br>      },<br>      &quot;id&quot;: &quot;2462e0a7-9353-4475-a72d-636cbd6013f1&quot;,<br>      &quot;name&quot;: &quot;Sticky Note&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.stickyNote&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        740,<br>        300<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://feeds.a.dj.com/rss/RSSWSJD.xml&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;929c230b-64e3-4aa7-90d4-93efe1896c98&quot;,<br>      &quot;name&quot;: &quot;HTTP Request6&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        1040,<br>        300<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;0cb78450-1740-4990-a195-3a7fb5f36b68&quot;,<br>      &quot;name&quot;: &quot;XML6&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.xml&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1260,<br>        300<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;fieldToSplitOut&quot;: &quot;rss.channel.item&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;1a3e047a-f10c-4131-a6b9-67bbeade641c&quot;,<br>      &quot;name&quot;: &quot;Split Out6&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitOut&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        1480,<br>        300<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;f2843d46-bd8e-4d03-886d-22ee6289f44c&quot;,<br>      &quot;name&quot;: &quot;Loop Over Items&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.splitInBatches&quot;,<br>      &quot;typeVersion&quot;: 3,<br>      &quot;position&quot;: [<br>        1720,<br>        300<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;=https://s.jina.ai/ {{ encodeURIComponent($json.title) }}&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;87bae5cd-0247-4fa0-90e4-d6dd8a2fc827&quot;,<br>      &quot;name&quot;: &quot;JinaAI Search&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3160,<br>        340<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;6079624f-c65a-4a2b-94e5-87c6a72240f0&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3360,<br>        560<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;ai_articles&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;rss_feed_id&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase11&#39;).item.json.id }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Supabase11&#39;).item.json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $(&#39;Write Article&#39;).item.json.text }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;aaac3a9d-2a6d-46c7-b347-b3da0e5c4b40&quot;,<br>      &quot;name&quot;: &quot;Save Article&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        4080,<br>        340<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;model&quot;: &quot;gpt-4o-mini-2024-07-18&quot;,<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;1a5dcc98-6955-4732-8892-e56175f03e7b&quot;,<br>      &quot;name&quot;: &quot;OpenAI Chat Model17&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.lmChatOpenAi&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2400,<br>        600<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;openAiApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;OpenAi&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;title&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.title }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;link&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.link }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;pub_date&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.pubDate }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;content_snippet&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.description }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;=&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;source&quot;,<br>              &quot;fieldValue&quot;: &quot;The Wall Street Journal&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;guid&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.guid._ }}&quot;<br>            },<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;daaa556a-8d84-4e42-843f-afa0ea5acbfe&quot;,<br>      &quot;name&quot;: &quot;Create RSS Item&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2000,<br>        320<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      },<br>      &quot;onError&quot;: &quot;continueRegularOutput&quot;<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.text }}&quot;,<br>              &quot;rightValue&quot;: &quot;true&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;contains&quot;<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;3b5482b7-fb9b-4c80-99e8-e08c9ec6097a&quot;,<br>      &quot;name&quot;: &quot;If - Is AI&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2700,<br>        380<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;conditions&quot;: {<br>          &quot;options&quot;: {<br>            &quot;caseSensitive&quot;: true,<br>            &quot;leftValue&quot;: &quot;&quot;,<br>            &quot;typeValidation&quot;: &quot;strict&quot;<br>          },<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;id&quot;: &quot;8e8ff64b-e59c-415c-af8b-211d7a7d144c&quot;,<br>              &quot;leftValue&quot;: &quot;={{ $json.error }}&quot;,<br>              &quot;rightValue&quot;: &quot;&quot;,<br>              &quot;operator&quot;: {<br>                &quot;type&quot;: &quot;string&quot;,<br>                &quot;operation&quot;: &quot;exists&quot;,<br>                &quot;singleValue&quot;: true<br>              }<br>            }<br>          ],<br>          &quot;combinator&quot;: &quot;and&quot;<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;aef6e1a2-73f5-4907-97f9-fa1a3a25be82&quot;,<br>      &quot;name&quot;: &quot;If - Exists Already&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.if&quot;,<br>      &quot;typeVersion&quot;: 2,<br>      &quot;position&quot;: [<br>        2180,<br>        320<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Create RSS Item&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;should_draft_article&quot;,<br>              &quot;fieldValue&quot;: &quot;True&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;7977b9f2-09da-4ccb-bcda-0d1f928cd3ef&quot;,<br>      &quot;name&quot;: &quot;Supabase11&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        2960,<br>        340<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;url&quot;: &quot;https://www.googleapis.com/customsearch/v1&quot;,<br>        &quot;authentication&quot;: &quot;genericCredentialType&quot;,<br>        &quot;genericAuthType&quot;: &quot;httpQueryAuth&quot;,<br>        &quot;sendQuery&quot;: true,<br>        &quot;queryParameters&quot;: {<br>          &quot;parameters&quot;: [<br>            {<br>              &quot;name&quot;: &quot;q&quot;,<br>              &quot;value&quot;: &quot;={{ $(&#39;Supabase11&#39;).item.json.title }} &quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;cx&quot;,<br>              &quot;value&quot;: &quot;{{ String($(&#39;Globals1&#39;).item.json.google_search_cx).trim() }}&quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;searchType&quot;,<br>              &quot;value&quot;: &quot;image&quot;<br>            },<br>            {<br>              &quot;name&quot;: &quot;num&quot;,<br>              &quot;value&quot;: &quot;1&quot;<br>            }<br>          ]<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;aa933864-42f6-445a-9e40-fabacfa4adc6&quot;,<br>      &quot;name&quot;: &quot;Get Image4&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.httpRequest&quot;,<br>      &quot;typeVersion&quot;: 4.2,<br>      &quot;position&quot;: [<br>        3720,<br>        340<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;httpQueryAuth&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Google Search Key&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;operation&quot;: &quot;update&quot;,<br>        &quot;tableId&quot;: &quot;rss_feed&quot;,<br>        &quot;filters&quot;: {<br>          &quot;conditions&quot;: [<br>            {<br>              &quot;keyName&quot;: &quot;id&quot;,<br>              &quot;condition&quot;: &quot;eq&quot;,<br>              &quot;keyValue&quot;: &quot;={{ $(&#39;Supabase11&#39;).item.json.id }}&quot;<br>            }<br>          ]<br>        },<br>        &quot;fieldsUi&quot;: {<br>          &quot;fieldValues&quot;: [<br>            {<br>              &quot;fieldId&quot;: &quot;img_url&quot;,<br>              &quot;fieldValue&quot;: &quot;={{ $json.items[0].link }}&quot;<br>            }<br>          ]<br>        }<br>      },<br>      &quot;id&quot;: &quot;f57de610-5993-4f60-b8c8-458f1516aee3&quot;,<br>      &quot;name&quot;: &quot;Supabase12&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.supabase&quot;,<br>      &quot;typeVersion&quot;: 1,<br>      &quot;position&quot;: [<br>        3900,<br>        340<br>      ],<br>      &quot;credentials&quot;: {<br>        &quot;supabaseApi&quot;: {<br>          &quot;id&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Supabase&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=Analyze the following article headline and content snippet.  \n\nDetermin if it is AI related.\n\nout put single word as either true or false\n\ndo not output codeblocks or markdown, just the word true or false.\n\n&lt;article_title&gt;\n{{ $(&#39;Create RSS Item&#39;).item.json.title }}\n&lt;/article_title&gt;\n\n&lt;article_snippet&gt;\n{{ $(&#39;Create RSS Item&#39;).item.json.content_snippet }}\n&lt;/article_snippet&gt;&quot;,<br>        &quot;hasOutputParser&quot;: true<br>      },<br>      &quot;id&quot;: &quot;6735df27-f00d-4cac-b8f2-a4ccc7e42350&quot;,<br>      &quot;name&quot;: &quot;Is AI Related&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        2380,<br>        380<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=You are an AI assistant tasked with writing a news article based on an RSS title, content snippet, and reference material from a Google search. Follow these instructions carefully:\n\n1. You will be provided with an RSS title and content snippet from a news feed:\n\n   ```\n   &lt;rss_title&gt;\n  {{ $(&#39;Supabase9&#39;).item.json.title }}\n   &lt;/rss_title&gt;\n\n   &lt;context_snippet&gt;\n  {{ $(&#39;Supabase9&#39;).item.json.content_snippet }}\n   &lt;/context_snippet&gt;\n   ```\n\n2. You will also be given content from a Google search related to the headline:\n\n   ```\n   &lt;google_search_content&gt;\n{{ JSON.stringify($json.data.substring(0, 300000)) }}\n   &lt;/google_search_content&gt;\n   ```\n\n3. Write an article that expands on the RSS headline and content snippet, using information from the Google search content. The article should be:\n   - Anchored on the Title and Context Snippet\n   - Informative\n   - Engaging\n   - Well-structured\n\n4. Format the article using Markdown. Use appropriate Markdown syntax for:\n   - Headings (use ## for the main title, ### for subheadings)\n   - Paragraphs (separate with blank lines)\n   - Bold and italic text where appropriate\n   - Bullet points or numbered lists if needed\n   - Blockquotes for any direct quotes from sources\n\n5. Incorporate information from both the RSS headline/snippet and the Google search content:\n   - Use the headline to guide the main topic\n   - Use the search content to provide additional details and context\n\n6. Maintain a neutral, journalistic tone throughout the article:\n   - Present facts objectively\n   - Do not include personal opinions or biases\n   - Use third-person perspective\n\n7. Structure your article with:\n   - Begin with a TL;DR section. Provide quick bullet points that capture the highlights of the article.\n   - A compelling introduction that summarizes the key points\n   - A conclusion that wraps up the article and potentially suggests future implications\n\n8. If applicable, include:\n   - Relevant statistics or data points\n   - Brief mentions of key stakeholders or experts\n   - Context on why this news is important or impactful\n\n9. Use Wikipedia-style citations in Markdown format:\n   - In the text, use footnote-style references like [^1], [^2], etc.\n   - Use footnotes sequentially without skipping any numbers\n   - At the end of the article, include a ## References section\n   - Format each reference as follows:\n     [^1]: Author Name (if available) (Date). \&quot;[Article Title](URL)\&quot;. Publication Name. Retrieved [Current Date].\n   - If an author name is not available, start with the article title\n   - Ensure all article titles are clickable links using Markdown syntax\n   - Include ALL sources provided in the Google search content in the References section, even if not directly cited in the text\n\n10. Begin your response with &lt;article&gt; and end it with &lt;/article&gt;. The entire article, including the Markdown formatting and references, should be contained within these tags.\n\n11. After the article, provide a brief metadata section with:\n    - Main keywords or tags (do not include links in this section)\n\n12. Double-check your footnotes before completing the article:\n    - Ensure all footnote numbers used in the text have corresponding entries in the References section\n    - Verify that footnote numbers are sequential (1, 2, 3, etc.) without any gaps\n\nRemember to adhere to journalistic standards and ethics in your writing. Stick to the facts presented in the provided sources and avoid sensationalism.&quot;<br>      },<br>      &quot;id&quot;: &quot;e5cabf00-0a9c-475a-ac0f-7f7085972ce2&quot;,<br>      &quot;name&quot;: &quot;Write Article8&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        3380,<br>        -180<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;promptType&quot;: &quot;define&quot;,<br>        &quot;text&quot;: &quot;=You are an AI assistant tasked with writing a news article based on an RSS title, context snippet, and reference material from a Google search. Follow these instructions carefully:\n\n1. You will be provided with an RSS title and content snippet from a news feed:\n\n   ```\n   &lt;rss_title&gt;\n  {{ $(&#39;Supabase11&#39;).item.json.title }}\n   &lt;/rss_title&gt;\n\n   &lt;context_snippet&gt;\n  {{ $(&#39;Supabase11&#39;).item.json.content_snippet }}\n   &lt;/context_snippet&gt;\n   ```\n\n2. You will also be given content from a Google search related to the headline:\n\n   ```\n   &lt;google_search_content&gt;\n{{ JSON.stringify($json.data.substring(0, 300000)) }}\n   &lt;/google_search_content&gt;\n   ```\n\n3. Write an article that expands on the RSS headline and content snippet, using information from the Google search content. The article should be:\n   - Anchored on the Title and Context Snippet\n   - Informative\n   - Engaging\n   - Well-structured\n\n4. Format the article using Markdown. Use appropriate Markdown syntax for:\n   - Headings (use ## for the main title, ### for subheadings)\n   - Paragraphs (separate with blank lines)\n   - Bold and italic text where appropriate\n   - Bullet points or numbered lists if needed\n   - Blockquotes for any direct quotes from sources\n\n5. Incorporate information from both the RSS headline/snippet and the Google search content:\n   - Use the headline to guide the main topic\n   - Use the search content to provide additional details and context\n\n6. Maintain a neutral, journalistic tone throughout the article:\n   - Present facts objectively\n   - Do not include personal opinions or biases\n   - Use third-person perspective\n\n7. Structure your article with:\n   - Begin with a TL;DR section. Provide quick bullet points that capture the highlights of the article.\n   - A compelling introduction that summarizes the key points\n   - A conclusion that wraps up the article and potentially suggests future implications\n\n8. If applicable, include:\n   - Relevant statistics or data points\n   - Brief mentions of key stakeholders or experts\n   - Context on why this news is important or impactful\n\n9. Use Wikipedia-style citations in Markdown format:\n   - In the text, use footnote-style references like [^1], [^2], etc.\n   - Use footnotes sequentially without skipping any numbers\n   - At the end of the article, include a ## References section\n   - Format each reference as follows:\n     [^1]: Author Name (if available) (Date). \&quot;[Article Title](URL)\&quot;. Publication Name. Retrieved [Current Date].\n   - If an author name is not available, start with the article title\n   - Ensure all article titles are clickable links using Markdown syntax\n   - Include ALL sources provided in the Google search content in the References section, even if not directly cited in the text\n\n10. Begin your response with &lt;article&gt; and end it with &lt;/article&gt;. The entire article, including the Markdown formatting and references, should be contained within these tags.\n\n11. After the article, provide a brief metadata section with:\n    - Main keywords or tags (do not include links in this section)\n\n12. Double-check your footnotes before completing the article:\n    - Ensure all footnote numbers used in the text have corresponding entries in the References section\n    - Verify that footnote numbers are sequential (1, 2, 3, etc.) without any gaps\n\nRemember to adhere to journalistic standards and ethics in your writing. Stick to the facts presented in the provided sources and avoid sensationalism.&quot;<br>      },<br>      &quot;id&quot;: &quot;dcda847d-aeac-4fef-8e88-5704506af2ce&quot;,<br>      &quot;name&quot;: &quot;Write Article&quot;,<br>      &quot;type&quot;: &quot;@n8n/n8n-nodes-langchain.chainLlm&quot;,<br>      &quot;typeVersion&quot;: 1.4,<br>      &quot;position&quot;: [<br>        3360,<br>        340<br>      ]<br>    },<br>    {<br>      &quot;parameters&quot;: {<br>        &quot;assignments&quot;: {<br>          &quot;assignments&quot;: [<br>            {<br>              &quot;id&quot;: &quot;62266f8c-0f97-494a-adb6-4b5c082cc1c1&quot;,<br>              &quot;name&quot;: &quot;google_search_cx&quot;,<br>              &quot;value&quot;: &quot;&quot;,<br>              &quot;type&quot;: &quot;string&quot;<br>            }<br>          ]<br>        },<br>        &quot;options&quot;: {}<br>      },<br>      &quot;id&quot;: &quot;2b0fe2a4-36ee-4a38-9642-269e9cf8b283&quot;,<br>      &quot;name&quot;: &quot;Globals1&quot;,<br>      &quot;type&quot;: &quot;n8n-nodes-base.set&quot;,<br>      &quot;typeVersion&quot;: 3.4,<br>      &quot;position&quot;: [<br>        500,<br>        -320<br>      ]<br>    }<br>  ],<br>  &quot;connections&quot;: {<br>    &quot;HTTP Request1&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;XML1&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;XML1&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Split Out1&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Split Out1&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Loop Over Items2&quot;: {<br>      &quot;main&quot;: [<br>        null,<br>        [<br>          {<br>            &quot;node&quot;: &quot;Create RSS Item2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;JinaAI Search3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model5&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article3&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Save Article3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model6&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related2&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Create RSS Item2&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Exists Already2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Is AI2&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Exists Already2&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;JinaAI Search3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Schedule Trigger&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Globals1&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Is AI Related2&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Is AI2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;HTTP Request&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;XML&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;XML&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Split Out&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Split Out&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Loop Over Items3&quot;: {<br>      &quot;main&quot;: [<br>        null,<br>        [<br>          {<br>            &quot;node&quot;: &quot;Extract Img and Description&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;JinaAI Search4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model7&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article4&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Save Article4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model8&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related3&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Create RSS Item3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Exists Already3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Is AI3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Exists Already3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;JinaAI Search4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Is AI Related3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Is AI3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Extract Img and Description&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Create RSS Item3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Write Article4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Save Article4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;HTTP Request2&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;XML2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;XML2&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Split Out2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Split Out2&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Loop Over Items4&quot;: {<br>      &quot;main&quot;: [<br>        null,<br>        [<br>          {<br>            &quot;node&quot;: &quot;Create RSS Item4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;JinaAI Search5&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article5&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model9&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article5&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model10&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related4&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Create RSS Item4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Exists Already4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Is AI4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase5&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Exists Already4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase5&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;JinaAI Search5&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Is AI Related4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Is AI4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Write Article5&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Get Image&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Save Article5&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Get Image&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase6&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase6&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Save Article5&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;HTTP Request5&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;XML5&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;XML5&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Split Out5&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Split Out5&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Loop Over Items7&quot;: {<br>      &quot;main&quot;: [<br>        null,<br>        [<br>          {<br>            &quot;node&quot;: &quot;Create RSS Item7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;JinaAI Search8&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article8&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model15&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article8&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Save Article8&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model16&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related7&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Create RSS Item7&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Exists Already7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Is AI7&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase9&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Exists Already7&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase9&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;JinaAI Search8&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Get Image3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase10&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase10&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Save Article8&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Is AI Related7&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Is AI7&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Write Article3&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Save Article3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;HTTP Request6&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;XML6&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;XML6&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Split Out6&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Split Out6&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Loop Over Items&quot;: {<br>      &quot;main&quot;: [<br>        null,<br>        [<br>          {<br>            &quot;node&quot;: &quot;Create RSS Item&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;JinaAI Search&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Write Article&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Save Article&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;OpenAI Chat Model17&quot;: {<br>      &quot;ai_languageModel&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related&quot;,<br>            &quot;type&quot;: &quot;ai_languageModel&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Create RSS Item&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Exists Already&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Is AI&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase11&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          },<br>          {<br>            &quot;node&quot;: &quot;JinaAI Search&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;If - Exists Already&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Loop Over Items&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ],<br>        [<br>          {<br>            &quot;node&quot;: &quot;Is AI Related&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase11&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;JinaAI Search&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Get Image4&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Supabase12&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Supabase12&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Save Article&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Is AI Related&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;If - Is AI&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Write Article8&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Get Image3&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Write Article&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;Get Image4&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    },<br>    &quot;Globals1&quot;: {<br>      &quot;main&quot;: [<br>        [<br>          {<br>            &quot;node&quot;: &quot;HTTP Request5&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          },<br>          {<br>            &quot;node&quot;: &quot;HTTP Request6&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          },<br>          {<br>            &quot;node&quot;: &quot;HTTP Request1&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          },<br>          {<br>            &quot;node&quot;: &quot;HTTP Request&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          },<br>          {<br>            &quot;node&quot;: &quot;HTTP Request2&quot;,<br>            &quot;type&quot;: &quot;main&quot;,<br>            &quot;index&quot;: 0<br>          }<br>        ]<br>      ]<br>    }<br>  },<br>  &quot;pinData&quot;: {}<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40cf3753a387" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Another WYSIWYG Editor: Biting the Bullet and Implementing TipTap]]></title>
            <link>https://medium.com/@learningsomethingnew/another-wysiwyg-editor-biting-the-bullet-and-implementing-tiptap-9640c8348227?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/9640c8348227</guid>
            <category><![CDATA[wysiwyg]]></category>
            <category><![CDATA[tiptap-editor]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Wed, 07 Aug 2024 22:01:30 GMT</pubDate>
            <atom:updated>2024-08-07T22:01:30.545Z</atom:updated>
            <content:encoded><![CDATA[<p>After implementing hasty versions of various WYSIWYG options across a few projects that always left me “underwhelmed” I decided to set aside 24 hours to implement a version I can start leveraging and build out further…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbQFi13bd7ZDpx8MqJFQiA.png" /><figcaption>What we’re building!</figcaption></figure><h3>Introduction: Finally Creating my WYSIWYG</h3><p>Hey there! Today, we’re diving into the wild world of WYSIWYG editors. You know, those magical text boxes that let you format your words without feeling like you’re decoding the Matrix.</p><p>The repo is <a href="https://github.com/joeBlockchain/wysiwyg-ai-080624/tree/main/src/components/TipTapEditor">here…</a> but if your curious in Claude 3.5 Sonnet explaininng the code with some jokes sprinkled in… read on!</p><p>So, picture this: you’re building a web app, and you think, “Hey, I’ll just slap in a textarea and call it a day!” Oh, sweet summer child. That’s like telling your kids you’re taking them to Disneyland and then driving them to the local playground. Sure, it’s technically a place to have fun, but it’s not exactly the magical kingdom they were expecting!</p><p>I’ve been there, folks. I’ve hastily overlooked the complexity of text editors more times than I’ve told my kids that the ice cream truck only plays music when it’s out of ice cream. (Pro tip: They eventually figure that one out.) But let me tell you, a proper WYSIWYG editor is more helpful than a GPS in a corn maze — and trust me, I’ve needed both!</p><p>After realizing that a simple editable div from <a href="https://ui.shadcn.com/">shadcn/ui</a> was about as useful as a screen door on a submarine, I decided it was time to create a comprehensive solution. Thats not entirely fair, the <a href="https://ui.shadcn.com/docs/components/textarea">Textarea</a> is helpful for what it does, but I had severely abused it’s relative utility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U2EmYNK53iCfwCsZ0cyC7w.png" /><figcaption>shadcn/ui Textarea… sure it works in a pinch</figcaption></figure><p>Enter <a href="https://tiptap.dev/">TipTap</a>— the framework built from <a href="https://prosemirror.net/docs/ref/">ProseMirror</a> that’s about to make our WYSIWYG dreams come true faster!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1GiKl1Ph4rXgQJVBP0U6wQ.png" /><figcaption>TipTap to the Rescue</figcaption></figure><p>So, what’s on the menu for this WYSIWYG feast? We’re talking a smorgasbord of features that’ll make your text shine brighter than my bald spot in the summer sun:</p><ul><li>Rich text formatting (because plain text is as boring as my jokes, according to my kids)</li><li>Code blocks with syntax highlighting (for when you want to show off your coding skills and make the rest of us feel inadequate)</li><li>Task lists (perfect for listing all the dad jokes your family begs you not to tell)</li><li>And more bells and whistles than a locomotive conductor’s birthday party!</li></ul><p>Stick around, and I promise you’ll learn how to implement a WYSIWYG editor that’s so good, your users will think it’s magic — or at least as magical as me making vegetables “disappear” from my plate when the kids aren’t looking. Let’s dive in!</p><h3>Setting Up the Foundation: TipTap and React Integration</h3><p>Alright, folks! Now that we’ve decided to embark on this WYSIWYG adventure, it’s time to lay down the foundation. Much like how I prepare to tell my kids a new dad joke — with excitement, anticipation, and the knowledge that eye-rolls are imminent — we’re going to set up TipTap with React and Next.js.</p><p>First things first, let’s get our ingredients together. We’ll need TipTap, React, and Next.js — a combination more powerful than my “Hi Hungry, I’m Dad” joke at the dinner table. Here’s how we start cooking:</p><pre>npm install @tiptap/react @tiptap/starter-kit @tiptap/extension-color @tiptap/extension-text-style</pre><p>Now, let’s whip up the base of our WYSIWYG editor. It’s like making a sandwich — you need a good foundation, or everything falls apart faster than my kids’ attention span when I start talking about the good old days.</p><pre>import { EditorProvider } from &#39;@tiptap/react&#39;<br>import StarterKit from &#39;@tiptap/starter-kit&#39;<br><br>const extensions = [<br>  StarterKit,<br>  // More extensions to come, like my endless supply of weather puns<br>]<br>const content = &#39;&lt;p&gt;Hello, World! 👋&lt;/p&gt;&#39;<br>const TipTapEditor = () =&gt; {<br>  return (<br>    &lt;EditorProvider extensions={extensions} content={content}&gt;<br>      {/* Our editor will go here, like where my dad jokes go to die */}<br>    &lt;/EditorProvider&gt;<br>  )<br>}</pre><p>This TipTapEditor component is the heart of our operation. It&#39;s like the remote control to the TV – everything important happens here, but sometimes it&#39;s frustratingly complex and you can&#39;t find the button you need.</p><p>Now, let’s talk about these extensions. The StarterKit is like the Swiss Army knife of TipTap – it&#39;s got all the basic tools you need to get started. But we&#39;re not stopping there! Oh no, we&#39;re going to add more extensions than I have excuses for being late to family gatherings.</p><p>Here’s a beefed-up version of our extensions array:</p><pre>import { Color } from &#39;@tiptap/extension-color&#39;<br>import ListItem from &#39;@tiptap/extension-list-item&#39;<br>import TextStyle from &#39;@tiptap/extension-text-style&#39;<br><br>const extensions = [<br>  StarterKit.configure({<br>    bulletList: {<br>      keepMarks: true,<br>      keepAttributes: false, // TODO: Figure out why this is false, like why my jokes fall flat<br>    },<br>    orderedList: {<br>      keepMarks: true,<br>      keepAttributes: false,<br>    },<br>  }),<br>  Color.configure({ types: [TextStyle.name, ListItem.name] }),<br>  TextStyle,<br>  // More extensions to come, like my expanding waistline<br>]</pre><p>Each of these extensions adds a new feature to our editor, kind of like how each of my dad jokes adds a new level of embarrassment for my children. The Color extension lets us change text colors, ListItem helps with, well, list items, and TextStyle allows for inline text styling. It&#39;s a real party in there!</p><p>Now, you might be wondering, “But wait, where’s the actual editor? Where do I type my groundbreaking novel or my list of increasingly desperate dad jokes?” Fear not! In the next section, we’ll dive into creating a toolbar that would make even the most seasoned handyman jealous. We’ll be adding buttons, dropdowns, and more features than you can shake a stick at (which, coincidentally, is my favorite form of exercise).</p><p>Stay tuned, folks! The next part is where the magic really happens — or at least where we pretend it does, much like how I pretend to know what I’m doing when I attempt home repairs. Until then, keep your code clean and your puns ready!</p><h3>Building the Toolbar: A Comprehensive Formatting Suite</h3><p>Alright, buckle up, buttercup! We’re about to dive into creating a toolbar that’s more loaded than a baked potato at a steakhouse. This toolbar is going to have more buttons than my shirt after Thanksgiving dinner, and it’s going to be just as satisfying to use.</p><p>First things first, let’s create our MenuBar component. This bad boy is going to be the control center of our WYSIWYG editor, like the remote control that always seems to disappear into the couch cushions.</p><pre>const MenuBar = () =&gt; {<br>  const { editor } = useCurrentEditor()<br><br>if (!editor) {<br>    return null<br>  }<br>  return (<br>    &lt;div className=&quot;menu-bar&quot;&gt;<br>      {/* We&#39;ll stuff this fuller than a turducken */}<br>    &lt;/div&gt;<br>  )<br>}</pre><p>Now, let’s start adding some buttons. We’ll use the Toggle component from our UI library, which is more versatile than my excuses for forgetting to take out the trash.</p><pre>import { Toggle } from &quot;../ui/toggle&quot;;<br>import { Bold, Italic, Strikethrough /* ... */ } from &quot;lucide-react&quot;;<br><br>// Inside MenuBar component<br>&lt;Toggle<br>  onClick={() =&gt; editor.chain().focus().toggleBold().run()}<br>  disabled={!editor.can().chain().focus().toggleBold().run()}<br>  pressed={editor.isActive(&quot;bold&quot;)}<br>  className=&quot;p-[.35rem] m-0 h-fit w-fit&quot;<br>&gt;<br>  &lt;Bold className=&quot;w-5 h-5 flex-none&quot; /&gt;<br>&lt;/Toggle&gt;</pre><p>This Toggle component is like the Swiss Army knife of UI elements. It&#39;s got more features than my attempts at multitasking (which usually ends with burnt dinner and unfolded laundry).</p><p>We’ll add similar toggles for italic, strikethrough, and other basic formatting options. It’s like giving your text a makeover, but without the awkward “does this font make me look fat?” questions.</p><p>Now, let’s spice things up with some dropdowns. We’ll use the Select component for things like text color and highlight color:</p><pre>import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from &quot;../ui/select&quot;;<br><br>// Inside MenuBar component<br>&lt;Select<br>  value={editor.getAttributes(&quot;textStyle&quot;).color || &quot;default&quot;}<br>  onValueChange={(color) =&gt; editor.chain().focus().setColor(color).run()}<br>&gt;<br>  &lt;SelectTrigger className=&quot;w-fit pr-4 bg-secondary&quot;&gt;<br>    &lt;SelectValue placeholder=&quot;Color&quot; /&gt;<br>  &lt;/SelectTrigger&gt;<br>  &lt;SelectContent&gt;<br>    &lt;SelectItem value=&quot;#e11d48&quot;&gt;Rose&lt;/SelectItem&gt;<br>    &lt;SelectItem value=&quot;#7c3aed&quot;&gt;Violet&lt;/SelectItem&gt;<br>    {/* More colors than my attempts at painting the living room */}<br>  &lt;/SelectContent&gt;<br>&lt;/Select&gt;</pre><p>This color picker is like a box of crayons for grown-ups. Now your users can make their text more colorful than my language when I step on a Lego.</p><p>But wait, there’s more! We’re going to add buttons for all sorts of formatting options:</p><pre>&lt;Toggle<br>  onClick={() =&gt; editor.chain().focus().toggleHeading({ level: 1 }).run()}<br>  pressed={editor.isActive(&quot;heading&quot;, { level: 1 })}<br>&gt;<br>  &lt;Heading1 className=&quot;w-5 h-5 flex-none&quot; /&gt;<br>&lt;/Toggle&gt;<br><br>&lt;Toggle<br>  onClick={() =&gt; editor.chain().focus().toggleBulletList().run()}<br>  pressed={editor.isActive(&quot;bulletList&quot;)}<br>&gt;<br>  &lt;List className=&quot;w-5 h-5 flex-none&quot; /&gt;<br>&lt;/Toggle&gt;<br>&lt;Toggle<br>  onClick={() =&gt; editor.chain().focus().setTextAlign(&quot;left&quot;).run()}<br>  pressed={editor.isActive({ textAlign: &quot;left&quot; })}<br>&gt;<br>  &lt;AlignLeft className=&quot;w-5 h-5 flex-none&quot; /&gt;<br>&lt;/Toggle&gt;</pre><p>We’ve got headings, lists, text alignment… this toolbar has more options than I have excuses for why I haven’t fixed that leaky faucet yet.</p><p>And let’s not forget about our code block feature. We’ll add a button that’s more exciting than finding an extra fry at the bottom of the bag:</p><pre>&lt;Toggle<br>  onClick={() =&gt; editor.chain().focus().toggleCodeBlock().run()}<br>  pressed={editor.isActive(&quot;codeBlock&quot;)}<br>&gt;<br>  &lt;CodeXml className=&quot;w-5 h-5 flex-none&quot; /&gt;<br>&lt;/Toggle&gt;</pre><p>Now your users can add code blocks faster than I can come up with a dad joke about programming. (Why do programmers prefer dark mode? Because light attracts bugs!)</p><p>Finally, we’ll wrap all these buttons in some fancy Alert components to group them nicely:</p><pre>&lt;Alert className=&quot;flex flex-row p-1 m-0 h-fit w-fit gap-1&quot;&gt;<br>  {/* Stuff more buttons in here than a teenager&#39;s first suit */}<br>&lt;/Alert&gt;</pre><p>And there you have it! A toolbar that’s more feature-packed than a Swiss Army knife at a gadget convention. Your users will have more formatting options than I have grey hairs (and trust me, that’s a lot).</p><p>In the next section, we’ll dive into some of the more advanced features of our editor. It’ll be more exciting than watching paint dry… which, coincidentally, is what I told my kids we were doing last weekend for “fun”. Stay tuned!</p><h3>Advanced Features: Code Blocks, Syntax Highlighting, and More</h3><p>Alright, folks, strap in! We’re about to take this WYSIWYG editor from 0 to 60 faster than I can embarrass my kids in public (which, let me tell you, is pretty darn fast). We’re diving into the advanced features that’ll make your editor cooler than the other side of the pillow.</p><p>First up, let’s talk about code blocks with syntax highlighting. This feature is more impressive than my ability to fall asleep during any movie my family wants to watch.</p><p>To get started, we need to invite some new friends to our coding party:</p><pre>npm install @tiptap/extension-code-block-lowlight lowlight</pre><p>Now, let’s set up our code block extension:</p><pre>import CodeBlockLowlight from &#39;@tiptap/extension-code-block-lowlight&#39;<br>import { createLowlight, all } from &#39;lowlight&#39;<br><br>const lowlight = createLowlight(all)<br>const extensions = [<br>  // ... other extensions<br>  CodeBlockLowlight.extend({<br>    addNodeView() {<br>      return ReactNodeViewRenderer(CodeBlockComponent)<br>    },<br>  }).configure({ lowlight }),<br>]</pre><p>This setup is like adding a turbo booster to your family minivan. Suddenly, your boring old text editor can handle code with more style than I handle a dad joke punchline.</p><p>Now, let’s create our CodeBlockComponent. This bad boy is going to be more functional than my attempts at DIY home improvement:</p><pre>const CodeBlockComponent = ({ node, updateAttributes, extension }: any) =&gt; {<br>  const [copied, setCopied] = useState(false);<br><br>const selectLanguage = (language: string) =&gt; {<br>    updateAttributes({ language });<br>  };<br>  const copyCode = () =&gt; {<br>    navigator.clipboard.writeText(node.textContent);<br>    setCopied(true);<br>    setTimeout(() =&gt; setCopied(false), 2000);<br>  };<br>  return (<br>    &lt;NodeViewWrapper className=&quot;relative&quot;&gt;<br>      &lt;pre className=&quot;rounded-md&quot;&gt;<br>        &lt;NodeViewContent as=&quot;code&quot; /&gt;<br>      &lt;/pre&gt;<br>      &lt;div className=&quot;absolute top-2 right-2 flex items-center space-x-2&quot;&gt;<br>        &lt;Select<br>          value={node.attrs.language || &quot;auto&quot;}<br>          onValueChange={selectLanguage}<br>        &gt;<br>          &lt;SelectTrigger className=&quot;w-fit pr-4 bg-secondary&quot;&gt;<br>            &lt;SelectValue placeholder=&quot;Language&quot; /&gt;<br>          &lt;/SelectTrigger&gt;<br>          &lt;SelectContent&gt;<br>            &lt;SelectItem value=&quot;auto&quot;&gt;Auto&lt;/SelectItem&gt;<br>            {extension.options.lowlight.listLanguages().map((lang: string) =&gt; (<br>              &lt;SelectItem key={lang} value={lang}&gt;{lang}&lt;/SelectItem&gt;<br>            ))}<br>          &lt;/SelectContent&gt;<br>        &lt;/Select&gt;<br>        &lt;Button variant=&quot;secondary&quot; onClick={copyCode}&gt;<br>          {copied ? &lt;Check className=&quot;h-4 w-4&quot; /&gt; : &lt;Copy className=&quot;h-4 w-4&quot; /&gt;}<br>        &lt;/Button&gt;<br>      &lt;/div&gt;<br>    &lt;/NodeViewWrapper&gt;<br>  );<br>};</pre><p>This component is like the Swiss Army knife of code blocks. It’s got language selection smoother than my attempts at dancing at weddings, and a copy button more useful than my “Pull my finger” joke at family gatherings.</p><p>But wait, there’s more! Let’s talk about task lists. These are perfect for when you want to make a to-do list of all the dad jokes you haven’t told yet:</p><pre>import TaskList from &#39;@tiptap/extension-task-list&#39;<br>import TaskItem from &#39;@tiptap/extension-task-item&#39;<br><br>const extensions = [<br>  // ... other extensions<br>  TaskList,<br>  TaskItem.configure({<br>    nested: true,<br>  }),<br>]</pre><p>With this setup, your users can create task lists faster than I can come up with excuses for why I haven’t mowed the lawn.</p><p>Now, let’s add some pizzazz with text alignment. This feature is more versatile than my collection of Hawaiian shirts:</p><pre>import TextAlign from &#39;@tiptap/extension-text-align&#39;<br><br>const extensions = [<br>  // ... other extensions<br>  TextAlign.configure({<br>    types: [&#39;heading&#39;, &#39;paragraph&#39;],<br>  }),</pre><p>Your users can now align their text left, right, or center, giving them more control than I have over my dad bod.</p><p>Last but not least, let’s talk about link insertion. This feature is more clickable than those ads promising to reveal Hollywood’s best-kept secrets:</p><pre>const setLink = useCallback(() =&gt; {<br>  const url = window.prompt(&#39;URL&#39;)<br>  if (url) {<br>    editor.chain().focus().setLink({ href: url }).run()<br>  } else {<br>    editor.chain().focus().unsetLink().run()<br>  }<br>}, [editor])<br><br>// In your toolbar<br>&lt;Button onClick={setLink} disabled={!editor.can().setLink()}&gt;<br>  &lt;Link2 className=&quot;w-5 h-5&quot; /&gt;<br>&lt;/Button&gt;</pre><p>Now your users can insert links faster than I can insert myself into my kids’ conversations with their friends (much to their eternal embarrassment).</p><p>And there you have it, folks! We’ve added more features to this editor than I have grey hairs (and trust me, that’s a lot). Your WYSIWYG editor is now equipped with code blocks that would make any developer jealous, task lists to organize your life (or procrastinate more efficiently), text alignment to satisfy your inner designer, and link insertion to connect your content to the vast world of the internet.</p><p>In our next and final section, we’ll wrap things up and look towards the future. We’ll discuss potential improvements that could make this editor even more powerful than my dad-joke game (if that’s even possible). Stay tuned!</p><h3>Conclusion: Reflections and Future Improvements</h3><p>Well, folks, we’ve reached the end of our WYSIWYG adventure. It’s been a wild ride, hasn’t it? We’ve created an editor more feature-packed than my toolbox (and probably more useful, too). Let’s take a moment to reflect on our achievements, much like I reflect on my glory days of high school sports… except our editor actually has a future!</p><p>In just 24 hours, we’ve managed to build a text editor that would make even the most seasoned web developer say, “Wow, that’s more impressive than a dad’s ability to embarrass his kids in public!” Let’s recap our key achievements:</p><ol><li>We set up a solid foundation with TipTap and React, creating a base as sturdy as my dad jokes are cringeworthy.</li><li>We built a toolbar with more buttons than a NASA control panel, giving users more formatting options than I have excuses for being late to family dinners.</li><li>We implemented advanced features like code blocks with syntax highlighting, task lists, and text alignment, making our editor more versatile than my collection of “World’s Best Dad” mugs.</li></ol><p>Our editor is now capable of handling everything from simple notes to complex documents with code snippets. It’s so feature-rich, it makes a Swiss Army knife look like a plastic spoon!</p><p>But as my kids always say when I try to be “hip and cool” — “Dad, you’re not done embarrassing us yet?” And they’re right (about the editor, not about me being embarrassing… I hope). There’s always room for improvement!</p><p>Here’s a sneak peek at some future enhancements we could add:</p><ol><li><strong>AI Features</strong>: Imagine an AI assistant that could help with writing, much like how I “help” my kids with their homework. (Spoiler: They usually end up teaching me.)</li><li><strong>Image Support</strong>: Let users add images to their documents. It’ll be easier than adding vegetables to my kids’ diets!</li><li><strong>Table Support</strong>: Because sometimes you need to organize information in rows and columns, like my ever-growing list of dad jokes categorized by levels of eye-rolling they induce.</li><li><strong>Collaborative Editing</strong>: Allow multiple users to edit the same document simultaneously. It’ll be like when the whole family tries to decide on a restaurant, but hopefully with less arguing.</li><li><strong>Dark Mode</strong>: Because sometimes you need to write in the dark, like when you’re jotting down dad joke ideas at 3 AM.</li><li><strong>Mobile Optimization</strong>: Make the editor responsive for mobile devices. It should adapt faster than I do to new technology (which, admittedly, isn’t saying much).</li><li><strong>Undo/Redo History</strong>: A feature more useful than my ability to remember where I left my car keys.</li><li><strong>Export Options</strong>: Allow users to export their masterpieces in various formats. It’ll be like sharing my dad jokes, but people might actually want to save these.</li></ol><p>Remember, implementing a WYSIWYG editor is a journey, not a destination. It’s like parenting — just when you think you’ve got it figured out, something new comes along to challenge you. (Usually in the form of a new social media platform I need to embarrass my kids on.)</p><p>So, I encourage you all to take this editor, experiment with it, and make it your own. Add features, remove ones you don’t need, or completely revamp it. The possibilities are as endless as my supply of dad jokes!</p><p>And speaking of experiments, why not try building your own WYSIWYG editor? It’s a great way to learn about text manipulation, React components, and how to create user interfaces that don’t make people want to pull their hair out (unlike my dance moves at family weddings).</p><p>In conclusion, remember that every great project starts with a single line of code, much like every great dad joke starts with a single groan. So get out there, start coding, and may your editors be bug-free and your jokes be groan-worthy!</p><p>Now, if you’ll excuse me, I have some urgent dad business to attend to. I heard someone say they’re hungry, and I can’t miss an opportunity like that!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9640c8348227" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Your Own AI Image Generator: Utilizing Stability AI endpoints]]></title>
            <link>https://medium.com/@learningsomethingnew/building-your-own-ai-image-generator-utilizing-stability-ai-endpoints-e0b968feba1b?source=rss-6c8f72bf7e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0b968feba1b</guid>
            <category><![CDATA[midjourney]]></category>
            <category><![CDATA[stability-ai]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Joe Taylor]]></dc:creator>
            <pubDate>Sat, 03 Aug 2024 00:13:49 GMT</pubDate>
            <atom:updated>2024-08-03T01:40:27.337Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Your Own AI Image Generator: Utilizing Stability AI Endpoints</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wB9U-VASiEftJ323hBI6_g.png" /><figcaption>CreateArt-AI User Interface</figcaption></figure><h3>Introduction: The Rise of AI-Powered Image Generation</h3><p>Image options:</p><ol><li>A split-screen showing a human artist painting on one side and an AI-generated artwork on the other.</li><li>A futuristic workspace with holographic displays showing AI-generated images.</li><li>A timeline graphic showing the evolution from traditional art to digital art to AI-generated art.</li></ol><p>Description: An image that visually represents the evolution or comparison between traditional art creation and AI-powered image generation.</p><p>The applications for AI-generated images are vast and growing by the day. From enhancing blog posts and social media content to creating stunning visuals for corporate presentations and breathing life into children’s books, AI-generated images are becoming an indispensable tool for content creators of all stripes.</p><p>As someone who enjoys sketching with pencil and paper, I’ve often found myself in situations where I needed a high-quality image quickly, but creating it from scratch wasn’t feasible due to time constraints or the complexity of the desired image. This is a common pain point for many creators, whether they’re artists, marketers, or educators.</p><p>Traditional stock image platforms, while useful, often fall short when it comes to finding that perfect, specific image you have in mind. The search process can be tedious, and more often than not, the exact image you’re envisioning simply doesn’t exist in their vast libraries.</p><p>This is where AI image generation truly shines. With the ability to prompt an AI system to create exactly what you’re looking for, the possibilities are virtually limitless. Need a picture of a cat riding a unicycle on Mars? No problem! Want to visualize a futuristic cityscape with floating gardens? The AI has got you covered.</p><p>One of the most appealing aspects of AI-generated images is their flexibility. If the initial output isn’t quite right, it’s easy to tweak the prompt or use image editing tools to refine the result. In my experience, about 90% of the time, the AI-generated image fits the bill right out of the box, saving valuable time and resources.</p><p>Motivated by the potential of this technology and the need for a more streamlined, customizable solution, I set out to build my own AI-powered image generation tool. In the following sections, I’ll walk you through my journey, from setting up the development environment to implementing advanced features that enhance the user experience.</p><p>Whether you’re a fellow developer looking to integrate AI into your projects, a content creator seeking to expand your toolkit, or simply someone curious about the intersection of AI and creativity, I hope you’ll find valuable insights in this exploration of AI-powered image generation.</p><h3>Setting Up the Development Environment</h3><p>Before we dive into the exciting world of AI-powered image generation, we need to set the stage with a robust development environment. In this section, we’ll walk through the process of setting up the necessary tools and technologies to build our application.</p><h3>Harness the Power of AI to Create, Edit, and Innovate with Images</h3><p>In this guide, we’ll walk you through the process of building a cutting-edge AI image generation tool using React, Next.js, and the Stability AI API. Whether you’re a seasoned developer looking to integrate AI into your projects or a curious coder eager to explore the frontiers of creative technology, this tutorial will equip you with the knowledge and skills to bring your ideas to life.</p><h3>What You’ll Learn:</h3><ol><li><strong>Setting Up Your Development Environment</strong>: Configure a modern tech stack with React, Next.js, and Supabase for a robust foundation.</li><li><strong>Core Image Generation Functionality</strong>: Implement prompt-based image creation using the Stability AI API.</li><li><strong>Advanced UI Components</strong>: Build intuitive interfaces for style presets, aspect ratio selection, and prompt input.</li><li><strong>Backend API Integration</strong>: Create efficient server-side routes to handle complex image operations.</li><li><strong>Enhanced Image Manipulation</strong>: Add features like background removal and search-and-replace functionality.</li><li><strong>Responsive Design Principles</strong>: Ensure your application looks great on devices of all sizes.</li><li><strong>Performance Optimization</strong>: Implement infinite scrolling for smooth browsing of generated images.</li><li><strong>AI Integration Best Practices</strong>: Learn tips and tricks for effectively incorporating AI services into web applications.</li><li><strong>Future-Proofing Your Skills</strong>: Explore potential applications and extensions of AI image generation technology.</li></ol><p>By the end of this tutorial, you’ll have a fully functional AI image generation tool and the knowledge to customize and expand its capabilities. Get ready to unleash your creativity and dive into the exciting world of AI-powered image creation!</p><h3>Required Technologies</h3><p>For this project, we’ll be using a modern and powerful tech stack:</p><ol><li><strong>React</strong>: A popular JavaScript library for building user interfaces</li><li><strong>Next.js</strong>: A React framework that enables server-side rendering and provides an intuitive routing system</li><li><strong>Supabase</strong>: An open-source Firebase alternative that provides a backend-as-a-service with built-in authentication and database management</li><li><strong>Stability AI API</strong>: We’ll be using this to interact with state-of-the-art image generation models</li></ol><h3>Initial Project Setup</h3><p>Let’s start by setting up our Next.js project with TypeScript support:</p><pre>npx create-next-app@latest ai-image-generator --typescript<br>cd ai-image-generator</pre><p>Next, we’ll install the necessary dependencies:</p><pre>npm install @supabase/supabase-js react-hook-form @radix-ui/react-popover</pre><h3>Configuring Supabase</h3><p>To set up Supabase, we’ll create a new project in the Supabase dashboard and add the project URL and anon key to our environment variables. Create a .env.local file in your project root and add:</p><pre>NEXT_PUBLIC_SUPABASE_URL=your-project-url<br>NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key</pre><p>Then, create a utility file to initialize the Supabase client:</p><pre>// utils/supabase/client.ts<br>import { createClient } from &#39;@supabase/supabase-js&#39;<br>export const supabase = createClient(<br>  process.env.NEXT_PUBLIC_SUPABASE_URL!,<br>  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!<br>)</pre><h3>Setting Up Stability AI API</h3><p>To use the Stability AI API, you’ll need to sign up for an account and obtain an API key. Once you have your key, add it to your .env.local file:</p><pre>STABILITY_API_KEY=your-stability-ai-api-key</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YUnH_1SsU7TjbiY7r0GjWQ.png" /></figure><h3>Project Structure</h3><p>Here’s an overview of our initial project structure:</p><pre>ai-image-generator/<br>├── components/<br>│   ├── ImageGenerator.tsx<br>│   ├── StylePresets.tsx<br>│   ├── AspectRatioSelector.tsx<br>│   └── ImageHistory.tsx<br>├── pages/<br>│   ├── api/<br>│   │   ├── generate-image.ts<br>│   │   ├── remove-background.ts<br>│   │   └── search-replace.ts<br>│   ├── _app.tsx<br>│   └── index.tsx<br>├── utils/<br>│   └── supabase/<br>│       └── client.ts<br>├── styles/<br>│   └── globals.css<br>├── .env.local<br>├── next.config.js<br>├── package.json<br>└── tsconfig.json</pre><p>This structure provides a clean separation of concerns, with components, API routes, and utility functions organized into their respective directories.</p><p>With our development environment set up, we’re now ready to start building the core functionality of our AI-powered image generation tool. In the next section, we’ll dive into creating the user interface and implementing the basic image generation features.</p><h3>Building the Core Image Generation Interface</h3><p>Now that our development environment is set up, let’s dive into creating the heart of our application: the image generation interface. We’ll break this down into several key components to create a user-friendly and powerful tool.</p><h3>1. Implementing the Prompt Input and Submission Form</h3><p>The first step is to create a form where users can enter their prompts and submit them for image generation. We’ll use the react-hook-form library to manage our form state and validation.</p><pre>import React, { useState } from &#39;react&#39;;<br>import { useForm, SubmitHandler } from &#39;react-hook-form&#39;;<br>import { Button } from &#39;@/components/ui/button&#39;;<br>import { Textarea } from &#39;@/components/ui/textarea&#39;;<br><br>type Inputs = {<br>  prompt: string;<br>};<br>export function ImageGenerator() {<br>  const [image, setImage] = useState&lt;string | null&gt;(null);<br>  const { register, handleSubmit, formState: { errors } } = useForm&lt;Inputs&gt;();<br>  const onSubmit: SubmitHandler&lt;Inputs&gt; = async (data) =&gt; {<br>    // We&#39;ll implement the API call here in the next step<br>    console.log(data);<br>  };<br>  return (<br>    &lt;form onSubmit={handleSubmit(onSubmit)} className=&quot;space-y-4&quot;&gt;<br>      &lt;Textarea<br>        {...register(&quot;prompt&quot;, { required: &quot;Prompt is required&quot; })}<br>        placeholder=&quot;Describe the image you want to generate...&quot;<br>        className=&quot;w-full h-32&quot;<br>      /&gt;<br>      {errors.prompt &amp;&amp; &lt;span className=&quot;text-red-500&quot;&gt;{errors.prompt.message}&lt;/span&gt;}<br>      &lt;Button type=&quot;submit&quot;&gt;Generate Image&lt;/Button&gt;<br>      {image &amp;&amp; &lt;img src={image} alt=&quot;Generated&quot; className=&quot;mt-4 max-w-full h-auto&quot; /&gt;}<br>    &lt;/form&gt;<br>  );<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUyuDAx_1nN5eq2_YU9F8A.gif" /></figure><h3>2. Integrating Style Presets</h3><p>To give users more control over the generated images, let’s add a style preset selector. This will allow users to choose from predefined styles like “anime”, “photorealistic”, or “digital art”.</p><pre>import React from &#39;react&#39;;<br>import { Button } from &#39;@/components/ui/button&#39;;<br>const stylePresets = [<br>  { name: &#39;None&#39;, image: &#39;/style-presets/none.jpg&#39; },<br>  { name: &#39;Anime&#39;, image: &#39;/style-presets/anime.jpg&#39; },<br>  { name: &#39;Photorealistic&#39;, image: &#39;/style-presets/photorealistic.jpg&#39; },<br>  { name: &#39;Digital Art&#39;, image: &#39;/style-presets/digital-art.jpg&#39; },<br>  // Add more style presets as needed<br>];<br>interface StylePresetsProps {<br>  selectedStyle: string;<br>  onStyleSelect: (style: string) =&gt; void;<br>}<br>export function StylePresets({ selectedStyle, onStyleSelect }: StylePresetsProps) {<br>  return (<br>    &lt;div className=&quot;flex flex-wrap gap-2&quot;&gt;<br>      {stylePresets.map((style) =&gt; (<br>        &lt;Button<br>          key={style.name}<br>          onClick={() =&gt; onStyleSelect(style.name)}<br>          variant={selectedStyle === style.name ? &quot;secondary&quot; : &quot;outline&quot;}<br>          className=&quot;w-24 h-24 p-1&quot;<br>        &gt;<br>          &lt;img src={style.image} alt={style.name} className=&quot;w-full h-full object-cover rounded&quot; /&gt;<br>          &lt;span className=&quot;mt-1 text-xs&quot;&gt;{style.name}&lt;/span&gt;<br>        &lt;/Button&gt;<br>      ))}<br>    &lt;/div&gt;<br>  );<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yCzDcYhXkVkWrZMIGQLuAA.gif" /></figure><h3>3. Creating the Aspect Ratio Selector</h3><p>Next, let’s add an aspect ratio selector to allow users to choose the dimensions of their generated images.</p><pre>import React from &#39;react&#39;;<br>import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from &#39;@/components/ui/select&#39;;<br>const aspectRatios = [<br>  { value: &#39;1:1&#39;, label: &#39;Square (1:1)&#39; },<br>  { value: &#39;4:3&#39;, label: &#39;Standard (4:3)&#39; },<br>  { value: &#39;16:9&#39;, label: &#39;Widescreen (16:9)&#39; },<br>  { value: &#39;9:16&#39;, label: &#39;Portrait (9:16)&#39; },<br>];<br>interface AspectRatioSelectorProps {<br>  selectedRatio: string;<br>  onRatioSelect: (ratio: string) =&gt; void;<br>}<br>export function AspectRatioSelector({ selectedRatio, onRatioSelect }: AspectRatioSelectorProps) {<br>  return (<br>    &lt;Select value={selectedRatio} onValueChange={onRatioSelect}&gt;<br>      &lt;SelectTrigger className=&quot;w-[180px]&quot;&gt;<br>        &lt;SelectValue placeholder=&quot;Select aspect ratio&quot; /&gt;<br>      &lt;/SelectTrigger&gt;<br>      &lt;SelectContent&gt;<br>        {aspectRatios.map((ratio) =&gt; (<br>          &lt;SelectItem key={ratio.value} value={ratio.value}&gt;<br>            {ratio.label}<br>          &lt;/SelectItem&gt;<br>        ))}<br>      &lt;/SelectContent&gt;<br>    &lt;/Select&gt;<br>  );<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FU7IsRFv3K2cf9O2Ed55EQ.gif" /></figure><h3>4. Handling Form Submission and API Calls</h3><p>Finally, let’s implement the API call to generate the image based on the user’s input.</p><pre>// In your ImageGenerator component<br>const onSubmit: SubmitHandler&lt;Inputs&gt; = async (data) =&gt; {<br>  try {<br>    const response = await fetch(&#39;/api/generate-image&#39;, {<br>      method: &#39;POST&#39;,<br>      headers: {<br>        &#39;Content-Type&#39;: &#39;application/json&#39;,<br>      },<br>      body: JSON.stringify({<br>        prompt: data.prompt,<br>        stylePreset,<br>        aspectRatio,<br>      }),<br>    });<br>    if (!response.ok) {<br>      throw new Error(&#39;Failed to generate image&#39;);<br>    }<br>    const result = await response.json();<br>    setImage(result.image);<br>  } catch (error) {<br>    console.error(&#39;Error generating image:&#39;, error);<br>    // Handle error (e.g., show error message to user)<br>  }<br>};</pre><p>This code sends a POST request to our /api/generate-image endpoint (which we&#39;ll implement in the backend section) with the user&#39;s prompt, selected style preset, and aspect ratio.</p><p>With these components in place, we now have a functional core interface for our AI image generation tool. Users can enter prompts, select style presets and aspect ratios, and generate images with a click of a button.</p><p>In the next section, we’ll explore how to implement the backend routes to handle these requests and interact with the Stability AI API.</p><h3>Implementing Backend Routes</h3><p>Now that we have our frontend interface set up, it’s time to create the backend routes that will handle our requests and interact with the Stability AI API. We’ll be implementing three main routes: image generation, background removal, and search and replace.</p><h3>1. Image Generation Route</h3><p>Let’s start with the main image generation route. This will handle the initial creation of images based on user prompts.</p><pre>// pages/api/generate-image.ts<br>import { NextRequest, NextResponse } from &quot;next/server&quot;;<br>export const maxDuration = 60;<br>export async function POST(req: NextRequest) {<br>  try {<br>    const body = await req.json();<br>    const { prompt, aspectRatio, stylePreset, negativePrompt, seed, aiImprovePrompt, model } = body;<br>    let apiEndpoint: string;<br>    let payload = new FormData();<br>    // Select the appropriate API endpoint based on the chosen model<br>    switch (model) {<br>      case &quot;sd3-medium&quot;:<br>      case &quot;sd3-large&quot;:<br>      case &quot;sd3-large-turbo&quot;:<br>        apiEndpoint = &quot;https://api.stability.ai/v2beta/stable-image/generate/sd3&quot;;<br>        payload.append(&quot;model&quot;, model);<br>        break;<br>      case &quot;stable-image-core&quot;:<br>        apiEndpoint = &quot;https://api.stability.ai/v2beta/stable-image/generate/core&quot;;<br>        break;<br>      case &quot;stable-image-ultra&quot;:<br>        apiEndpoint = &quot;https://api.stability.ai/v2beta/stable-image/generate/ultra&quot;;<br>        break;<br>      default:<br>        throw new Error(&quot;Invalid model selected&quot;);<br>    }<br>    // Prepare the payload for the Stability AI API<br>    payload.append(&quot;prompt&quot;, prompt);<br>    payload.append(&quot;output_format&quot;, &quot;png&quot;);<br>    payload.append(&quot;aspect_ratio&quot;, aspectRatio);<br>    if (negativePrompt) payload.append(&quot;negative_prompt&quot;, negativePrompt);<br>    if (seed !== 0) payload.append(&quot;seed&quot;, seed.toString());<br>    // SD3 Large Turbo doesn&#39;t support negative_prompt<br>    if (model === &quot;sd3-large-turbo&quot;) {<br>      payload.delete(&quot;negative_prompt&quot;);<br>    }<br>    // Style Preset only works with Stable Image Core<br>    if (model === &quot;stable-image-core&quot; &amp;&amp; stylePreset) {<br>      payload.append(&quot;style_preset&quot;, stylePreset);<br>    }<br>    // Make the API call to Stability AI<br>    const response = await fetch(apiEndpoint, {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        Authorization: `Bearer ${process.env.STABILITY_API_KEY}`,<br>        Accept: &quot;image/*&quot;,<br>      },<br>      body: payload,<br>    });<br>    if (response.ok) {<br>      const imageBuffer = await response.arrayBuffer();<br>      const base64Image = Buffer.from(imageBuffer).toString(&quot;base64&quot;);<br>      return NextResponse.json(<br>        {<br>          image: `data:image/png;base64,${base64Image}`,<br>          message: &quot;Image generated successfully&quot;,<br>        },<br>        { status: 200 }<br>      );<br>    } else {<br>      const errorText = await response.text();<br>      throw new Error(`${response.status}: ${errorText}`);<br>    }<br>  } catch (error) {<br>    console.error(&quot;Error:&quot;, error);<br>    return NextResponse.json(<br>      { error: &quot;An error occurred while generating the image&quot; },<br>      { status: 500 }<br>    );<br>  }<br>}</pre><h3>2. Background Removal Route</h3><p>Next, let’s implement the background removal route. This will allow users to remove the background from their generated images.</p><pre>// pages/api/remove-background.ts<br>import { NextRequest, NextResponse } from &quot;next/server&quot;;<br>import { createClient } from &quot;@/utils/supabase/server&quot;;<br>export const maxDuration = 60;<br>export async function POST(req: NextRequest) {<br>  try {<br>    const formData = await req.formData();<br>    const imageFile = formData.get(&quot;image&quot;) as File;<br>    const outputFormat = (formData.get(&quot;output_format&quot;) as string) || &quot;png&quot;;<br>    // Get the original image metadata<br>    const originalPrompt = formData.get(&quot;prompt&quot;) as string;<br>    const aspectRatio = formData.get(&quot;aspect_ratio&quot;) as string;<br>    const stylePreset = formData.get(&quot;style_preset&quot;) as string;<br>    const negativePrompt = formData.get(&quot;negative_prompt&quot;) as string;<br>    const seed = parseInt(formData.get(&quot;seed&quot;) as string);<br>    const aiImprovePrompt = formData.get(&quot;ai_improve_prompt&quot;) === &quot;true&quot;;<br>    const model = formData.get(&quot;model&quot;) as string;<br>    if (!imageFile) {<br>      return NextResponse.json({ error: &quot;No image provided&quot; }, { status: 400 });<br>    }<br>    // Prepare the request to Stability AI<br>    const apiUrl = &quot;https://api.stability.ai/v2beta/stable-image/edit/remove-background&quot;;<br>    const payload = new FormData();<br>    payload.append(&quot;image&quot;, imageFile);<br>    payload.append(&quot;output_format&quot;, outputFormat);<br>    const response = await fetch(apiUrl, {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        Authorization: `Bearer ${process.env.STABILITY_API_KEY}`,<br>        Accept: &quot;image/*&quot;,<br>      },<br>      body: payload,<br>    });<br>    if (!response.ok) {<br>      const errorText = await response.text();<br>      throw new Error(`${response.status}: ${errorText}`);<br>    }<br>    const imageBuffer = await response.arrayBuffer();<br>    const base64Image = Buffer.from(imageBuffer).toString(&quot;base64&quot;);<br>    // Save the image to Supabase and update the database<br>    const supabase = createClient();<br>    const { data: { user } } = await supabase.auth.getUser();<br>    if (!user) {<br>      return NextResponse.json({ error: &quot;User not authenticated&quot; }, { status: 401 });<br>    }<br>    // Save image to Supabase storage and database (implementation details omitted for brevity)<br>    return NextResponse.json({<br>      image: `data:image/${outputFormat};base64,${base64Image}`,<br>      savedImage: savedData[0],<br>      message: &quot;Background removed and image saved successfully&quot;,<br>    });<br>  } catch (error) {<br>    console.error(&quot;Error:&quot;, error);<br>    return NextResponse.json(<br>      { error: &quot;An error occurred while removing the background&quot; },<br>      { status: 500 }<br>    );<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2uBhTRxF-qb6oEkb0AYnA.gif" /></figure><h3>3. Search and Replace Route</h3><p>Finally, let’s implement the search and replace route, which allows users to modify specific elements in their generated images.</p><pre>// pages/api/search-replace.ts<br>import { NextRequest, NextResponse } from &quot;next/server&quot;;<br>import { createClient } from &quot;@/utils/supabase/server&quot;;<br>export const maxDuration = 60;<br>export async function POST(req: NextRequest) {<br>  try {<br>    const formData = await req.formData();<br>    const imageFile = formData.get(&quot;image&quot;) as File;<br>    const prompt = formData.get(&quot;prompt&quot;) as string;<br>    const searchPrompt = formData.get(&quot;search_prompt&quot;) as string;<br>    const replacePrompt = formData.get(&quot;replace_prompt&quot;) as string;<br>    const outputFormat = (formData.get(&quot;output_format&quot;) as string) || &quot;png&quot;;<br>    const negativePrompt = formData.get(&quot;negative_prompt&quot;) as string;<br>    const seed = parseInt(formData.get(&quot;seed&quot;) as string) || 0;<br>    if (!imageFile || !prompt || !searchPrompt) {<br>      return NextResponse.json(<br>        { error: &quot;Missing required parameters&quot; },<br>        { status: 400 }<br>      );<br>    }<br>    // Prepare the request to Stability AI<br>    const apiUrl = &quot;https://api.stability.ai/v2beta/stable-image/edit/search-and-replace&quot;;<br>    const payload = new FormData();<br>    payload.append(&quot;image&quot;, imageFile);<br>    if (seed !== 0) payload.append(&quot;seed&quot;, seed.toString());<br>    payload.append(&quot;mode&quot;, &quot;search&quot;);<br>    payload.append(&quot;output_format&quot;, outputFormat);<br>    payload.append(&quot;prompt&quot;, replacePrompt);<br>    payload.append(&quot;search_prompt&quot;, searchPrompt);<br>    if (negativePrompt) payload.append(&quot;negative_prompt&quot;, negativePrompt);<br>    const response = await fetch(apiUrl, {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        Authorization: `Bearer ${process.env.STABILITY_API_KEY}`,<br>        Accept: &quot;image/*&quot;,<br>      },<br>      body: payload,<br>    });<br>    if (!response.ok) {<br>      const errorText = await response.text();<br>      throw new Error(`${response.status}: ${errorText}`);<br>    }<br>    const imageBuffer = await response.arrayBuffer();<br>    const base64Image = Buffer.from(imageBuffer).toString(&quot;base64&quot;);<br>    // Save the image to Supabase and update the database (implementation details omitted for brevity)<br>    return NextResponse.json({<br>      image: `data:image/${outputFormat};base64,${base64Image}`,<br>      savedImage: savedData[0],<br>      message: &quot;Search and replace completed successfully&quot;,<br>    });<br>  } catch (error) {<br>    console.error(&quot;Error:&quot;, error);<br>    return NextResponse.json(<br>      { error: &quot;An error occurred while performing search and replace&quot; },<br>      { status: 500 }<br>    );<br>  }<br>}</pre><p>These backend routes form the core of our AI image generation tool’s functionality. They handle the communication with the Stability AI API, process the responses, and manage the storage and retrieval of generated images.</p><p>In the next section, we’ll explore how to enhance the user experience with advanced features and a responsive design.</p><h3>Enhancing User Experience with Advanced Features</h3><p>Now that we have our core functionality in place, let’s focus on enhancing the user experience with advanced features and a responsive design. We’ll implement background removal and search-and-replace capabilities in the frontend, create a responsive layout, and build an image history component with infinite scrolling.</p><h3>1. Implementing Background Removal in the Frontend</h3><p>Let’s add a button that allows users to remove the background from their generated images.</p><pre>import React, { useState } from &#39;react&#39;;<br>import { Button } from &#39;@/components/ui/button&#39;;<br>import { ImageOff } from &#39;lucide-react&#39;;<br>interface BackgroundRemovalProps {<br>  imageUrl: string;<br>  onImageUpdate: (newImageUrl: string) =&gt; void;<br>}<br>export function BackgroundRemoval({ imageUrl, onImageUpdate }: BackgroundRemovalProps) {<br>  const [isRemoving, setIsRemoving] = useState(false);<br>  const handleRemoveBackground = async () =&gt; {<br>    setIsRemoving(true);<br>    try {<br>      const formData = new FormData();<br>      formData.append(&#39;image&#39;, await (await fetch(imageUrl)).blob());<br>      const response = await fetch(&#39;/api/remove-background&#39;, {<br>        method: &#39;POST&#39;,<br>        body: formData,<br>      });<br>      if (!response.ok) {<br>        throw new Error(&#39;Failed to remove background&#39;);<br>      }<br>      const data = await response.json();<br>      onImageUpdate(data.image);<br>    } catch (error) {<br>      console.error(&#39;Error removing background:&#39;, error);<br>      // Handle error (e.g., show error message to user)<br>    } finally {<br>      setIsRemoving(false);<br>    }<br>  };<br>  return (<br>    &lt;Button<br>      onClick={handleRemoveBackground}<br>      disabled={isRemoving}<br>      variant=&quot;outline&quot;<br>      size=&quot;icon&quot;<br>    &gt;<br>      {isRemoving ? (<br>        &lt;span className=&quot;loader&quot; /&gt;<br>      ) : (<br>        &lt;ImageOff className=&quot;w-4 h-4&quot; /&gt;<br>      )}<br>    &lt;/Button&gt;<br>  );<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2uBhTRxF-qb6oEkb0AYnA.gif" /></figure><h3>2. Adding Search and Replace Capabilities</h3><p>Next, let’s implement the search and replace feature in our frontend.</p><pre>import React, { useState } from &#39;react&#39;;<br>import { Button } from &#39;@/components/ui/button&#39;;<br>import { Input } from &#39;@/components/ui/input&#39;;<br>import { Replace } from &#39;lucide-react&#39;;<br>interface SearchReplaceProps {<br>  imageUrl: string;<br>  onImageUpdate: (newImageUrl: string) =&gt; void;<br>}<br>export function SearchReplace({ imageUrl, onImageUpdate }: SearchReplaceProps) {<br>  const [searchTerm, setSearchTerm] = useState(&#39;&#39;);<br>  const [replaceTerm, setReplaceTerm] = useState(&#39;&#39;);<br>  const [isReplacing, setIsReplacing] = useState(false);<br>  const handleSearchReplace = async () =&gt; {<br>    setIsReplacing(true);<br>    try {<br>      const formData = new FormData();<br>      formData.append(&#39;image&#39;, await (await fetch(imageUrl)).blob());<br>      formData.append(&#39;search_prompt&#39;, searchTerm);<br>      formData.append(&#39;replace_prompt&#39;, replaceTerm);<br>      const response = await fetch(&#39;/api/search-replace&#39;, {<br>        method: &#39;POST&#39;,<br>        body: formData,<br>      });<br>      if (!response.ok) {<br>        throw new Error(&#39;Failed to perform search and replace&#39;);<br>      }<br>      const data = await response.json();<br>      onImageUpdate(data.image);<br>    } catch (error) {<br>      console.error(&#39;Error performing search and replace:&#39;, error);<br>      // Handle error (e.g., show error message to user)<br>    } finally {<br>      setIsReplacing(false);<br>    }<br>  };<br>  return (<br>    &lt;div className=&quot;flex space-x-2&quot;&gt;<br>      &lt;Input<br>        placeholder=&quot;Search for...&quot;<br>        value={searchTerm}<br>        onChange={(e) =&gt; setSearchTerm(e.target.value)}<br>      /&gt;<br>      &lt;Input<br>        placeholder=&quot;Replace with...&quot;<br>        value={replaceTerm}<br>        onChange={(e) =&gt; setReplaceTerm(e.target.value)}<br>      /&gt;<br>      &lt;Button<br>        onClick={handleSearchReplace}<br>        disabled={isReplacing || !searchTerm || !replaceTerm}<br>        variant=&quot;outline&quot;<br>        size=&quot;icon&quot;<br>      &gt;<br>        {isReplacing ? (<br>          &lt;span className=&quot;loader&quot; /&gt;<br>        ) : (<br>          &lt;Replace className=&quot;w-4 h-4&quot; /&gt;<br>        )}<br>      &lt;/Button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>3. Creating a Responsive Design</h3><p>To ensure our application works well on both desktop and mobile devices, let’s implement a responsive layout using CSS Grid and Flexbox.</p><pre>import React from &#39;react&#39;;<br>import { ImageGenerator } from &#39;./ImageGenerator&#39;;<br>import { ImageHistory } from &#39;./ImageHistory&#39;;<br><br>export function App() {<br>  return (<br>    &lt;div className=&quot;min-h-screen bg-background&quot;&gt;<br>      &lt;main className=&quot;container mx-auto px-4 py-8&quot;&gt;<br>        &lt;h1 className=&quot;text-4xl font-bold mb-8&quot;&gt;AI Image Generator&lt;/h1&gt;<br>        &lt;div className=&quot;grid grid-cols-1 md:grid-cols-3 gap-8&quot;&gt;<br>          &lt;div className=&quot;md:col-span-2&quot;&gt;<br>            &lt;ImageGenerator /&gt;<br>          &lt;/div&gt;<br>          &lt;div className=&quot;hidden md:block&quot;&gt;<br>            &lt;ImageHistory /&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div className=&quot;md:hidden mt-8&quot;&gt;<br>          &lt;ImageHistory /&gt;<br>        &lt;/div&gt;<br>      &lt;/main&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>This layout will stack the components vertically on mobile devices and use a two-column layout on larger screens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*u4qL1kVUs5xXgy35L4CMnQ.png" /><figcaption>Mobile</figcaption></figure><h3>4. Building an Image History Component with Infinite Scrolling</h3><p>Finally, let’s create an image history component that loads more images as the user scrolls.</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br>import { useInView } from &#39;react-intersection-observer&#39;;<br>import { createClient } from &#39;@/utils/supabase/client&#39;;<br>export function ImageHistory() {<br>  const [images, setImages] = useState([]);<br>  const [page, setPage] = useState(1);<br>  const [hasMore, setHasMore] = useState(true);<br>  const { ref, inView } = useInView();<br>  const fetchImages = async () =&gt; {<br>    const supabase = createClient();<br>    const { data, error } = await supabase<br>      .from(&#39;generated_images&#39;)<br>      .select(&#39;*&#39;)<br>      .order(&#39;created_at&#39;, { ascending: false })<br>      .range((page - 1) * 10, page * 10 - 1);<br>    if (error) {<br>      console.error(&#39;Error fetching images:&#39;, error);<br>      return;<br>    }<br>    setImages((prevImages) =&gt; [...prevImages, ...data]);<br>    setHasMore(data.length === 10);<br>    setPage((prevPage) =&gt; prevPage + 1);<br>  };<br>  useEffect(() =&gt; {<br>    fetchImages();<br>  }, []);<br>  useEffect(() =&gt; {<br>    if (inView &amp;&amp; hasMore) {<br>      fetchImages();<br>    }<br>  }, [inView, hasMore]);<br>  return (<br>    &lt;div className=&quot;grid grid-cols-2 gap-4&quot;&gt;<br>      {images.map((image) =&gt; (<br>        &lt;div key={image.id} className=&quot;aspect-square&quot;&gt;<br>          &lt;img<br>            src={image.image_url}<br>            alt={image.prompt}<br>            className=&quot;w-full h-full object-cover rounded-lg&quot;<br>          /&gt;<br>        &lt;/div&gt;<br>      ))}<br>      {hasMore &amp;&amp; (<br>        &lt;div ref={ref} className=&quot;col-span-2 text-center py-4&quot;&gt;<br>          Loading more images...<br>        &lt;/div&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>}</pre><p>This component fetches images in batches and loads more as the user scrolls to the bottom of the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*PFfYCRd3PLDCMAQ281CA4w.png" /><figcaption>User Created Image History</figcaption></figure><p>By implementing these advanced features and focusing on responsive design, we’ve significantly enhanced the user experience of our AI image generation tool. Users can now easily remove backgrounds, perform search and replace operations, and browse their image history, all while enjoying a seamless experience across different devices.</p><p>In the next and final section, we’ll conclude our journey and discuss potential future enhancements and applications for our AI image generation tool.</p><h3>Conclusion: Empowering Developers with AI Integration</h3><p>As we wrap up our journey through the creation of an AI-powered image generation tool, it’s time to reflect on what we’ve accomplished and look towards the future of AI in web development.</p><h3>Recap of Key Concepts and Techniques</h3><p>Throughout this blog post, we’ve explored several crucial aspects of building an AI-integrated web application:</p><ol><li>Setting up a modern development environment with React, Next.js, and Supabase</li><li>Implementing core functionality for AI image generation using the Stability AI API</li><li>Creating an intuitive user interface for prompt input, style selection, and aspect ratio control</li><li>Developing backend routes to handle complex operations like image generation, background removal, and search-and-replace</li><li>Enhancing user experience with advanced features and responsive design</li><li>Building an efficient image history component with infinite scrolling</li></ol><p>These concepts and techniques form a solid foundation for integrating AI capabilities into web applications, opening up a world of possibilities for developers and content creators alike.</p><h3>Potential Applications and Extensions</h3><p>The AI image generation tool we’ve built is just the beginning. There are numerous ways to extend and apply this technology:</p><ol><li><strong>Content Creation Platforms</strong>: Integrate AI image generation into blogging platforms or social media schedulers to help content creators quickly produce visuals for their posts.</li><li><strong>E-commerce Product Visualization</strong>: Use the tool to generate product images in different styles or settings, helping customers visualize products in various contexts.</li><li><strong>Educational Tools</strong>: Develop interactive learning platforms that use AI-generated images to illustrate concepts or create visual study aids.</li><li><strong>Game Development</strong>: Implement the tool in game design software to rapidly prototype environments, characters, or assets.</li><li><strong>Architectural Visualization</strong>: Extend the tool to generate or modify architectural renderings based on text descriptions or sketches.</li><li><strong>Accessibility Applications</strong>: Create tools that can generate descriptive images from text, aiding visually impaired users in understanding visual content.</li><li><strong>Creative Writing Aids</strong>: Build applications that generate illustrations for stories or poems, bringing written words to life visually.</li></ol><h3>Encouragement for Further Exploration</h3><p>As AI technology continues to evolve at a rapid pace, the possibilities for integration into web and mobile applications are virtually limitless. I encourage you, as developers and innovators, to:</p><ol><li><strong>Experiment with Different AI Models</strong>: Explore other AI services and models to expand the capabilities of your applications.</li><li><strong>Combine AI Technologies</strong>: Consider integrating image generation with other AI technologies like natural language processing or computer vision for more complex applications.</li><li><strong>Focus on Ethical Considerations</strong>: As you develop AI-powered tools, always consider the ethical implications and strive to create responsible and beneficial applications.</li><li><strong>Stay Updated</strong>: Keep abreast of the latest developments in AI and web technologies to continually enhance your skills and the capabilities of your applications.</li><li><strong>Collaborate and Share</strong>: Engage with the developer community, share your experiences, and collaborate on open-source projects to drive innovation in AI integration.</li></ol><p>Remember, the AI revolution in web development is just beginning, and you have the opportunity to be at the forefront of this exciting field. Whether you’re building tools for creative expression, solving complex business problems, or developing the next groundbreaking application, AI integration can help you push the boundaries of what’s possible.</p><p>As we conclude this blog post, I hope you feel inspired and equipped to embark on your own AI integration journey. The tools and techniques we’ve explored are just the beginning — the real magic happens when you apply your creativity and problem-solving skills to create something truly innovative.</p><p>So, what will you build next? The future of AI-powered web development is in your hands, and the possibilities are endless. Happy coding, and may your AI adventures be as exciting as they are groundbreaking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0b968feba1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>