<?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: Arif Aydın</title>
    <description>The latest articles on DEV Community by Arif Aydın (@arifaydindev).</description>
    <link>https://dev.to/arifaydindev</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%2F1928624%2F204bfc43-4a20-4361-9396-d79210de7abf.png</url>
      <title>DEV Community: Arif Aydın</title>
      <link>https://dev.to/arifaydindev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arifaydindev"/>
    <language>en</language>
    <item>
      <title>I built modulix. it does regenerate your codebase.</title>
      <dc:creator>Arif Aydın</dc:creator>
      <pubDate>Fri, 20 Nov 2026 13:37:26 +0000</pubDate>
      <link>https://dev.to/arifaydindev/i-built-modulix-it-does-regenerate-your-codebase-fk8</link>
      <guid>https://dev.to/arifaydindev/i-built-modulix-it-does-regenerate-your-codebase-fk8</guid>
      <description>&lt;p&gt;Selling a product to one customer is simple. The moment a second customer says "we don't want the billing module, but we do want stock", things get messy. Teams usually pick one of three paths:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A branch per customer.&lt;/strong&gt; Fine for a week, then every fix has to be carried across five branches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;if (features.billing)&lt;/code&gt; sprinkled everywhere.&lt;/strong&gt; The disabled module's code still ships, and its tables still sit in the database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete things by hand before delivery.&lt;/strong&gt; It works once. The second time, nobody remembers how it was done.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://github.com/arifaydin16/modulix" rel="noopener noreferrer"&gt;modulix&lt;/a&gt; is an open-source CLI I wrote to avoid all three: you mark modules inside the source code and switch them on or off with one command. It's on npm as &lt;a href="https://www.npmjs.com/package/modulix" rel="noopener noreferrer"&gt;&lt;code&gt;modulix&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  the idea: tags as comments
&lt;/h2&gt;

&lt;p&gt;modulix adds no language-specific syntax. You wrap the code that belongs to a module between a start and an end tag, written in that language's own comment style:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// @auth users-table&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;authService&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AuthService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;setupAuthListeners&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;authService&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// @!auth users-table&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;@auth users-table&lt;/code&gt; opens the block, &lt;code&gt;@!auth users-table&lt;/code&gt; closes it. &lt;code&gt;auth&lt;/code&gt; is the module, &lt;code&gt;users-table&lt;/code&gt; is the block. Because the tags are comments, the code compiles and runs exactly as if modulix weren't there.&lt;/p&gt;

&lt;p&gt;The same works in HTML, CSS and SQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- @billing invoice-panel --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"billing-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;Invoices&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- @!billing invoice-panel --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- @auth users-schema&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="kt"&gt;SERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="kt"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;-- @!auth users-schema&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript, TypeScript, PHP, HTML, CSS/SCSS/LESS, Go, C# and SQL files are supported today. If a whole file belongs to a module, put &lt;code&gt;@@module block&lt;/code&gt; on its first line: the file is deleted when the module is disabled and restored when it's enabled again.&lt;/p&gt;

&lt;h2&gt;
  
  
  the flow: tag, save a template, sync
&lt;/h2&gt;

&lt;p&gt;Using modulix in a project takes four steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install -g modulix   &lt;span class="c"&gt;# global CLI, short alias: mdl&lt;/span&gt;
mdl init                 &lt;span class="c"&gt;# creates .modulix/config.json in the project&lt;/span&gt;
mdl config &lt;span class="nb"&gt;set&lt;/span&gt; includes add .php
mdl config &lt;span class="nb"&gt;set&lt;/span&gt; excludes add node_modules
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you declare modules and save the current state of the code as a &lt;strong&gt;template&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mdl modules add          &lt;span class="c"&gt;# e.g. auth, billing&lt;/span&gt;
mdl templates add base-template
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The template is what makes this safe: when a module is disabled, its blocks are actually removed from the source. When you enable it again, the content is written back from the template. The disabled module's code is never in the delivered project, but it's never lost either.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mdl modules disable billing
mdl modules sync         &lt;span class="c"&gt;# clears blocks of disabled modules, fills active ones from the template&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  the database follows the same rules
&lt;/h2&gt;

&lt;p&gt;Removing the code but leaving the tables is half a job. modulix can filter the template's SQL schema (for example &lt;code&gt;schema.sql&lt;/code&gt;) by the active modules and apply it. MySQL and PostgreSQL are supported:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mdl config &lt;span class="nb"&gt;set&lt;/span&gt; db                 &lt;span class="c"&gt;# interactive wizard for connection details&lt;/span&gt;
mdl db sync base-template         &lt;span class="c"&gt;# applies the filtered schema&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command drops the current schema and imports the filtered structure, so take a backup before running it anywhere near real data. There are commands for that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mdl db backup create v1-db-backup
mdl db backup swap v1-db-backup   &lt;span class="c"&gt;# roll back if needed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  a way back: codebase backups
&lt;/h2&gt;

&lt;p&gt;Since sync rewrites files, modulix can also snapshot the filesystem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mdl backup create initial-state
mdl backup status initial-state   &lt;span class="c"&gt;# created, modified and deleted files&lt;/span&gt;
mdl backup swap initial-state     &lt;span class="c"&gt;# restore the workspace to that point&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;status&lt;/code&gt; shows exactly what a sync changed; taking a backup before a sync and checking it afterwards is a good habit.&lt;/p&gt;

&lt;h2&gt;
  
  
  where it fits, and where it doesn't
&lt;/h2&gt;

&lt;p&gt;modulix works well when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you ship the same product in different packages (basic, pro, enterprise),&lt;/li&gt;
&lt;li&gt;a customer must not receive the code of a module they didn't buy,&lt;/li&gt;
&lt;li&gt;you want the client and server folders of a monorepo kept in sync with one module list (&lt;code&gt;mdl config set folder&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is not the right tool for features that toggle at runtime (feature flags, A/B tests). modulix decides at build time, before delivery. For something that changes per user, you still want a flag system.&lt;/p&gt;

&lt;h2&gt;
  
  
  try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install -g modulix
mdl init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you interest you can check my &lt;a href="https://arifaydin.dev/blog/modulix" rel="noopener noreferrer"&gt;website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The source and a full example walkthrough are &lt;a href="https://github.com/arifaydin16/modulix" rel="noopener noreferrer"&gt;on GitHub&lt;/a&gt;. Issues for bugs, ideas or support for another language are welcome.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
