<?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: Stephanie Ekejiuba</title>
    <description>The latest articles on DEV Community by Stephanie Ekejiuba (@stephanie_ekejiuba).</description>
    <link>https://dev.to/stephanie_ekejiuba</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%2F3473162%2Fc77cbe65-2f63-4965-9acd-851639f0728e.jpeg</url>
      <title>DEV Community: Stephanie Ekejiuba</title>
      <link>https://dev.to/stephanie_ekejiuba</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stephanie_ekejiuba"/>
    <language>en</language>
    <item>
      <title>Deploying an AI Spam Detection App</title>
      <dc:creator>Stephanie Ekejiuba</dc:creator>
      <pubDate>Thu, 04 Sep 2025 11:41:18 +0000</pubDate>
      <link>https://dev.to/stephanie_ekejiuba/deploying-an-ai-spam-detection-app-59b</link>
      <guid>https://dev.to/stephanie_ekejiuba/deploying-an-ai-spam-detection-app-59b</guid>
      <description>&lt;p&gt;AI Powered Spam Detection Web App Deployed on AWS EC2 with Flask &amp;amp; Gunicorn&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Spam emails continue to plague inboxes worldwide, affecting productivity and exposing users to phishing and malware. To address this problem, I developed an AI-based Spam Detection Web Application using Python and Flask. The app utilizes natural language processing (NLP) and machine learning to classify messages as spam or not spam with high accuracy.&lt;/p&gt;

&lt;p&gt;In this project, I not only built the core spam classifier but also deployed the full stack application on an AWS EC2 instance, making it publicly accessible via the web. I also implemented a production-ready environment using Gunicorn, a WSGI HTTP server for Python applications.&lt;/p&gt;

&lt;p&gt;This article outlines the development process, deployment architecture, tools used, and the steps I followed to bring the app live.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Goals&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ Build an AI model capable of detecting spam emails&lt;/p&gt;

&lt;p&gt;✅ Create a web-based UI using Flask&lt;/p&gt;

&lt;p&gt;✅ Deploy the application on a cloud server (AWS EC2)&lt;/p&gt;

&lt;p&gt;✅ Make the server production ready using Gunicorn&lt;/p&gt;

&lt;p&gt;✅ Demonstrate understanding of cloud infrastructure, Python backend, and deployment best practices&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the Spam Detection Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the heart of the application is a machine learning model trained on labeled email data. The model uses techniques such as:&lt;/p&gt;

&lt;p&gt;Text preprocessing: Removing noise, stop words, tokenization&lt;/p&gt;

&lt;p&gt;TF-IDF Vectorization: Converting text into numerical form&lt;/p&gt;

&lt;p&gt;Multinomial Naive Bayes Classifier: A popular algorithm for text classification&lt;/p&gt;

&lt;p&gt;When users input a message into the web form, the model predicts whether the message is spam or ham (not spam) in real-time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tech Stack&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Layer    Technology&lt;/li&gt;
&lt;li&gt;Frontend HTML/CSS&lt;/li&gt;
&lt;li&gt;Backend  Python, Flask&lt;/li&gt;
&lt;li&gt;ML/NLP   Scikit-learn, Pandas, NLTK&lt;/li&gt;
&lt;li&gt;Deployment   AWS EC2 (Ubuntu 20.04), Gunicorn&lt;/li&gt;
&lt;li&gt;Package Manager pip&lt;/li&gt;
&lt;li&gt;Git Repository GitHub&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;App Features&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Simple, clean UI for user input&lt;/li&gt;
&lt;li&gt; Real-time spam classification&lt;/li&gt;
&lt;li&gt; RESTful architecture&lt;/li&gt;
&lt;li&gt; Lightweight and responsive&lt;/li&gt;
&lt;li&gt; Publicly accessible via EC2 public IP&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The app is hosted on an Ubuntu EC2 instance with Flask handling the app logic and Gunicorn ensuring the app can handle production traffic efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step by Step Deployment Process&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launching EC2 Instance&lt;/li&gt;
&lt;li&gt;Selected Ubuntu 20.04 AMI&lt;/li&gt;
&lt;li&gt;t2.micro instance (free tier)&lt;/li&gt;
&lt;li&gt;Set up key pair (.pem) and security group&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Allowed ports: 22 (SSH), 80 (HTTP), 5000 (Flask Dev)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Installing System Dependencies&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
sudo apt install python3-pip -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cloning the Flask App&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &amp;lt;your-github-repo-url&amp;gt;
cd spamemail
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fixing Windows-style line endings (if needed)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install dos2unix -y
dos2unix requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Installing Python Dependencies&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip3 install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Running the App in Development&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Access at: &lt;a href="http://your-ec2-ip:5000" rel="noopener noreferrer"&gt;http://your-ec2-ip:5000&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Running with Gunicorn for Production&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip3 install gunicorn
gunicorn --workers 3 --bind 0.0.0.0:5000 app:app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Replace app with your filename: flask app object if your file or Flask object has a different name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security Considerations&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For development, port 5000 was opened to the public.&lt;/li&gt;
&lt;li&gt;For production, the app can be routed through Nginx on port 80 with HTTPS using Let's Encrypt.&lt;/li&gt;
&lt;li&gt;SSH access was secured with a private key.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Testing &amp;amp; Validation&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tested on multiple test cases and known spam messages&lt;/li&gt;
&lt;li&gt;Verified model accuracy and false positive rates&lt;/li&gt;
&lt;li&gt;Load tested the Gunicorn server for concurrent requests&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Lessons Learned&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Handling OS level issues like CRLF line endings on Linux&lt;/li&gt;
&lt;li&gt;Setting up and securing cloud infrastructure on AWS&lt;/li&gt;
&lt;li&gt;Working with WSGI servers like Gunicorn for Python deployment&lt;/li&gt;
&lt;li&gt;Enhancing app performance and fault tolerance Repository&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;GitHub: your repo link&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Steps&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Integrate with email clients to automatically flag spam&lt;/li&gt;
&lt;li&gt;Add user authentication and database support&lt;/li&gt;
&lt;li&gt;Deploy behind an Nginx reverse proxy for better performance&lt;/li&gt;
&lt;li&gt;Add HTTPS support for secure connections&lt;/li&gt;
&lt;li&gt;Dockerize the application for portability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
This project helped me bridge the gap between machine learning development and real world deployment. From building a robust spam classifier to deploying it in the cloud, I’ve gained hands-on experience in both AI and DevOps fundamentals. It’s a great addition to my portfolio and a stepping stone toward more scalable AI solutions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Preview of the Application&lt;/strong&gt;&lt;br&gt;
The application interface is simple and intuitive. Users can paste email content into a text box and receive immediate feedback indicating whether the content is spam or not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5jt9ann5q65jnnsecyc.png" rel="noopener noreferrer"&gt;check out the screenshot of what the app looks like &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vml4qhcy2ibh00lsduh.png" rel="noopener noreferrer"&gt;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vml4qhcy2ibh00lsduh.png&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;(&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ihwwkaai2bfqafw18axp.png" rel="noopener noreferrer"&gt;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ihwwkaai2bfqafw18axp.png&lt;/a&gt;)&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
