<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ahmed Adawy </title>
    <description>The latest articles on DEV Community by Ahmed Adawy  (@ahmedadawy625).</description>
    <link>https://dev.to/ahmedadawy625</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4040204%2F4dd4d75d-e3ef-42b2-9789-2535618efcda.jpg</url>
      <title>DEV Community: Ahmed Adawy </title>
      <link>https://dev.to/ahmedadawy625</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahmedadawy625"/>
    <language>en</language>
    <item>
      <title>Master Python testing with pytest and learn how to build reliable, maintainable automated tests</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Sun, 09 Aug 2026 19:43:15 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/master-python-testing-with-pytest-and-learn-how-to-build-reliable-maintainable-automated-tests-2akj</link>
      <guid>https://dev.to/ahmedadawy625/master-python-testing-with-pytest-and-learn-how-to-build-reliable-maintainable-automated-tests-2akj</guid>
      <description>&lt;p&gt;Writing Python code is only half of the job.&lt;/p&gt;

&lt;p&gt;The other half is knowing that the code continues to work when the project changes.&lt;/p&gt;

&lt;p&gt;A function can work perfectly today and break tomorrow after a small refactor.&lt;/p&gt;

&lt;p&gt;A new feature can accidentally affect an older one.&lt;/p&gt;

&lt;p&gt;A seemingly harmless change can introduce a regression somewhere else.&lt;/p&gt;

&lt;p&gt;This is where automated testing becomes essential.&lt;/p&gt;

&lt;p&gt;Introducing: Python Testing with pytest&lt;/p&gt;

&lt;p&gt;I’ve just published the second capsule in my Ahmed Adawy Tech Capsules series:&lt;/p&gt;

&lt;p&gt;Python Testing with pytest — A Practical Guide to Writing Reliable Tests&lt;/p&gt;

&lt;p&gt;This capsule is designed as a practical introduction to automated testing with Python’s pytest framework.&lt;/p&gt;

&lt;p&gt;It focuses on the concepts developers actually need when moving from manual checking to a repeatable testing workflow.&lt;/p&gt;

&lt;p&gt;What you’ll learn&lt;/p&gt;

&lt;p&gt;The capsule starts from the fundamentals and progressively builds the testing mindset.&lt;/p&gt;

&lt;p&gt;It covers topics such as:&lt;/p&gt;

&lt;p&gt;Why automated testing matters&lt;/p&gt;

&lt;p&gt;Installing and running pytest&lt;/p&gt;

&lt;p&gt;Writing your first test&lt;/p&gt;

&lt;p&gt;Assertions&lt;/p&gt;

&lt;p&gt;Testing normal behavior&lt;/p&gt;

&lt;p&gt;Testing edge cases&lt;/p&gt;

&lt;p&gt;Testing exceptions&lt;/p&gt;

&lt;p&gt;Verifying exception messages&lt;/p&gt;

&lt;p&gt;Writing focused tests&lt;/p&gt;

&lt;p&gt;Arrange / Act / Assert&lt;/p&gt;

&lt;p&gt;Running individual tests&lt;/p&gt;

&lt;p&gt;Understanding pytest output&lt;/p&gt;

&lt;p&gt;Structuring tests for real Python projects&lt;/p&gt;

&lt;p&gt;And it doesn’t stop at simply showing syntax.&lt;/p&gt;

&lt;p&gt;The goal is to understand why these techniques matter and how they fit into a real development workflow.&lt;/p&gt;

&lt;p&gt;A simple example&lt;/p&gt;

&lt;p&gt;A pytest test can be surprisingly readable:&lt;/p&gt;

&lt;p&gt;def test_add():&lt;br&gt;
    result = add(2, 3)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;assert result == 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The test tells a story:&lt;/p&gt;

&lt;p&gt;Arrange → Act → Assert&lt;/p&gt;

&lt;p&gt;Prepare the input.&lt;/p&gt;

&lt;p&gt;Execute the behavior.&lt;/p&gt;

&lt;p&gt;Verify the result.&lt;/p&gt;

&lt;p&gt;That simplicity is one of the reasons pytest has become such a practical choice for Python testing.&lt;/p&gt;

&lt;p&gt;Testing failure is testing too&lt;/p&gt;

&lt;p&gt;Reliable software isn’t only about successful inputs.&lt;/p&gt;

&lt;p&gt;Invalid behavior needs to be tested as well.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;import pytest&lt;/p&gt;

&lt;p&gt;def test_divide_by_zero():&lt;br&gt;
    with pytest.raises(ValueError):&lt;br&gt;
        divide(10, 0)&lt;/p&gt;

&lt;p&gt;Now the test verifies that the software doesn’t merely fail — it fails in the expected way.&lt;/p&gt;

&lt;p&gt;That’s an important distinction when building dependable applications.&lt;/p&gt;

&lt;p&gt;Why I created this capsule&lt;/p&gt;

&lt;p&gt;I wanted this capsule to be useful to someone who already knows basic Python but wants to move toward a more professional development workflow.&lt;/p&gt;

&lt;p&gt;Instead of treating testing as something added at the end of a project, the capsule presents testing as part of the development process itself.&lt;/p&gt;

&lt;p&gt;The bigger idea is simple:&lt;/p&gt;

&lt;p&gt;Your tests become a safety net for your code.&lt;/p&gt;

&lt;p&gt;The more your project grows, the more valuable that safety net becomes.&lt;/p&gt;

&lt;p&gt;📚 The full capsule&lt;/p&gt;

&lt;p&gt;The complete capsule goes beyond the introductory material and explores the techniques needed for larger Python projects, including:&lt;/p&gt;

&lt;p&gt;Fixtures • Parametrization • Reusable Test Setup • Advanced Exception Testing • Test Organization • Code Coverage • Continuous Integration • Real-World Testing • Professional Testing Practices&lt;/p&gt;

&lt;p&gt;The capsule is approximately 45 pages and is part of the growing Ahmed Adawy Tech Capsules series.&lt;/p&gt;

&lt;p&gt;🚀 Who is this for?&lt;/p&gt;

&lt;p&gt;This capsule is especially useful for:&lt;/p&gt;

&lt;p&gt;Python developers&lt;/p&gt;

&lt;p&gt;Students learning software engineering&lt;/p&gt;

&lt;p&gt;Developers moving from scripts to larger projects&lt;/p&gt;

&lt;p&gt;Anyone starting with automated testing&lt;/p&gt;

&lt;p&gt;Developers who want to introduce pytest into their workflow&lt;/p&gt;

&lt;p&gt;You don’t need to be a testing expert.&lt;/p&gt;

&lt;p&gt;You just need a working understanding of Python and a willingness to start testing your code properly.&lt;/p&gt;

&lt;p&gt;The bigger goal&lt;/p&gt;

&lt;p&gt;This capsule is part of a larger project I’m building:&lt;/p&gt;

&lt;p&gt;Ahmed Adawy Tech Capsules&lt;/p&gt;

&lt;p&gt;Short, focused technical books designed to turn complex engineering concepts into practical, readable learning material.&lt;/p&gt;

&lt;p&gt;One topic.&lt;/p&gt;

&lt;p&gt;One focused capsule.&lt;/p&gt;

&lt;p&gt;One practical engineering skill at a time.&lt;/p&gt;

&lt;p&gt;📖 Python Testing with pytest&lt;/p&gt;

&lt;p&gt;A Practical Guide to Writing Reliable Tests&lt;/p&gt;

&lt;p&gt;Author: Ahmed Adawy&lt;br&gt;
Series: Ahmed Adawy Tech Capsules&lt;br&gt;
Category: Python / Testing&lt;br&gt;
Level: Intermediate&lt;br&gt;
Length: ~45 pages&lt;/p&gt;

&lt;p&gt;If you’re writing Python seriously, automated testing is no longer just a “nice to have.”&lt;/p&gt;

&lt;p&gt;It’s part of building software you can trust.&lt;/p&gt;

&lt;p&gt;Keep testing. Keep improving. Keep building. &lt;/p&gt;

</description>
      <category>python</category>
      <category>pytest</category>
      <category>testing</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Automating Python Projects with GitHub Actions: A Practical CI/CD Workflow</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Sat, 08 Aug 2026 18:59:52 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/automating-python-projects-with-github-actions-a-practical-cicd-workflow-5b0c</link>
      <guid>https://dev.to/ahmedadawy625/automating-python-projects-with-github-actions-a-practical-cicd-workflow-5b0c</guid>
      <description>&lt;p&gt;I finally published a practical guide to GitHub Actions for Python projects.&lt;/p&gt;

&lt;p&gt;GitHub Actions is easy to demonstrate with a simple YAML file.&lt;/p&gt;

&lt;p&gt;The harder part is designing a workflow that actually helps a real project.&lt;/p&gt;

&lt;p&gt;So I built this capsule around the practical side of CI/CD:&lt;/p&gt;

&lt;p&gt;• Setting up Python environments in GitHub Actions&lt;br&gt;
• Managing project dependencies&lt;br&gt;
• Running automated tests with pytest&lt;br&gt;
• Generating test coverage reports&lt;br&gt;
• Building project documentation&lt;br&gt;
• Generating and preserving workflow artifacts&lt;br&gt;
• Organizing workflow steps&lt;br&gt;
• Understanding the execution order of CI jobs&lt;br&gt;
• Building reusable patterns for Python projects&lt;/p&gt;

&lt;p&gt;The goal wasn't to write another long DevOps book.&lt;/p&gt;

&lt;p&gt;I wanted something closer to a technical micro-book: one focused topic, practical examples, and enough explanation to understand why each part of the workflow exists.&lt;/p&gt;

&lt;p&gt;If you're working on a Python project and still run tests, build documentation, or generate artifacts manually, this is the problem this capsule is trying to solve.&lt;/p&gt;

&lt;p&gt;📘 GitHub Actions for Python Projects&lt;br&gt;
A Practical Guide to CI/CD Automation&lt;/p&gt;

&lt;p&gt;Available on Leanpub:&lt;br&gt;
[Leanpub link]&lt;/p&gt;

&lt;p&gt;The source/project materials are also available on GitHub:&lt;br&gt;
&lt;a href="https://github.com/adawy20262026-oss/ahmed-adawy-tech-capsules" rel="noopener noreferrer"&gt;https://github.com/adawy20262026-oss/ahmed-adawy-tech-capsules&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Python #GitHubActions #CICD #DevOps #SoftwareEngineering #Testing #pytest
&lt;/h1&gt;

</description>
      <category>python</category>
      <category>githubactions</category>
      <category>testing</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Introducing Ahmed Adawy Tech Capsules: A Professional Markdown-to-PDF Publishing Engine Built with Python</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Fri, 07 Aug 2026 15:53:20 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/introducing-ahmed-adawy-tech-capsules-a-professional-markdown-to-pdf-publishing-engine-built-with-3na7</link>
      <guid>https://dev.to/ahmedadawy625/introducing-ahmed-adawy-tech-capsules-a-professional-markdown-to-pdf-publishing-engine-built-with-3na7</guid>
      <description>&lt;h1&gt;
  
  
  Introducing Ahmed Adawy Tech Capsules..
&lt;/h1&gt;

&lt;p&gt;For the past weeks, I have been building a project that combines technical writing, automation, and software engineering into a single publishing workflow.&lt;/p&gt;

&lt;p&gt;Today I'm happy to introduce &lt;strong&gt;Ahmed Adawy Tech Capsules&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A Python-powered publishing engine that transforms Markdown documents into professional technical publications.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why I Built It
&lt;/h2&gt;

&lt;p&gt;Writing technical content is easy.&lt;/p&gt;

&lt;p&gt;Publishing it professionally is not.&lt;/p&gt;

&lt;p&gt;Most technical writers spend hours formatting documents, creating PDF files, styling pages, generating tables of contents, and maintaining documentation.&lt;/p&gt;

&lt;p&gt;I wanted one command to do everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Professional HTML rendering&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Beautiful PDF generation using WeasyPrint&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic cover pages&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic Table of Contents&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Syntax highlighting powered by Pygments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Metadata support&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modular architecture&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Library index generation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Streamlit Web Interface&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GitHub Actions CI/CD&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automated testing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;The project follows a modular architecture.&lt;br&gt;
&lt;/p&gt;

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

      │

      ▼

Metadata Parser

      │

      ▼

Markdown Parser

      │

      ▼

HTML Renderer

      │

      ├── Cover Renderer

      ├── TOC Renderer

      ├── Content Renderer

      ├── Footer Renderer

      │

      ▼

PDF Generator

      │

      ▼

Professional PDF

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

&lt;/div&gt;



&lt;p&gt;Each component has a single responsibility, making the project easy to maintain and extend.&lt;/p&gt;




&lt;h2&gt;
  
  
  Current Statistics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Python 3.12&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;54 automated tests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;94% test coverage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GitHub Actions CI&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MIT License&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;First Stable Release (v1.0.0)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Technologies
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Python&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Markdown&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WeasyPrint&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pygments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PyYAML&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Streamlit&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pytest&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GitHub Actions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Open Source
&lt;/h2&gt;

&lt;p&gt;The project is completely open source.&lt;/p&gt;

&lt;p&gt;Contributions, ideas, and feedback are always welcome.&lt;/p&gt;

&lt;p&gt;GitHub Repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/adawy20262026-oss/ahmed-adawy-tech-capsules" rel="noopener noreferrer"&gt;https://github.com/adawy20262026-oss/ahmed-adawy-tech-capsules&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;The roadmap includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;100% test coverage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CLI interface&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiple themes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;EPUB export&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PyPI package&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Plugin system&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AI-assisted publishing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Thank you for reading.&lt;/p&gt;

&lt;p&gt;If you enjoy technical writing, Python, or documentation tooling, I'd love to hear your thoughts.&lt;/p&gt;

</description>
      <category>python</category>
      <category>markdown</category>
      <category>github</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Introducing Ahmed Adawy Tech Capsules: A Professional Markdown-to-PDF Publishing Engine Built with Python</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Fri, 07 Aug 2026 15:43:00 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/introducing-ahmed-adawy-tech-capsules-a-professional-markdown-to-pdf-publishing-engine-built-with-5faj</link>
      <guid>https://dev.to/ahmedadawy625/introducing-ahmed-adawy-tech-capsules-a-professional-markdown-to-pdf-publishing-engine-built-with-5faj</guid>
      <description>&lt;h1&gt;
  
  
  Introducing Ahmed Adawy Tech Capsules
&lt;/h1&gt;

&lt;p&gt;For the past weeks, I have been building a project that combines technical writing, automation, and software engineering into a single publishing workflow.&lt;/p&gt;

&lt;p&gt;Today I'm happy to introduce &lt;strong&gt;Ahmed Adawy Tech Capsules&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A Python-powered publishing engine that transforms Markdown documents into professional technical publications.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why I Built It
&lt;/h2&gt;

&lt;p&gt;Writing technical content is easy.&lt;/p&gt;

&lt;p&gt;Publishing it professionally is not.&lt;/p&gt;

&lt;p&gt;Most technical writers spend hours formatting documents, creating PDF files, styling pages, generating tables of contents, and maintaining documentation.&lt;/p&gt;

&lt;p&gt;I wanted one command to do everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Professional HTML rendering&lt;/li&gt;
&lt;li&gt;Beautiful PDF generation using WeasyPrint&lt;/li&gt;
&lt;li&gt;Automatic cover pages&lt;/li&gt;
&lt;li&gt;Automatic Table of Contents&lt;/li&gt;
&lt;li&gt;Syntax highlighting powered by Pygments&lt;/li&gt;
&lt;li&gt;Metadata support&lt;/li&gt;
&lt;li&gt;Modular architecture&lt;/li&gt;
&lt;li&gt;Library index generation&lt;/li&gt;
&lt;li&gt;Streamlit Web Interface&lt;/li&gt;
&lt;li&gt;GitHub Actions CI/CD&lt;/li&gt;
&lt;li&gt;Automated testing&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;The project follows a modular architecture.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Markdown
      │
      ▼
Metadata Parser
      │
      ▼
Markdown Parser
      │
      ▼
HTML Renderer
      │
      ├── Cover Renderer
      ├── TOC Renderer
      ├── Content Renderer
      ├── Footer Renderer
      │
      ▼
PDF Generator
      │
      ▼
Professional PDF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each component has a single responsibility, making the project easy to maintain and extend.&lt;/p&gt;




&lt;h2&gt;
  
  
  Current Statistics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.12&lt;/li&gt;
&lt;li&gt;54 automated tests&lt;/li&gt;
&lt;li&gt;94% test coverage&lt;/li&gt;
&lt;li&gt;GitHub Actions CI&lt;/li&gt;
&lt;li&gt;MIT License&lt;/li&gt;
&lt;li&gt;First Stable Release (v1.0.0)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Technologies
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;Markdown&lt;/li&gt;
&lt;li&gt;WeasyPrint&lt;/li&gt;
&lt;li&gt;Pygments&lt;/li&gt;
&lt;li&gt;PyYAML&lt;/li&gt;
&lt;li&gt;Streamlit&lt;/li&gt;
&lt;li&gt;Pytest&lt;/li&gt;
&lt;li&gt;GitHub Actions&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Open Source
&lt;/h2&gt;

&lt;p&gt;The project is completely open source.&lt;/p&gt;

&lt;p&gt;Contributions, ideas, and feedback are always welcome.&lt;/p&gt;

&lt;p&gt;GitHub Repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/adawy20262026-oss/ahmed-adawy-tech-capsules" rel="noopener noreferrer"&gt;https://github.com/adawy20262026-oss/ahmed-adawy-tech-capsules&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;The roadmap includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100% test coverage&lt;/li&gt;
&lt;li&gt;CLI interface&lt;/li&gt;
&lt;li&gt;Multiple themes&lt;/li&gt;
&lt;li&gt;EPUB export&lt;/li&gt;
&lt;li&gt;PyPI package&lt;/li&gt;
&lt;li&gt;Plugin system&lt;/li&gt;
&lt;li&gt;AI-assisted publishing&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Thank you for reading.&lt;/p&gt;

&lt;p&gt;If you enjoy technical writing, Python, or documentation tooling, I'd love to hear your thoughts.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>🚀 Beyond pip install: The Invisible Memory Leak Destroying AI Microservices</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Mon, 03 Aug 2026 18:25:58 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/beyond-pip-install-the-invisible-memory-leak-destroying-ai-microservices-3b5o</link>
      <guid>https://dev.to/ahmedadawy625/beyond-pip-install-the-invisible-memory-leak-destroying-ai-microservices-3b5o</guid>
      <description>&lt;p&gt;There is a specific kind of developer pain that only happens at 2:00 AM.&lt;/p&gt;

&lt;p&gt;Your code compiles. Your tests pass with flying colors. You build a sleek Python/AI microservice, write a few clean modules,wrap it up nicely, and push it to production or cloud runtime. Everything looks smooth, the demo works, and for the first few minutes, you feel like a genius.&lt;/p&gt;

&lt;p&gt;Then, under real user traffic, the memory consumption starts creeping up. 100MB... 500MB... 1.5GB... Crash. OOMKilled (Out of Memory).&lt;/p&gt;

&lt;p&gt;If you are a Computer Science student, AI Engineer, or Software Developer building data &amp;amp; text pipelines, you’ve probably blamed garbage collection, blamed Streamlit, or blamed Python itself.&lt;/p&gt;

&lt;p&gt;Here is the truth about what actually broke, and how we solved it.&lt;/p&gt;

&lt;p&gt;🛠️ The Problem: Hidden C-Level Memory Leaks in Python Pipelines&lt;/p&gt;

&lt;p&gt;When we build AI wrappers or document transformation tools (converting Markdown/HTML to professional PDFs using packages like weasyprint, cairo, or heavy ML models), we rely heavily on C-extensions under the hood.&lt;/p&gt;

&lt;p&gt;Python developers trust Python’s Automatic Garbage Collector (gc). But here is the catch:&lt;/p&gt;

&lt;p&gt;Python’s garbage collector only manages Python objects. It has ZERO visibility or control over memory allocated at the C-library level (libgobject, libcairo, or C++ bindings).&lt;/p&gt;

&lt;p&gt;When your backend processes requests&lt;/p&gt;

&lt;p&gt;continuously:&lt;/p&gt;

&lt;p&gt;Python creates C-level pointers for rendering or model inference.&lt;/p&gt;

&lt;p&gt;The Python object dies after the request finishes.&lt;/p&gt;

&lt;p&gt;The C-level memory chunk remains allocated in system RAM because the shared library didn’t explicitly trigger a release.&lt;/p&gt;

&lt;p&gt;To the system, your app looks like a memory sponge.&lt;/p&gt;

&lt;p&gt;⚡ The Solution: Process Isolation &amp;amp; Defensive Pipeline Design&lt;/p&gt;

&lt;p&gt;Instead of fighting C-level garbage collection inside the main runtime thread, the architectural solution lies in Process Isolation &amp;amp; Explicit Context Cleanup.&lt;/p&gt;

&lt;p&gt;Here is how to solve it natively in Python:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Isolated Execution via multiprocessing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By offloading heavy rendering or inference tasks into a temporary worker process,&lt;/p&gt;

&lt;p&gt;system RAM is forcibly reclaimed by the OS the moment the worker process terminates.&lt;/p&gt;

&lt;p&gt;import multiprocessing as mp&lt;/p&gt;

&lt;p&gt;def isolated_heavy_task(input_data, output_queue):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Heavy C-library calls / PDF rendering / Heavy AI inference happens here

result = perform_rendering(input_data)

output_queue.put(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;def safe_execution(input_data):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;queue = mp.Queue()

process = mp.Process(target=isolated_heavy_task, args=(input_data, queue))

process.start()



# Retrieve result and ensure process termination

result = queue.get()

process.join()  # OS automatically frees 100% of C-level RAM here

return result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Explicit Ctypes &amp;amp; Temporary File Flushing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are generating heavy PDF artifacts or manipulating raw text buffers:&lt;/p&gt;

&lt;p&gt;Never keep binary streams held indefinitely in application memory.&lt;/p&gt;

&lt;p&gt;Flush explicitly to /tmp storage and use context managers (with) to enforce clean file descriptor closures immediately after execution.&lt;/p&gt;

&lt;p&gt;💡 The Takeaway for Engineers &amp;amp; CS Students&lt;/p&gt;

&lt;p&gt;Building software that works on localhost takes a few hours.&lt;/p&gt;

&lt;p&gt;Building software that survives real-world edge cases, shared libraries, and server constraints takes real architectural engineering.&lt;/p&gt;

&lt;p&gt;Don't just write scripts that execute—build systems that clean up after themselves.&lt;/p&gt;

&lt;p&gt;What’s the most frustrating runtime or memory bug you’ve ever had to debug in production? Let's discuss in the comments below! 🛠️&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>softwareengineering</category>
      <category>devops</category>
    </item>
    <item>
      <title>4 Docker Commands I Use Almost Every Day (And You Probably Will Too)</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Tue, 28 Jul 2026 16:24:00 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/4-docker-commands-i-use-almost-every-day-and-you-probably-will-too-48c9</link>
      <guid>https://dev.to/ahmedadawy625/4-docker-commands-i-use-almost-every-day-and-you-probably-will-too-48c9</guid>
      <description>&lt;p&gt;When I first started using Docker, I kept searching for the same commands over and over again.&lt;/p&gt;

&lt;p&gt;Eventually, I realized that I only needed a handful of commands for 90% of my daily work.&lt;/p&gt;

&lt;p&gt;Here are the four Docker commands I use the most.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Build an Image
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; myapp:v1 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a Docker image from your Dockerfile.&lt;/p&gt;

&lt;p&gt;I always use version tags instead of &lt;code&gt;latest&lt;/code&gt; because it makes deployments easier to track and roll back.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Run a Container
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 &lt;span class="nt"&gt;--name&lt;/span&gt; myapp_instance myapp:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs the container in the background&lt;/li&gt;
&lt;li&gt;Maps port &lt;strong&gt;8080&lt;/strong&gt; on your machine to the container&lt;/li&gt;
&lt;li&gt;Gives the container a readable name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of random container IDs, I can simply reference &lt;code&gt;myapp_instance&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Monitor What's Happening
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;Shows all running containers.&lt;/p&gt;

&lt;p&gt;Need to inspect logs?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker logs &lt;span class="nt"&gt;-f&lt;/span&gt; myapp_instance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-f&lt;/code&gt; flag streams logs in real time, which is incredibly useful when debugging startup issues.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Stop and Remove Cleanly
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop myapp_instance &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker &lt;span class="nb"&gt;rm &lt;/span&gt;myapp_instance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One command.&lt;/p&gt;

&lt;p&gt;No leftover containers.&lt;/p&gt;

&lt;p&gt;No unnecessary clutter.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Small Habit That Saves Time
&lt;/h2&gt;

&lt;p&gt;I almost never use anonymous containers during development.&lt;/p&gt;

&lt;p&gt;Naming containers makes debugging, logging, restarting, and scripting much easier.&lt;/p&gt;

&lt;p&gt;It seems like a tiny habit, but it saves a surprising amount of time over the long run.&lt;/p&gt;




&lt;h3&gt;
  
  
  Quick Reference
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; myapp:v1 &lt;span class="nb"&gt;.&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 &lt;span class="nt"&gt;--name&lt;/span&gt; myapp_instance myapp:v1
docker ps
docker logs &lt;span class="nt"&gt;-f&lt;/span&gt; myapp_instance
docker stop myapp_instance &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker &lt;span class="nb"&gt;rm &lt;/span&gt;myapp_instance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;You don't need to memorize dozens of Docker commands.&lt;/p&gt;

&lt;p&gt;Master these four first, and you'll already handle most day-to-day Docker workflows with confidence.&lt;/p&gt;




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

&lt;p&gt;If you found this useful, save it for later—you'll probably need these commands again.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>security</category>
      <category>datascience</category>
      <category>docker</category>
    </item>
    <item>
      <title>Practical Python Implementation: Simulating Lattice-Based Key Generation</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Mon, 27 Jul 2026 21:18:51 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/practical-python-implementation-simulating-lattice-based-key-generation-47jb</link>
      <guid>https://dev.to/ahmedadawy625/practical-python-implementation-simulating-lattice-based-key-generation-47jb</guid>
      <description>&lt;p&gt;Practical Python Implementation: Simulating Lattice-Based Key Generation&lt;br&gt;
Understanding the mathematical foundation behind post-quantum cryptography using a simple Python implementation.&lt;/p&gt;




&lt;p&gt;Why Lattice Cryptography?&lt;br&gt;
Quantum computers threaten many of today's public-key cryptographic systems, including RSA and Elliptic Curve Cryptography.&lt;br&gt;
One of the strongest candidates for replacing them is Lattice-Based Cryptography, the mathematical foundation behind algorithms such as CRYSTALS-Kyber, selected by NIST for the post-quantum era.&lt;br&gt;
Real implementations involve advanced polynomial algebra and high-dimensional lattices.&lt;br&gt;
However, before diving into those complexities, it's helpful to understand the core mathematical intuition.&lt;/p&gt;




&lt;p&gt;The Idea&lt;br&gt;
Instead of implementing the complete Kyber algorithm, this educational example demonstrates how a hidden lattice basis can generate a public lattice while keeping the private structure secret.&lt;br&gt;
The example illustrates:&lt;br&gt;
Mathematical vectors&lt;/p&gt;

&lt;p&gt;Linear combinations&lt;/p&gt;

&lt;p&gt;Public and private lattice bases&lt;/p&gt;

&lt;p&gt;Shared secret generation&lt;/p&gt;

&lt;p&gt;Why recovering the private basis is computationally difficult&lt;/p&gt;

&lt;p&gt;The objective is education - not production cryptography.&lt;/p&gt;




&lt;p&gt;Python Example&lt;br&gt;
import random&lt;br&gt;
def vector_add(v1, v2):&lt;br&gt;
    return [x + y for x, y in zip(v1, v2)]&lt;br&gt;
def scalar_multiply(scalar, vector):&lt;br&gt;
    return [scalar * x for x in vector]&lt;br&gt;
private_basis_v1 = [1, 0]&lt;br&gt;
private_basis_v2 = [0, 1]&lt;br&gt;
scalar_a = 51&lt;br&gt;
scalar_b = 73&lt;br&gt;
public_v1 = vector_add(&lt;br&gt;
    scalar_multiply(scalar_a, private_basis_v1),&lt;br&gt;
    scalar_multiply(scalar_b, private_basis_v2)&lt;br&gt;
)&lt;br&gt;
secret_multiplier = 142&lt;br&gt;
shared_secret = scalar_multiply(secret_multiplier, public_v1)&lt;br&gt;
print(shared_secret)&lt;/p&gt;




&lt;p&gt;What Happens&amp;nbsp;Here?&lt;br&gt;
The script performs the following steps:&lt;br&gt;
Creates a simple private lattice basis.&lt;/p&gt;

&lt;p&gt;Produces a transformed public basis.&lt;/p&gt;

&lt;p&gt;Simulates a shared secret generated on the public lattice.&lt;/p&gt;

&lt;p&gt;Demonstrates the core intuition behind lattice-based cryptography.&lt;/p&gt;

&lt;p&gt;Although this example uses only two dimensions, the same concepts scale to hundreds of dimensions in real post-quantum cryptographic systems.&lt;/p&gt;




&lt;p&gt;Why This&amp;nbsp;Matters&lt;br&gt;
The security of lattice cryptography does not rely on prime factorization like RSA.&lt;br&gt;
Instead, it depends on the computational hardness of mathematical lattice problems such as:&lt;br&gt;
Shortest Vector Problem (SVP)&lt;/p&gt;

&lt;p&gt;Closest Vector Problem (CVP)&lt;/p&gt;

&lt;p&gt;Learning With Errors (LWE)&lt;/p&gt;

&lt;p&gt;These problems remain difficult even for large-scale quantum computers, making lattice cryptography one of the most promising foundations for future secure communication.&lt;/p&gt;




&lt;p&gt;Educational Purpose&lt;br&gt;
This implementation is intentionally simplified to help students and engineers understand the underlying mathematical concepts before studying full post-quantum algorithms such as:&lt;br&gt;
CRYSTALS-Kyber&lt;/p&gt;

&lt;p&gt;Dilithium&lt;/p&gt;

&lt;p&gt;Falcon&lt;/p&gt;

&lt;p&gt;Learning the intuition first makes advanced cryptographic research much easier to approach.&lt;/p&gt;




&lt;p&gt;Final Thoughts&lt;br&gt;
Modern cybersecurity is increasingly becoming applied mathematics.&lt;br&gt;
Understanding the mathematics behind cryptographic algorithms is just as important as learning to implement them.&lt;br&gt;
Every secure communication protocol begins with mathematical ideas that can often be explained through surprisingly simple code.&lt;/p&gt;




&lt;p&gt;If you enjoyed this article, consider following my work for more content on:&lt;br&gt;
Scientific Python&lt;/p&gt;

&lt;p&gt;Computational Mathematics&lt;/p&gt;

&lt;p&gt;AI Engineering&lt;/p&gt;

&lt;p&gt;Numerical Methods&lt;/p&gt;

&lt;p&gt;Cybersecurity&lt;/p&gt;

&lt;p&gt;Post-Quantum Cryptography&lt;/p&gt;




&lt;h1&gt;
  
  
  Python #CyberSecurity #PostQuantumCryptography #LatticeCryptography #Cryptography #Mathematics #Programming #SoftwareEngineering #OpenSource #AI #NumPy #ComputerScience
&lt;/h1&gt;




</description>
      <category>ai</category>
      <category>programming</category>
      <category>python</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title># Why Every Engineering Student Should Build Simulators Instead of Solving More Equations</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Sun, 26 Jul 2026 23:17:08 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/-why-every-engineering-student-should-build-simulators-instead-of-solving-more-equations-378l</link>
      <guid>https://dev.to/ahmedadawy625/-why-every-engineering-student-should-build-simulators-instead-of-solving-more-equations-378l</guid>
      <description>&lt;p&gt;During my journey studying computational engineering, I noticed something surprising.&lt;/p&gt;

&lt;p&gt;Most textbooks do an excellent job explaining the mathematics behind engineering problems.&lt;/p&gt;

&lt;p&gt;They derive differential equations.&lt;/p&gt;

&lt;p&gt;They prove theorems.&lt;/p&gt;

&lt;p&gt;They analyze physical models.&lt;/p&gt;

&lt;p&gt;But they rarely answer one practical question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we transform those equations into software?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is a huge gap between understanding an equation and building a simulator that actually solves it.&lt;/p&gt;

&lt;p&gt;For example...&lt;/p&gt;

&lt;p&gt;A neutron diffusion equation on paper eventually becomes:&lt;/p&gt;

&lt;p&gt;• A discretized numerical model&lt;br&gt;
• A sparse matrix&lt;br&gt;
• A linear algebra problem&lt;br&gt;
• A Python implementation&lt;br&gt;
• A working scientific application&lt;/p&gt;

&lt;p&gt;That transformation is where real engineering happens.&lt;/p&gt;

&lt;p&gt;Writing software forces you to understand every assumption, every approximation, and every numerical decision.&lt;/p&gt;

&lt;p&gt;That's why I believe:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Code is the ultimate proof of understanding.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This idea is the motivation behind my current open-source work and technical writing.&lt;/p&gt;

&lt;p&gt;I'm building educational projects focused on:&lt;/p&gt;

&lt;p&gt;• Scientific Python&lt;br&gt;
• Numerical Methods&lt;br&gt;
• Software Architecture&lt;br&gt;
• AI Engineering&lt;br&gt;
• Reactor Physics&lt;/p&gt;

&lt;p&gt;The goal isn't simply to explain theory.&lt;/p&gt;

&lt;p&gt;The goal is to transform theory into working software that anyone can study, modify, and improve.&lt;/p&gt;

&lt;p&gt;If engineering education is going to evolve, I think we need more simulation projects—and fewer isolated equations on paper.&lt;/p&gt;

&lt;p&gt;What do you think?&lt;/p&gt;

&lt;p&gt;Should engineering education spend more time teaching students how to build scientific software?&lt;/p&gt;

&lt;h1&gt;
  
  
  Python #ScientificComputing #AI #Engineering #NumPy #OpenSource #SoftwareArchitecture
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>python</category>
      <category>devops</category>
    </item>
    <item>
      <title>Stop Just Solving Equations: How to Build a Live Nuclear Reactor Simulator in Python</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Sat, 25 Jul 2026 11:43:01 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/stop-just-solving-equations-how-to-build-a-live-nuclear-reactor-simulator-in-python-3njk</link>
      <guid>https://dev.to/ahmedadawy625/stop-just-solving-equations-how-to-build-a-live-nuclear-reactor-simulator-in-python-3njk</guid>
      <description>&lt;p&gt;If you've ever opened classics like &lt;em&gt;Introduction to Nuclear Engineering&lt;/em&gt; by Lamarsh or &lt;em&gt;Nuclear Reactor Analysis&lt;/em&gt; by Duderstadt &amp;amp; Hamilton, you've probably admired the elegance of reactor physics.&lt;/p&gt;

&lt;p&gt;You'll derive the neutron transport equation, study diffusion theory, analyze reactor criticality, and work through sophisticated mathematical models.&lt;/p&gt;

&lt;p&gt;But the moment you open VS Code, PyCharm, or Jupyter Notebook and try to build even a simple reactor simulator, you encounter something textbooks rarely discuss:&lt;/p&gt;

&lt;p&gt;A massive engineering gap.&lt;/p&gt;

&lt;p&gt;The gap isn't in the physics.&lt;/p&gt;

&lt;p&gt;It's in translating mathematical models into reliable numerical software.&lt;/p&gt;

&lt;p&gt;The journey actually looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Continuous Physics
        ↓
Numerical Discretization
        ↓
Linear Algebra
        ↓
Algorithms
        ↓
Working Python Code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most classical textbooks master the first step.&lt;/p&gt;

&lt;p&gt;Scientific software lives in the last four.&lt;/p&gt;




&lt;h1&gt;
  
  
  From Differential Equations to Numerical Algorithms
&lt;/h1&gt;

&lt;p&gt;Consider one of the most fundamental equations in reactor physics: the one-dimensional steady-state neutron diffusion equation with an external source.&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
D\frac{d^2\phi}{dx^2}-\Sigma_a\phi+S=0&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;where&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;D&lt;/strong&gt; is the diffusion coefficient&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;φ&lt;/strong&gt; is the neutron flux&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Σa&lt;/strong&gt; is the macroscopic absorption cross section&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S&lt;/strong&gt; is the external neutron source&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Beautiful.&lt;/p&gt;

&lt;p&gt;Elegant.&lt;/p&gt;

&lt;p&gt;Impossible for a computer to solve directly.&lt;/p&gt;

&lt;p&gt;Computers don't understand derivatives.&lt;/p&gt;

&lt;p&gt;They understand numbers.&lt;/p&gt;


&lt;h1&gt;
  
  
  Step 1 — Discretize the Reactor
&lt;/h1&gt;

&lt;p&gt;Instead of treating space as continuous, we divide the reactor into equally spaced nodes.&lt;/p&gt;

&lt;p&gt;Using the finite difference approximation,&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
\frac{d^2\phi}{dx^2}&lt;br&gt;
\approx&lt;br&gt;
\frac{\phi_{i+1}-2\phi_i+\phi_{i-1}}{\Delta x^2}&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;the governing equation becomes&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
D&lt;br&gt;
\left(&lt;br&gt;
\frac{\phi_{i+1}-2\phi_i+\phi_{i-1}}&lt;br&gt;
{\Delta x^2}&lt;/p&gt;
&lt;h2&gt;
  
  
  \right)
&lt;/h2&gt;

&lt;p&gt;\Sigma_a\phi_i&lt;br&gt;
+&lt;/p&gt;
&lt;h1&gt;
  
  
  S_i
&lt;/h1&gt;

&lt;p&gt;0&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;The differential equation has now become a collection of algebraic equations.&lt;/p&gt;


&lt;h1&gt;
  
  
  Step 2 — Build a Linear System
&lt;/h1&gt;

&lt;p&gt;Rearranging the terms gives&lt;/p&gt;

&lt;p&gt;[&lt;/p&gt;
&lt;h2&gt;
  
  
  \left(\frac{D}{\Delta x^2}\right)\phi_{i-1}
&lt;/h2&gt;

&lt;p&gt;\left(&lt;br&gt;
\frac{2D}{\Delta x^2}&lt;br&gt;
+\Sigma_a&lt;br&gt;
\right)\phi_i&lt;br&gt;
+&lt;/p&gt;
&lt;h1&gt;
  
  
  \left(\frac{D}{\Delta x^2}\right)\phi_{i+1}
&lt;/h1&gt;

&lt;p&gt;-S_i&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;Instead of solving calculus,&lt;/p&gt;

&lt;p&gt;we solve&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
A\Phi=B&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;where&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A&lt;/strong&gt; is a tridiagonal matrix representing neutron leakage and absorption,&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Φ&lt;/strong&gt; is the unknown neutron flux vector,&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;B&lt;/strong&gt; contains the external source.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where reactor physics becomes numerical linear algebra.&lt;/p&gt;


&lt;h1&gt;
  
  
  Step 3 — Solve the System in Python
&lt;/h1&gt;

&lt;p&gt;Once the mathematical model has been transformed into matrix form, implementing the solver becomes straightforward.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;solve_1d_reactor_flux&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;core_length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;Sigma_a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;source_strength&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="n"&gt;dx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;core_length&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_nodes&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;core_length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;A&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;B&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;leakage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;D&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;center&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;leakage&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Sigma_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;leakage&lt;/span&gt;
        &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;center&lt;/span&gt;
        &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;leakage&lt;/span&gt;
        &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;source_strength&lt;/span&gt;

    &lt;span class="c1"&gt;# Vacuum boundary conditions
&lt;/span&gt;
    &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="n"&gt;flux&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linalg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;solve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flux&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice something important.&lt;/p&gt;

&lt;p&gt;We are &lt;strong&gt;not performing matrix inversion&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;numpy.linalg.solve()&lt;/code&gt; uses optimized LAPACK routines to solve the linear system directly, which is both faster and numerically more stable than explicitly computing an inverse matrix.&lt;/p&gt;

&lt;p&gt;That distinction matters in scientific computing.&lt;/p&gt;




&lt;h1&gt;
  
  
  Where Classical Textbooks and Scientific Software Meet
&lt;/h1&gt;

&lt;p&gt;Today's learning resources usually fall into one of two categories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Classical reactor physics textbooks
&lt;/h3&gt;

&lt;p&gt;Books by Lamarsh, Duderstadt &amp;amp; Hamilton, and Stacey provide the theoretical foundation needed to understand diffusion theory, neutron transport, reactor kinetics, and nuclear engineering.&lt;/p&gt;

&lt;p&gt;They explain &lt;strong&gt;why the equations work&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Production simulation codes
&lt;/h3&gt;

&lt;p&gt;Projects like OpenMC, Serpent, and MCNP are industrial-strength scientific codes capable of solving extremely sophisticated neutron transport problems.&lt;/p&gt;

&lt;p&gt;They demonstrate &lt;strong&gt;how professionals simulate reactors&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, for many students and software engineers, there is still a missing middle layer:&lt;/p&gt;

&lt;p&gt;How do you build a simulator yourself?&lt;/p&gt;

&lt;p&gt;How do you translate equations into maintainable Python code?&lt;/p&gt;

&lt;p&gt;How do you organize numerical algorithms into software architecture?&lt;/p&gt;

&lt;p&gt;That bridge is rarely discussed.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Different Learning Perspective
&lt;/h1&gt;

&lt;p&gt;Instead of replacing classical reactor physics books, numerical programming complements them.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Resource&lt;/th&gt;
&lt;th&gt;Primary Focus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lamarsh&lt;/td&gt;
&lt;td&gt;Reactor physics fundamentals&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duderstadt &amp;amp; Hamilton&lt;/td&gt;
&lt;td&gt;Mathematical reactor analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stacey&lt;/td&gt;
&lt;td&gt;Advanced reactor engineering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Practical Python implementations&lt;/td&gt;
&lt;td&gt;Numerical algorithms and simulator architecture&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These aren't competing approaches.&lt;/p&gt;

&lt;p&gt;They're different layers of the same discipline.&lt;/p&gt;

&lt;p&gt;Physics explains the model.&lt;/p&gt;

&lt;p&gt;Numerical analysis transforms the model.&lt;/p&gt;

&lt;p&gt;Software engineering turns the numerical method into a maintainable simulator.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Writing code forces us to confront every assumption hidden inside an equation.&lt;/p&gt;

&lt;p&gt;Boundary conditions.&lt;/p&gt;

&lt;p&gt;Grid spacing.&lt;/p&gt;

&lt;p&gt;Matrix assembly.&lt;/p&gt;

&lt;p&gt;Numerical stability.&lt;/p&gt;

&lt;p&gt;Data structures.&lt;/p&gt;

&lt;p&gt;Algorithmic complexity.&lt;/p&gt;

&lt;p&gt;That is why implementing a physical model is often the deepest form of understanding it.&lt;/p&gt;

&lt;p&gt;Equations describe reality.&lt;/p&gt;

&lt;p&gt;Algorithms make them computable.&lt;/p&gt;

&lt;p&gt;Software makes them useful.&lt;/p&gt;

&lt;p&gt;If you're interested in exploring this bridge between reactor physics and practical scientific programming, I've been documenting my own approach in a Leanpub book focused on building reactor simulators from scratch using Python and NumPy.&lt;/p&gt;

&lt;p&gt;I hope it helps make the transition from equations on paper to working simulation software a little less intimidating.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>githubcopilot</category>
      <category>programming</category>
    </item>
    <item>
      <title>Mind the Chasm: Bridging the Gap Between Reactor Physics Equations and Python Simulators</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Sat, 25 Jul 2026 11:40:15 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/mind-the-chasm-bridging-the-gap-between-reactor-physics-equations-and-python-simulators-ecm</link>
      <guid>https://dev.to/ahmedadawy625/mind-the-chasm-bridging-the-gap-between-reactor-physics-equations-and-python-simulators-ecm</guid>
      <description>&lt;p&gt;If you've ever opened classics like &lt;em&gt;Introduction to Nuclear Engineering&lt;/em&gt; by Lamarsh or &lt;em&gt;Nuclear Reactor Analysis&lt;/em&gt; by Duderstadt &amp;amp; Hamilton, you've probably admired the elegance of reactor physics.&lt;/p&gt;

&lt;p&gt;You'll derive the neutron transport equation, study diffusion theory, analyze reactor criticality, and work through sophisticated mathematical models.&lt;/p&gt;

&lt;p&gt;But the moment you open VS Code, PyCharm, or Jupyter Notebook and try to build even a simple reactor simulator, you encounter something textbooks rarely discuss:&lt;/p&gt;

&lt;p&gt;A massive engineering gap.&lt;/p&gt;

&lt;p&gt;The gap isn't in the physics.&lt;/p&gt;

&lt;p&gt;It's in translating mathematical models into reliable numerical software.&lt;/p&gt;

&lt;p&gt;The journey actually looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Continuous Physics
        ↓
Numerical Discretization
        ↓
Linear Algebra
        ↓
Algorithms
        ↓
Working Python Code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most classical textbooks master the first step.&lt;/p&gt;

&lt;p&gt;Scientific software lives in the last four.&lt;/p&gt;




&lt;h1&gt;
  
  
  From Differential Equations to Numerical Algorithms
&lt;/h1&gt;

&lt;p&gt;Consider one of the most fundamental equations in reactor physics: the one-dimensional steady-state neutron diffusion equation with an external source.&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
D\frac{d^2\phi}{dx^2}-\Sigma_a\phi+S=0&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;where&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;D&lt;/strong&gt; is the diffusion coefficient&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;φ&lt;/strong&gt; is the neutron flux&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Σa&lt;/strong&gt; is the macroscopic absorption cross section&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S&lt;/strong&gt; is the external neutron source&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Beautiful.&lt;/p&gt;

&lt;p&gt;Elegant.&lt;/p&gt;

&lt;p&gt;Impossible for a computer to solve directly.&lt;/p&gt;

&lt;p&gt;Computers don't understand derivatives.&lt;/p&gt;

&lt;p&gt;They understand numbers.&lt;/p&gt;


&lt;h1&gt;
  
  
  Step 1 — Discretize the Reactor
&lt;/h1&gt;

&lt;p&gt;Instead of treating space as continuous, we divide the reactor into equally spaced nodes.&lt;/p&gt;

&lt;p&gt;Using the finite difference approximation,&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
\frac{d^2\phi}{dx^2}&lt;br&gt;
\approx&lt;br&gt;
\frac{\phi_{i+1}-2\phi_i+\phi_{i-1}}{\Delta x^2}&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;the governing equation becomes&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
D&lt;br&gt;
\left(&lt;br&gt;
\frac{\phi_{i+1}-2\phi_i+\phi_{i-1}}&lt;br&gt;
{\Delta x^2}&lt;/p&gt;
&lt;h2&gt;
  
  
  \right)
&lt;/h2&gt;

&lt;p&gt;\Sigma_a\phi_i&lt;br&gt;
+&lt;/p&gt;
&lt;h1&gt;
  
  
  S_i
&lt;/h1&gt;

&lt;p&gt;0&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;The differential equation has now become a collection of algebraic equations.&lt;/p&gt;


&lt;h1&gt;
  
  
  Step 2 — Build a Linear System
&lt;/h1&gt;

&lt;p&gt;Rearranging the terms gives&lt;/p&gt;

&lt;p&gt;[&lt;/p&gt;
&lt;h2&gt;
  
  
  \left(\frac{D}{\Delta x^2}\right)\phi_{i-1}
&lt;/h2&gt;

&lt;p&gt;\left(&lt;br&gt;
\frac{2D}{\Delta x^2}&lt;br&gt;
+\Sigma_a&lt;br&gt;
\right)\phi_i&lt;br&gt;
+&lt;/p&gt;
&lt;h1&gt;
  
  
  \left(\frac{D}{\Delta x^2}\right)\phi_{i+1}
&lt;/h1&gt;

&lt;p&gt;-S_i&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;Instead of solving calculus,&lt;/p&gt;

&lt;p&gt;we solve&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
A\Phi=B&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;where&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A&lt;/strong&gt; is a tridiagonal matrix representing neutron leakage and absorption,&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Φ&lt;/strong&gt; is the unknown neutron flux vector,&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;B&lt;/strong&gt; contains the external source.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where reactor physics becomes numerical linear algebra.&lt;/p&gt;


&lt;h1&gt;
  
  
  Step 3 — Solve the System in Python
&lt;/h1&gt;

&lt;p&gt;Once the mathematical model has been transformed into matrix form, implementing the solver becomes straightforward.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;solve_1d_reactor_flux&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;core_length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;Sigma_a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;source_strength&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="n"&gt;dx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;core_length&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_nodes&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;core_length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;A&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;B&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;leakage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;D&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;center&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;leakage&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Sigma_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_nodes&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;leakage&lt;/span&gt;
        &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;center&lt;/span&gt;
        &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;leakage&lt;/span&gt;
        &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;source_strength&lt;/span&gt;

    &lt;span class="c1"&gt;# Vacuum boundary conditions
&lt;/span&gt;
    &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="n"&gt;flux&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linalg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;solve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flux&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice something important.&lt;/p&gt;

&lt;p&gt;We are &lt;strong&gt;not performing matrix inversion&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;numpy.linalg.solve()&lt;/code&gt; uses optimized LAPACK routines to solve the linear system directly, which is both faster and numerically more stable than explicitly computing an inverse matrix.&lt;/p&gt;

&lt;p&gt;That distinction matters in scientific computing.&lt;/p&gt;




&lt;h1&gt;
  
  
  Where Classical Textbooks and Scientific Software Meet
&lt;/h1&gt;

&lt;p&gt;Today's learning resources usually fall into one of two categories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Classical reactor physics textbooks
&lt;/h3&gt;

&lt;p&gt;Books by Lamarsh, Duderstadt &amp;amp; Hamilton, and Stacey provide the theoretical foundation needed to understand diffusion theory, neutron transport, reactor kinetics, and nuclear engineering.&lt;/p&gt;

&lt;p&gt;They explain &lt;strong&gt;why the equations work&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Production simulation codes
&lt;/h3&gt;

&lt;p&gt;Projects like OpenMC, Serpent, and MCNP are industrial-strength scientific codes capable of solving extremely sophisticated neutron transport problems.&lt;/p&gt;

&lt;p&gt;They demonstrate &lt;strong&gt;how professionals simulate reactors&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, for many students and software engineers, there is still a missing middle layer:&lt;/p&gt;

&lt;p&gt;How do you build a simulator yourself?&lt;/p&gt;

&lt;p&gt;How do you translate equations into maintainable Python code?&lt;/p&gt;

&lt;p&gt;How do you organize numerical algorithms into software architecture?&lt;/p&gt;

&lt;p&gt;That bridge is rarely discussed.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Different Learning Perspective
&lt;/h1&gt;

&lt;p&gt;Instead of replacing classical reactor physics books, numerical programming complements them.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Resource&lt;/th&gt;
&lt;th&gt;Primary Focus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lamarsh&lt;/td&gt;
&lt;td&gt;Reactor physics fundamentals&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duderstadt &amp;amp; Hamilton&lt;/td&gt;
&lt;td&gt;Mathematical reactor analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stacey&lt;/td&gt;
&lt;td&gt;Advanced reactor engineering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Practical Python implementations&lt;/td&gt;
&lt;td&gt;Numerical algorithms and simulator architecture&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These aren't competing approaches.&lt;/p&gt;

&lt;p&gt;They're different layers of the same discipline.&lt;/p&gt;

&lt;p&gt;Physics explains the model.&lt;/p&gt;

&lt;p&gt;Numerical analysis transforms the model.&lt;/p&gt;

&lt;p&gt;Software engineering turns the numerical method into a maintainable simulator.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Writing code forces us to confront every assumption hidden inside an equation.&lt;/p&gt;

&lt;p&gt;Boundary conditions.&lt;/p&gt;

&lt;p&gt;Grid spacing.&lt;/p&gt;

&lt;p&gt;Matrix assembly.&lt;/p&gt;

&lt;p&gt;Numerical stability.&lt;/p&gt;

&lt;p&gt;Data structures.&lt;/p&gt;

&lt;p&gt;Algorithmic complexity.&lt;/p&gt;

&lt;p&gt;That is why implementing a physical model is often the deepest form of understanding it.&lt;/p&gt;

&lt;p&gt;Equations describe reality.&lt;/p&gt;

&lt;p&gt;Algorithms make them computable.&lt;/p&gt;

&lt;p&gt;Software makes them useful.&lt;/p&gt;

&lt;p&gt;If you're interested in exploring this bridge between reactor physics and practical scientific programming, I've been documenting my own approach in a Leanpub book focused on building reactor simulators from scratch using Python and NumPy.&lt;/p&gt;

&lt;p&gt;I hope it helps make the transition from equations on paper to working simulation software a little less intimidating.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why Raw Python Loops Are Bottlenecking Your AI Models (And How to Fix It)</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Fri, 24 Jul 2026 22:16:02 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/why-raw-python-loops-are-bottlenecking-your-ai-models-and-how-to-fix-it-1de8</link>
      <guid>https://dev.to/ahmedadawy625/why-raw-python-loops-are-bottlenecking-your-ai-models-and-how-to-fix-it-1de8</guid>
      <description>&lt;p&gt;Python is undisputed king of the Artificial Intelligence and Machine Learning ecosystem. It’s elegant, highly expressive, and lets us prototype complex architectures in a few lines of code. But Python has a dark, dirty secret that every AI engineer eventually crashes into: Native for loops are devastatingly slow.&lt;br&gt;
​When you are preprocessing massive datasets, calculating custom loss functions, or manipulating tensor vectors, throwing a standard Python loop at the problem is like driving a tractor on a highway.&lt;br&gt;
​Let’s look at why this happens and how we can achieve a 100x+ speedup using Hyper-Drive vectorization techniques.&lt;br&gt;
​The Bottleneck: Why Python Loops Fail at Scale&lt;br&gt;
​To understand the latency, we have to look under the hood of the CPython interpreter. Every time a standard Python loop runs:&lt;br&gt;
​Dynamic Type Checking: Python checks the data type of the variable on every single iteration.&lt;br&gt;
​Interpreter Overhead: The loop overhead itself adds massive bytecode execution lag.&lt;br&gt;
​Memory Fragmentation: Appending to standard Python lists doesn't guarantee contiguous memory allocation, destroying CPU cache efficiency.&lt;br&gt;
​When dealing with 1,000,000 data points in an AI pipeline, this translates to agonizingly slow execution times.&lt;br&gt;
​The Hyper-Drive Solution: Vectorization&lt;br&gt;
​Instead of processing elements sequentially (Single Instruction, Single Data), we shift the workload to optimized low-level machine code via NumPy, utilizing SIMD (Single Instruction, Multiple Data) architectures. This allows the CPU (or GPU) to execute operations on entire arrays simultaneously at native C speeds.&lt;br&gt;
​The Head-to-Head Benchmark&lt;br&gt;
​Let’s put theory into practice. Here is a clean, production-ready benchmark script comparing a traditional raw Python loop against a vectorized implementation.&lt;br&gt;
import time&lt;br&gt;
import numpy as np&lt;/p&gt;

&lt;h1&gt;
  
  
  Size of the dataset (1 Million elements)
&lt;/h1&gt;

&lt;p&gt;N = 1000000&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Slow Pure Python Loop Approach
&lt;/h1&gt;

&lt;p&gt;def slow_loop(arr):&lt;br&gt;
    result = []&lt;br&gt;
    for x in arr:&lt;br&gt;
        # Simulating a basic linear mathematical transformation&lt;br&gt;
        result.append(x * 2 + 5)&lt;br&gt;
    return result&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Fast Vectorized Implementation
&lt;/h1&gt;

&lt;p&gt;def fast_vectorized(arr):&lt;br&gt;
    return arr * 2 + 5&lt;/p&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == "&lt;strong&gt;main&lt;/strong&gt;":&lt;br&gt;
    # Prepare data allocations&lt;br&gt;
    data_list = list(range(N))&lt;br&gt;
    data_array = np.arange(N)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("🚀 Running performance benchmarks...")

# Timing the pure python loop
start = time.time()
res_slow = slow_loop(data_list)
end = time.time()
time_slow = end - start
print(f"🛑 Pure Python Loop Time: {time_slow:.4f} seconds")

# Timing the vectorized execution
start = time.time()
res_fast = fast_vectorized(data_array)
end = time.time()
time_fast = end - start
print(f"⚡ Vectorized Hyper-Drive Time: {time_fast:.4f} seconds")

# Calculating the speedup factor
print(f"🔥 Speedup Factor: {time_slow / time_fast:.1f}x Faster!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The Results: The Numbers Don't Lie&lt;br&gt;
​When running this setup on a standard development machine, the output is striking:&lt;br&gt;
​Pure Python Loop Time: ~0.0850 seconds&lt;br&gt;
​Vectorized Implementation Time: ~0.0007 seconds&lt;br&gt;
​Performance Jump: ~120x Faster!&lt;br&gt;
​By eliminating the Python interpreter's loop overhead, the computation finishes in a fraction of a millisecond. In a real-world AI pipeline training on gigabytes of data, this optimization saves hours of compute time and slashes cloud infrastructure costs.&lt;br&gt;
​Going Deeper: Beyond Vectorization&lt;br&gt;
​Vectorization is just the first step. When building high-performance AI architectures, you eventually need to cross the bridge from high-level Python wrappers down to bare-metal hardware optimization, GPU compilation, and custom machine code.&lt;br&gt;
​If you want to master the underlying mathematical frameworks and hardware-level algorithms that power ultra-fast AI execution, check out my comprehensive blueprint book on Leanpub:&lt;br&gt;
👉 The Hyper-Drive Algorithms: From Raw Python Formulas to High-Performance GPU &amp;amp; Machine Code&lt;br&gt;
​Stop letting unoptimized loops throttle your machine learning models. Vectorize your pipelines, keep your data contiguous, and let the hardware do what it was built to do.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>python</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Stop Running Your Docker Containers as Root: A Production-Ready Hardening Guide</title>
      <dc:creator>Ahmed Adawy </dc:creator>
      <pubDate>Wed, 22 Jul 2026 10:34:34 +0000</pubDate>
      <link>https://dev.to/ahmedadawy625/stop-running-your-docker-containers-as-root-a-production-ready-hardening-guide-1579</link>
      <guid>https://dev.to/ahmedadawy625/stop-running-your-docker-containers-as-root-a-production-ready-hardening-guide-1579</guid>
      <description>&lt;p&gt;The silent security flaw in your Dockerfile and how to fix it in 30 seconds using Node.js and Linux best practices.&lt;br&gt;
​When you’ve finally built your application, tested it locally, wrapped it nicely inside a Docker container, and pushed it to production, it works flawlessly. You feel like a DevOps wizard.&lt;br&gt;
​But then, an automated security audit flags your deployment, or worse, a malicious actor exploits a dependency vulnerability and gains absolute control over your host cloud server.&lt;br&gt;
​Why? Because of one silent, pervasive mistake: You ran your Docker container as root.&lt;br&gt;
​By default, unless specified otherwise, Docker runs every process inside the container with root privileges. If an attacker manages to break out of your application process via a container breakout vulnerability, they instantly inherit root access to your entire virtual private server (VPS).&lt;br&gt;
​In this quick guide, we’ll dismantle this problem, fix it from scratch, and show you how easy it is to deploy battle-tested, secure containers.&lt;br&gt;
​The Problem: The Naive Dockerfile&lt;br&gt;
​Look at this common Dockerfile configuration used by thousands of developers daily:&lt;/p&gt;

&lt;h1&gt;
  
  
  A standard, but insecure Node.js setup
&lt;/h1&gt;

&lt;p&gt;FROM node:18-alpine&lt;br&gt;
WORKDIR /app&lt;br&gt;
COPY package*.json ./&lt;br&gt;
RUN npm ci --only=production&lt;br&gt;
COPY . .&lt;br&gt;
EXPOSE 3000&lt;/p&gt;

&lt;h1&gt;
  
  
  Trapped! Running implicitly as root
&lt;/h1&gt;

&lt;p&gt;CMD ["node", "server.js"]&lt;br&gt;
If you inspect the running processes inside this container on your VPS, you’ll notice that node server.js is executed by user ID 0 (root). If your app gets compromised, your host system is compromised.&lt;br&gt;
​The Solution: Dropping Privileges (Non-Root Hardening)&lt;br&gt;
​Fixing this doesn't require complex orchestration tools. It only requires understanding the underlying Linux user environment and leveraging built-in image features. Official images like node already come with a secure, pre-configured non-root user called node.&lt;br&gt;
​Here is the production-ready, hardened version of the exact same environment:&lt;br&gt;
FROM node:18-alpine&lt;br&gt;
WORKDIR /app&lt;/p&gt;

&lt;h1&gt;
  
  
  Copy dependency manifests
&lt;/h1&gt;

&lt;p&gt;COPY package*.json ./&lt;/p&gt;

&lt;h1&gt;
  
  
  Install production dependencies only
&lt;/h1&gt;

&lt;p&gt;RUN npm ci --only=production&lt;/p&gt;

&lt;h1&gt;
  
  
  Copy application source code
&lt;/h1&gt;

&lt;p&gt;COPY . .&lt;/p&gt;

&lt;p&gt;EXPOSE 3000&lt;/p&gt;

&lt;h1&gt;
  
  
  The Magic Line: Instantly switch from root to limited privileges&lt;a href="https://dev.tostart_span"&gt;span_0&lt;/a&gt;&lt;a href="https://dev.toend_span"&gt;span_0&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;USER node&lt;/p&gt;

&lt;p&gt;CMD ["node", "server.js"]&lt;br&gt;
By simply introducing USER node before your execution command, the application drops its root capabilities completely. If a vulnerability is triggered, the blast radius is confined tightly inside a sandboxed, low-privilege environment.&lt;br&gt;&lt;br&gt;
​The Production Cleanup &amp;amp; Firewall Layer&lt;br&gt;
​Securing your container is only half the battle; you must also secure the Linux environment hosting it. When managing a VPS, ensuring proper networking and storage hygiene is crucial.&lt;br&gt;&lt;br&gt;
​1. Hardening the Network (UFW Firewall)&lt;br&gt;
​Never leave your server ports completely exposed to the open web. Before launching your containers, restrict incoming traffic using the Uncomplicated Firewall (UFW) to allow only essential administration and web traffic:  &lt;/p&gt;

&lt;h1&gt;
  
  
  Deny everything by default, allow standard management and web ports&lt;a href="https://dev.tostart_span"&gt;span_6&lt;/a&gt;&lt;a href="https://dev.toend_span"&gt;span_6&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;sudo ufw default deny incoming&lt;br&gt;
sudo ufw default allow outgoing&lt;br&gt;
sudo ufw allow 22/tcp   # SSH&lt;br&gt;
sudo ufw allow 80/tcp   # HTTP&lt;br&gt;
sudo ufw allow 443/tcp  # HTTPS&lt;br&gt;
sudo ufw enable&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reclaiming Disk Space
​Building multiple versions of images can quickly fill up your server's storage. Run a strict maintenance loop to prune dangling layers, unused containers, and unreferenced volumes:
docker system prune -a --volumes
Stop Guessing Your Production Configs
​Modern software development requires moving fast, but local development and production deployments shouldn't feel like two completely different worlds. You shouldn't have to wade through 500 pages of dense theoretical text just to spin up a secure, multi-container architecture.
​If you want a condensed, zero-fluff reference guide packed with ready-to-use Linux CLI commands, production multi-container docker-compose setups with databases, and ultimate security checklists, check out my latest handbook:
​👉 The Production-Ready Docker &amp;amp; Linux Pocket Guide&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmpy5bdv0yeny83hol03v.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmpy5bdv0yeny83hol03v.jpg" alt=" " width="800" height="1071"&gt;&lt;/a&gt;&lt;br&gt;
​What is your container security routine? Do you always implement non-root users in your pipelines, or do you rely entirely on cloud-level firewalls to protect your workloads? Let's discuss your deployment setup in the comments below!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>docker</category>
      <category>security</category>
    </item>
  </channel>
</rss>
