<?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: UnplugCharger</title>
    <description>The latest articles on DEV Community by UnplugCharger (@unplugcharger).</description>
    <link>https://dev.to/unplugcharger</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F636945%2F444a5f2c-3208-4f64-901e-de07e2a2cd8f.jpeg</url>
      <title>DEV Community: UnplugCharger</title>
      <link>https://dev.to/unplugcharger</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/unplugcharger"/>
    <language>en</language>
    <item>
      <title>🚀 Building a Serverless Platform: Systems Programming 🚀</title>
      <dc:creator>UnplugCharger</dc:creator>
      <pubDate>Wed, 21 May 2025 09:27:23 +0000</pubDate>
      <link>https://dev.to/unplugcharger/building-a-serverless-platform-systems-programming-2330</link>
      <guid>https://dev.to/unplugcharger/building-a-serverless-platform-systems-programming-2330</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/6njop7F92hQ"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;If you've ever felt stuck building yet another todo app and craved a project that dives into the guts of how systems work, you're in the right place. Let me take you through my journey of building a lightweight serverless platform from scratch—a project that taught me more about containerization, process management, and API design than any tutorial ever could.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Heads up:&lt;/strong&gt; This is an educational project, not production-ready! &lt;a href="https://github.com/UnplugCharger/serverless" rel="noopener noreferrer"&gt;Check out the full code here.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Build a Serverless Platform?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Serverless computing is everywhere, but how does it actually work under the hood? I wanted to peel back the layers and explore:&lt;/p&gt;

&lt;p&gt;🛠️ &lt;strong&gt;Systems Programming Challenges:&lt;/strong&gt; File handling, process isolation, security.&lt;br&gt;&lt;br&gt;
🧩 &lt;strong&gt;Practical Utility:&lt;/strong&gt; Build something usable, not just theoretical.&lt;br&gt;&lt;br&gt;
📦 &lt;strong&gt;Modern Tech Stack:&lt;/strong&gt; Docker, REST APIs, multi-language support.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Spoiler:&lt;/em&gt; It was harder—and more rewarding—than I expected.&lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;How It Works: Breaking Down the Core Components&lt;/strong&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Handling User Code Safely
&lt;/h3&gt;

&lt;p&gt;When users upload a zip file, the platform must extract it without risking security flaws like the infamous zip slip vulnerability:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// Simplified code snippet for secure zip extraction&lt;/span&gt;
&lt;span class="n"&gt;filePath&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destDir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HasPrefix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destDir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PathSeparator&lt;/span&gt;&lt;span class="p"&gt;))&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;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"illegal file path: %s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Key Takeaways:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Validate every file path to prevent directory escapes.&lt;/li&gt;
&lt;li&gt;Use Go's &lt;code&gt;os&lt;/code&gt; and &lt;code&gt;filepath&lt;/code&gt; libraries for safe file operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Detecting Programming Languages
&lt;/h3&gt;

&lt;p&gt;The platform supports Python and Go (for now!). A simple but effective approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// Check for Python files&lt;/span&gt;
&lt;span class="n"&gt;pythonFiles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"*.py"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pythonFiles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Why This Matters:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Introduces pattern matching and filesystem inspection.&lt;/li&gt;
&lt;li&gt;Lays groundwork for multi-language support.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Docker: The Heart of Isolation
&lt;/h3&gt;

&lt;p&gt;Running untrusted code safely meant leaning into Docker. Here’s the workflow:&lt;/p&gt;

&lt;p&gt;Build a Docker image from the user’s code.&lt;/p&gt;

&lt;p&gt;Run containers with strict resource limits (CPU, memory, network).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// Simplified Docker execution with security constraints&lt;/span&gt;
&lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;exec&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Command&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"docker"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"run"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="s"&gt;"--read-only"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c"&gt;// No writes to filesystem&lt;/span&gt;
    &lt;span class="s"&gt;"--network=none"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c"&gt;// No internet access&lt;/span&gt;
    &lt;span class="s"&gt;"--memory=128m"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c"&gt;// Memory cap&lt;/span&gt;
    &lt;span class="n"&gt;imageTag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Lessons Learned:
&lt;/h3&gt;

&lt;p&gt;Process management in Go using exec.Command.&lt;/p&gt;

&lt;p&gt;Security through isolation: Containers run without privileges or network access.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The API Layer
&lt;/h3&gt;

&lt;p&gt;A REST API ties everything together. For example, submitting a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;submitFunctionHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Handle file upload, extract, build, and store metadata&lt;/span&gt;
    &lt;span class="n"&gt;respondWithJSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCreated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;{}{&lt;/span&gt;
        &lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Function '%s' deployed!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Design Choices:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Used Go standard library net package for routing.&lt;/li&gt;
&lt;li&gt;Middleware for logging, timeout handling, and error recovery.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Hardest Parts (And What I Learned)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔒 Security Challenges
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zip Slip Vulnerability&lt;/strong&gt;: A single path validation oversight could let attackers overwrite system files&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Limits&lt;/strong&gt;: Implementing strict CPU/memory constraints via Docker to prevent abuse&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Input Sanitization&lt;/strong&gt;: Learned to never trust user input - always validate and sanitize&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🐛 Debugging Nightmares
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exit Code 124&lt;/strong&gt;: Spent hours diagnosing Docker's mysterious timeout error&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Orphaned Containers&lt;/strong&gt;: The costly lesson of forgetting &lt;code&gt;--rm&lt;/code&gt; flag (thousands of dead containers later...)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's Missing? (Future Improvements)
&lt;/h2&gt;

&lt;p&gt;While functional, this isn't production-grade like AWS Lambda. Here's the roadmap:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Persistent Storage&lt;/strong&gt;: Track function metadata and execution history&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication Layer&lt;/strong&gt;: Implement OAuth or API key security&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-Scaling&lt;/strong&gt;: Dynamic container provisioning based on workload&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extended Language Support&lt;/strong&gt;: Add JavaScript, Rust, and more!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why You Should Try a Project Like This
&lt;/h2&gt;

&lt;p&gt;Building a serverless platform from scratch taught me:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Systems Thinking&lt;/strong&gt;: How file I/O, containers, and APIs work together&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Hidden Cost of Serverless&lt;/strong&gt;: Appreciation for the complexity abstracted away&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production-Grade Resilience&lt;/strong&gt;: Why robust error handling makes or breaks systems&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This wasn't about building a better Lambda - it was about understanding the machinery behind the magic. If you're tired of surface-level tutorials, I challenge you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick a complex systems problem&lt;/li&gt;
&lt;li&gt;Dive deeper than any tutorial would&lt;/li&gt;
&lt;li&gt;Embrace the struggle (that's where real learning happens)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You'll gain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Skills most tutorials never cover&lt;/li&gt;
&lt;li&gt;Deep respect for the tools you use daily&lt;/li&gt;
&lt;li&gt;Confidence to tackle any technical challenge&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ready to tinker?&lt;/strong&gt; ➡️ &lt;a href="https://github.com/UnplugCharger/serverless" rel="noopener noreferrer"&gt;Explore the code on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What's the most ambitious project you've built to level up your skills? Share your war stories below! 💬&lt;/em&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>backenddevelopment</category>
    </item>
  </channel>
</rss>
