<?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: HydraBytes</title>
    <description>The latest articles on DEV Community by HydraBytes (@thehydrabytes).</description>
    <link>https://dev.to/thehydrabytes</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%2F3873503%2F4d017dc0-77b3-4e5b-b8b7-6a3c71cbab08.jpg</url>
      <title>DEV Community: HydraBytes</title>
      <link>https://dev.to/thehydrabytes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thehydrabytes"/>
    <language>en</language>
    <item>
      <title>Machine Learning for Business: A Practical Guide</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Thu, 14 May 2026 11:48:54 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/machine-learning-for-business-a-practical-guide-26kj</link>
      <guid>https://dev.to/thehydrabytes/machine-learning-for-business-a-practical-guide-26kj</guid>
      <description>&lt;p&gt;Most businesses know they should be "doing something with AI." Few know where to start. After building ML systems for clients across healthcare, finance, and education, here is what we have learned about turning machine learning from a buzzword into a working business tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start With the Problem, Not the Technology
&lt;/h2&gt;

&lt;p&gt;The biggest mistake we see is companies starting with "we want to use AI" instead of "we have a problem that costs us X per month." Machine learning is a tool. Like any tool, it is only useful when applied to the right problem.&lt;/p&gt;

&lt;p&gt;Good ML problems share three characteristics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You have data.&lt;/strong&gt; Not "we could collect data someday." You have it now, in a structured or semi-structured format, with enough volume to train a model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The task is repeatable and pattern-based.&lt;/strong&gt; Classifying images, predicting churn, detecting anomalies, extracting information from documents. If a human does it by recognizing patterns, ML can probably do it faster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The cost of being wrong is manageable.&lt;/strong&gt; ML models make mistakes. If a wrong prediction means a minor inconvenience, great. If it means someone gets the wrong medical diagnosis, you need much more rigorous validation.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Build vs. Buy Decision
&lt;/h2&gt;

&lt;p&gt;Before writing a single line of code, ask: does a pre-built solution already do this?&lt;/p&gt;

&lt;h3&gt;
  
  
  Use off-the-shelf when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The problem is common (sentiment analysis, OCR, object detection)&lt;/li&gt;
&lt;li&gt;You do not need to own the model&lt;/li&gt;
&lt;li&gt;Speed to market matters more than customization&lt;/li&gt;
&lt;li&gt;Your team does not have ML expertise&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Services like AWS Rekognition, Google Cloud Vision, and OpenAI's APIs solve common problems well. There is no shame in using them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build custom when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Your data is domain-specific (medical images, industrial sensors, Urdu text)&lt;/li&gt;
&lt;li&gt;Off-the-shelf accuracy is not good enough for your use case&lt;/li&gt;
&lt;li&gt;You need the model to run on-device or on-premise&lt;/li&gt;
&lt;li&gt;The ML component is your competitive advantage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At HydraBytes, we built a custom retinal disease detector (OptiPro) because no off-the-shelf vision API was trained on fundus photography. We used a pre-trained sentiment model for a social media dashboard because the generic model was accurate enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data is the Hard Part
&lt;/h2&gt;

&lt;p&gt;Everyone talks about models. Nobody talks enough about data. In our experience, 80% of the effort in any ML project is data collection, cleaning, and labeling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data quality checklist
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Is it labeled correctly?&lt;/strong&gt; Mislabeled training data is the most common source of poor model performance. We always do a manual audit of at least 10% of labels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is it balanced?&lt;/strong&gt; If 95% of your data is one class, the model will just predict that class every time and get 95% accuracy. This is not useful. We use oversampling, undersampling, or class weights to handle imbalance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is it representative?&lt;/strong&gt; Training data needs to reflect real-world conditions. A model trained on high-quality studio photos will fail on blurry phone camera images.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is it enough?&lt;/strong&gt; There is no magic number. For image classification, we typically want at least 500 examples per class. For structured data, 10,000+ rows is a reasonable starting point.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data privacy
&lt;/h3&gt;

&lt;p&gt;If your data contains PII (names, emails, medical records), you need to handle it carefully. We always ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can we anonymize the data before training?&lt;/li&gt;
&lt;li&gt;Does the data need to stay on-premise?&lt;/li&gt;
&lt;li&gt;What regulations apply (GDPR, HIPAA, local data protection laws)?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These constraints affect architecture decisions. A model that needs to run on-premise has different infrastructure requirements than one running in the cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the Right Approach
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Structured data (spreadsheets, databases)
&lt;/h3&gt;

&lt;p&gt;Start with &lt;strong&gt;gradient boosting&lt;/strong&gt; (XGBoost or LightGBM). These models are fast to train, easy to interpret, and surprisingly hard to beat on tabular data. We used gradient boosting for student stress prediction and it outperformed our initial neural network attempt.&lt;/p&gt;

&lt;p&gt;Do not start with deep learning for structured data. It is almost never the right first choice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Images
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Convolutional Neural Networks (CNNs)&lt;/strong&gt; are the standard. But do not train from scratch. Use &lt;strong&gt;transfer learning&lt;/strong&gt;: take a model pre-trained on ImageNet (ResNet, EfficientNet) and fine-tune it on your data. This works even with small datasets (a few hundred images per class).&lt;/p&gt;

&lt;p&gt;For our lung cancer classifier, we fine-tuned an EfficientNet model and achieved 96% accuracy with under 5,000 training images.&lt;/p&gt;

&lt;h3&gt;
  
  
  Text
&lt;/h3&gt;

&lt;p&gt;For most text tasks in 2026, &lt;strong&gt;large language models&lt;/strong&gt; via API (Claude, GPT) are the practical choice. Fine-tuning a smaller model (BERT, DistilBERT) makes sense when you need lower latency, lower cost per inference, or offline capability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Time series
&lt;/h3&gt;

&lt;p&gt;Start with &lt;strong&gt;Prophet&lt;/strong&gt; or &lt;strong&gt;ARIMA&lt;/strong&gt; for forecasting. Move to LSTMs or Transformers only if the simpler models are not accurate enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment is Where Projects Die
&lt;/h2&gt;

&lt;p&gt;Building a model that works in a Jupyter notebook is the easy part. Getting it into production and keeping it there is where most ML projects fail.&lt;/p&gt;

&lt;h3&gt;
  
  
  Our deployment checklist
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Wrap the model in an API.&lt;/strong&gt; We use FastAPI (Python) for inference endpoints. Keep the ML service separate from your main application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Version your models.&lt;/strong&gt; Every model should have a version number, a training date, and a record of what data it was trained on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Monitor performance.&lt;/strong&gt; Model accuracy degrades over time as real-world data shifts. Set up alerts for when prediction distributions change significantly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Plan for retraining.&lt;/strong&gt; Decide upfront how often you will retrain and what triggers a retrain. Monthly on a schedule? When accuracy drops below a threshold? When new labeled data becomes available?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Have a fallback.&lt;/strong&gt; If the model goes down or starts producing garbage predictions, what happens? The system should degrade gracefully, not crash.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Measuring ROI
&lt;/h2&gt;

&lt;p&gt;ML projects need to justify their cost. Before starting, define:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What metric improves?&lt;/strong&gt; Revenue, cost reduction, time saved, error rate reduction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What is the baseline?&lt;/strong&gt; How does the current process perform without ML?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What improvement justifies the investment?&lt;/strong&gt; A 2% improvement in fraud detection might save millions. A 2% improvement in email subject line generation might save nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Track these metrics before, during, and after deployment. If the model is not delivering measurable value, iterate or shut it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;If you are considering ML for your business:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Identify one specific, measurable problem&lt;/strong&gt; that costs you time or money.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit your data.&lt;/strong&gt; Do you have enough? Is it clean? Is it accessible?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start with the simplest approach.&lt;/strong&gt; Off-the-shelf API or a basic model. Prove the concept before investing in complexity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set a success metric&lt;/strong&gt; before you start building.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Machine learning is powerful, but it is not magic. The businesses that succeed with ML are the ones that treat it as an engineering discipline, not a silver bullet.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;&lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;HydraBytes&lt;/a&gt; is an Islamabad-based development agency building web, mobile, and AI solutions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>python</category>
      <category>startup</category>
    </item>
    <item>
      <title>Mobile-First Design: Why It Matters More Than Ever</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Thu, 14 May 2026 11:47:27 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/mobile-first-design-why-it-matters-more-than-ever-4flc</link>
      <guid>https://dev.to/thehydrabytes/mobile-first-design-why-it-matters-more-than-ever-4flc</guid>
      <description>&lt;p&gt;Over 60% of global web traffic now comes from mobile devices. Yet most websites are still designed on a desktop monitor and then squeezed down to fit smaller screens. That approach is backwards, and it shows.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Mobile-First Actually Means
&lt;/h2&gt;

&lt;p&gt;Mobile-first design is not "make it responsive." It means you start the design process with the smallest screen and work your way up. Every layout decision, every interaction, every piece of content is first validated on a 375px viewport before it ever touches a desktop breakpoint.&lt;/p&gt;

&lt;p&gt;This forces a discipline that desktop-first design does not. When you have 375 pixels of width, you cannot hide behind a 12-column grid and spacious whitespace. Every element has to earn its place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Desktop-First Fails
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Content overload
&lt;/h3&gt;

&lt;p&gt;Desktop designs tend to pack too much onto a single screen. Navigation menus with 15 items, sidebars with widgets, hero sections with three CTAs. When these get compressed to mobile, the result is usually a hamburger menu hiding most of the site, content stacking into an endless scroll, and touch targets that are too small to hit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance blind spots
&lt;/h3&gt;

&lt;p&gt;Desktop-first development often ignores the constraints of mobile networks. That 4MB hero image looks great on fiber. On a 3G connection in a rural area, it takes 12 seconds to load. By then, the user is gone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interaction model mismatch
&lt;/h3&gt;

&lt;p&gt;Hover states do not exist on touch devices. Drag-and-drop is awkward on small screens. Right-click menus are invisible. When you design for desktop first, you build interactions that fundamentally do not translate to mobile.&lt;/p&gt;

&lt;h2&gt;
  
  
  How We Approach Mobile-First at HydraBytes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Content hierarchy comes first
&lt;/h3&gt;

&lt;p&gt;Before opening Figma, we list every piece of content the page needs to communicate. Then we rank it by importance. On mobile, the most important content goes at the top. Everything else either moves down or gets cut.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Touch targets are non-negotiable
&lt;/h3&gt;

&lt;p&gt;Every interactive element is at least 44x44 pixels. Buttons have adequate spacing between them. Form inputs are tall enough to tap without zooming. This is not a guideline for us, it is a hard rule.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Performance budgets
&lt;/h3&gt;

&lt;p&gt;We set a performance budget before development starts. For most projects: under 200KB of JavaScript, under 1MB total page weight, First Contentful Paint under 1.5 seconds on 4G. If a design element pushes us over budget, the design changes. Not the budget.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Progressive enhancement
&lt;/h3&gt;

&lt;p&gt;The mobile experience is the baseline. As the viewport grows, we add complexity: multi-column layouts, richer animations, larger media. Desktop users get a better experience, but mobile users never get a broken one.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Real device testing
&lt;/h3&gt;

&lt;p&gt;Simulators lie. We test on actual phones with actual network conditions. A mid-range Android phone on a congested WiFi network reveals problems that Chrome DevTools never will.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mobile-First Mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Making the mobile version a stripped-down desktop
&lt;/h3&gt;

&lt;p&gt;Mobile users are not second-class citizens. They are often your primary audience. If your mobile experience is a degraded version of desktop, you are telling the majority of your users that they matter less.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignoring landscape orientation
&lt;/h3&gt;

&lt;p&gt;People use phones in landscape mode more than you think. Video playback, gaming, and even casual browsing happen in landscape. If your layout breaks at 667x375, you have a problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Over-relying on bottom sheets and modals
&lt;/h3&gt;

&lt;p&gt;These patterns work well on native apps. On the mobile web, they often conflict with browser chrome, create scroll-locking issues, and confuse users who expect back-button navigation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Forgetting about thumb reach
&lt;/h3&gt;

&lt;p&gt;On modern phones (6+ inches), the top of the screen is unreachable with one hand. Critical navigation and actions should live in the bottom half of the screen, within natural thumb reach.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Business Case
&lt;/h2&gt;

&lt;p&gt;This is not just a design preference. Mobile-first has measurable business impact:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Google uses mobile-first indexing.&lt;/strong&gt; Your mobile experience directly affects your search ranking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conversion rates drop 7% for every additional second of load time&lt;/strong&gt; on mobile.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;53% of mobile users abandon sites that take longer than 3 seconds to load.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile commerce&lt;/strong&gt; accounted for 72% of all e-commerce sales in 2025.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your site does not work well on mobile, you are leaving money on the table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;If you are redesigning an existing site, start with your analytics. Look at your mobile vs. desktop traffic split, your mobile bounce rate, and your mobile conversion rate. If mobile traffic is high but conversions are low, your mobile experience is the bottleneck.&lt;/p&gt;

&lt;p&gt;If you are building something new, resist the urge to start with the desktop layout. Open your design tool, set the artboard to 375px wide, and start there. It will feel constraining at first. That constraint is the point.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;&lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;HydraBytes&lt;/a&gt; is an Islamabad-based development agency building web, mobile, and AI solutions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>design</category>
      <category>webdev</category>
      <category>mobile</category>
      <category>ux</category>
    </item>
    <item>
      <title>Why We Started HydraBytes: Building Tech Solutions From Islamabad</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Thu, 14 May 2026 11:02:27 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/why-we-started-hydrabytes-building-tech-solutions-from-islamabad-2hn9</link>
      <guid>https://dev.to/thehydrabytes/why-we-started-hydrabytes-building-tech-solutions-from-islamabad-2hn9</guid>
      <description>&lt;p&gt;Pakistan has no shortage of talented developers. What it lacks is agencies that treat client projects with the same rigor as their own products. Most local agencies run on a volume model: take as many projects as possible, assign junior devs, ship fast, move on. The client gets something that works on demo day but falls apart in production.&lt;/p&gt;

&lt;p&gt;We started &lt;strong&gt;HydraBytes&lt;/strong&gt; because we were tired of seeing that pattern. We wanted to build an agency where every project gets production-grade architecture, proper testing, and code that the next developer can actually read.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Do
&lt;/h2&gt;

&lt;p&gt;HydraBytes is a development agency based in Islamabad. We build three types of things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Web applications&lt;/strong&gt;: Full-stack platforms with authentication, dashboards, APIs, and scalable architecture. Our stack is typically Next.js, TypeScript, PostgreSQL, and Prisma.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mobile apps&lt;/strong&gt;: Cross-platform applications with React Native and Expo. We focus on apps that need real-time features, offline capability, or hardware integration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AI/ML solutions&lt;/strong&gt;: From computer vision classifiers to RAG-powered chatbots. We build AI that solves specific business problems, not demos that look impressive but never ship.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How We Work
&lt;/h2&gt;

&lt;p&gt;Every project starts with understanding the actual problem, not jumping to a tech stack. We have turned down projects where the client wanted a mobile app but the real solution was a better spreadsheet. We have recommended simpler architectures when a client's budget did not justify a microservices setup.&lt;/p&gt;

&lt;p&gt;Once we commit to a project, we work in short cycles with frequent demos. No disappearing for three months and hoping the client likes what we built.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Portfolio
&lt;/h2&gt;

&lt;p&gt;Some projects we have shipped:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OptiPro&lt;/strong&gt;: AI-powered retinal disease detection for clinical use. Classifies four disease types with explainable heatmaps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CPAi&lt;/strong&gt;: Bank statement analysis dashboard that auto-detects 12 Malaysian bank formats and generates credit reports client-side.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safe-Sawar&lt;/strong&gt;: Pakistan's first NADRA-verified carpooling app with offline emergency SOS via Bluetooth mesh networking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inventra&lt;/strong&gt;: Inventory management platform with real-time margin analytics and automated PDF billing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these solved a real problem for a real user. None of them were template sites with placeholder content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Islamabad
&lt;/h2&gt;

&lt;p&gt;The Pakistan tech ecosystem is growing fast, but it is still undervalued globally. Senior developers here cost a fraction of what they cost in the US or Europe, but the skill level is comparable. We have team members who have built production systems handling millions of requests, contributed to open-source projects, and shipped apps with tens of thousands of users.&lt;/p&gt;

&lt;p&gt;Islamabad specifically gives us access to universities producing strong CS graduates, a growing startup scene, and a cost of living that lets us keep our rates competitive without cutting corners on quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Believe
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ship production code, not prototypes.&lt;/strong&gt; Every line we write should be ready for real users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Underpromise, overdeliver.&lt;/strong&gt; We would rather say "we can do this in 6 weeks" and deliver in 4 than promise 2 weeks and miss the deadline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transparency over polish.&lt;/strong&gt; We will tell you when your idea needs rethinking. That honesty is worth more than a polished pitch deck.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Get In Touch
&lt;/h2&gt;

&lt;p&gt;If you have a project that needs building, or if you just want to talk tech, &lt;a href="https://www.hydrabytes.tech/contact" rel="noopener noreferrer"&gt;reach out&lt;/a&gt;. We respond to every message.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;&lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;HydraBytes&lt;/a&gt; is an Islamabad-based development agency. We build web, mobile, and AI solutions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
      <category>webdev</category>
      <category>startup</category>
    </item>
    <item>
      <title>Safe-Sawar: Building Pakistan's First NADRA-Verified Carpooling App with React Native</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Thu, 14 May 2026 10:38:30 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/safe-sawar-building-pakistans-first-nadra-verified-carpooling-app-with-react-native-4ia8</link>
      <guid>https://dev.to/thehydrabytes/safe-sawar-building-pakistans-first-nadra-verified-carpooling-app-with-react-native-4ia8</guid>
      <description>&lt;p&gt;Fuel prices in Pakistan have more than doubled in recent years. For millions of daily commuters, especially women, the options are limited: overcrowded public transport with safety concerns, expensive ride-hailing, or burning through a salary on petrol. Carpooling is the obvious solution, but existing platforms do not address the trust and safety barriers that prevent adoption.&lt;/p&gt;

&lt;p&gt;We built &lt;strong&gt;Safe-Sawar&lt;/strong&gt; (محفوظ سوار, "Safe Rider") to change that: Pakistan's first NADRA-verified carpooling platform with separate women and men sections, biometric identity verification, and an offline emergency SOS system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Existing Solutions Fall Short
&lt;/h2&gt;

&lt;p&gt;Ride-sharing apps like Careem and InDrive connect strangers with no identity verification beyond a phone number. For women commuters, this is a non-starter. You should not have to take a stranger's word for who they are when getting into their car.&lt;/p&gt;

&lt;p&gt;The trust problem goes deeper than just identity. Even with verification, how do you know the person is connected to your community? How do you send an SOS when you have no cell signal? These are the problems we set out to solve.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  NADRA CNIC + Biometric Verification
&lt;/h3&gt;

&lt;p&gt;Every Safe-Sawar user is verified through Pakistan's NADRA (National Database and Registration Authority) system. The onboarding flow requires:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CNIC (national ID) number entry&lt;/li&gt;
&lt;li&gt;Biometric fingerprint or facial verification against NADRA records&lt;/li&gt;
&lt;li&gt;Profile creation only after successful verification&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This means every person on the platform is who they claim to be. No fake accounts, no anonymous riders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Women-First, With a Male Section
&lt;/h3&gt;

&lt;p&gt;The app launches with a gender selection screen: Female or Male. The women's section was the original focus, offering women-only rides that are verified, private, and trusted. We later added a male section to expand the userbase, but the safety-first architecture applies to both.&lt;/p&gt;

&lt;p&gt;Each section maintains its own ride pool. Women riders only see women drivers and vice versa in the women's section.&lt;/p&gt;

&lt;h3&gt;
  
  
  Institution-Based Trust Circles
&lt;/h3&gt;

&lt;p&gt;Beyond identity verification, Safe-Sawar introduces trust circles: groups tied to institutions like universities, offices, or neighborhoods. If you are riding with someone from your own university or workplace, there is an additional layer of social accountability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Live Ride Tracking
&lt;/h3&gt;

&lt;p&gt;Every active ride is tracked in real time using OpenStreetMap. Riders and their emergency contacts can see the vehicle's location throughout the journey.&lt;/p&gt;

&lt;h3&gt;
  
  
  Offline Emergency SOS via Bluetooth Mesh
&lt;/h3&gt;

&lt;p&gt;This is the feature we are most proud of. In areas with poor cellular coverage (which is common on intercity routes in Pakistan), a traditional SOS button that relies on internet connectivity is useless.&lt;/p&gt;

&lt;p&gt;Safe-Sawar's SOS system uses Bluetooth mesh networking. When a user triggers an emergency, their phone broadcasts the alert via Bluetooth to nearby devices, which relay it further. The alert propagates through the mesh until it reaches a device with internet connectivity, which then sends the SOS to emergency contacts and authorities.&lt;/p&gt;

&lt;p&gt;This works even in complete dead zones. As long as there are other phones within Bluetooth range (even phones not running Safe-Sawar, if they support the protocol), the alert gets through.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend&lt;/strong&gt;: React Native with Expo and TypeScript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend&lt;/strong&gt;: Firebase (Auth, Firestore, Cloud Functions)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maps&lt;/strong&gt;: OpenStreetMap integration&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Identity&lt;/strong&gt;: NADRA API for biometric verification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mesh Network&lt;/strong&gt;: Bluetooth Low Energy for offline SOS&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;strong&gt;React Native + Expo&lt;/strong&gt; over native Swift/Kotlin because we needed to ship on both platforms simultaneously with a small team. Expo's managed workflow handled push notifications, location services, and Bluetooth without ejecting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firebase&lt;/strong&gt; over a custom backend because real-time ride updates, presence detection, and push notifications are Firebase's core strengths. Firestore's offline persistence also means the app remains functional in poor connectivity areas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OpenStreetMap&lt;/strong&gt; over Google Maps because OSM data is better maintained in Pakistan for rural and intercity routes, and there are no per-request API costs that would make the app economically unviable at scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current Status
&lt;/h2&gt;

&lt;p&gt;Safe-Sawar is currently in beta testing with university communities in Islamabad. We are refining the onboarding flow, expanding trust circle features, and preparing for a wider launch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;The project is open source: &lt;a href="https://github.com/faizan-02/Safe-Sawar" rel="noopener noreferrer"&gt;github.com/faizan-02/Safe-Sawar&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are interested in contributing or partnering on deployment, &lt;a href="https://www.hydrabytes.tech/contact" rel="noopener noreferrer"&gt;reach out to us&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built by &lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;HydraBytes&lt;/a&gt;, an Islamabad-based development agency specializing in web, mobile, and AI solutions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>mobile</category>
      <category>firebase</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Building CPAi: An AI-Powered Bank Statement Analysis Dashboard</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Thu, 14 May 2026 10:36:41 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/building-cpai-an-ai-powered-bank-statement-analysis-dashboard-1ka4</link>
      <guid>https://dev.to/thehydrabytes/building-cpai-an-ai-powered-bank-statement-analysis-dashboard-1ka4</guid>
      <description>&lt;p&gt;Manually reviewing bank statements to assess creditworthiness is one of those tasks that sounds simple until you realize there are dozens of bank formats, each with different layouts, column names, and transaction structures. A credit analyst might spend hours on a single applicant's documents. Multiply that across a loan pipeline and you have a serious bottleneck.&lt;/p&gt;

&lt;p&gt;We built &lt;strong&gt;CPAi (Credit Profile Analysis AI)&lt;/strong&gt; to solve this: a dashboard that auto-detects Malaysian bank formats from uploaded PDFs, extracts transactions, and generates credit analysis reports. All client-side.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Financial institutions in Malaysia deal with statements from over a dozen banks. Each bank has its own PDF structure. Extracting transaction data means either manual data entry or brittle format-specific parsers that break whenever a bank updates their template.&lt;/p&gt;

&lt;p&gt;The consequences are real: slow turnaround on loan applications, human error in data extraction, and inconsistent credit assessments across analysts.&lt;/p&gt;

&lt;h2&gt;
  
  
  How CPAi Works
&lt;/h2&gt;

&lt;p&gt;The pipeline is straightforward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Upload&lt;/strong&gt;: Drop one or more PDF bank statements into the dashboard&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-detect&lt;/strong&gt;: The system identifies which of the 12 supported Malaysian bank formats the statement belongs to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parse&lt;/strong&gt;: Transactions are extracted with dates, descriptions, credits, debits, and running balances&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Analyze&lt;/strong&gt;: The dashboard aggregates data across statements for balance trends, transaction categorization, and anomaly detection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Report&lt;/strong&gt;: Export a full credit profile as PDF&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The critical design decision was doing everything client-side. Bank statements contain extremely sensitive financial data. By processing PDFs in the browser rather than uploading them to a server, we eliminated the data privacy concern entirely. No statement data ever leaves the user's machine.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Parsed Statements View
&lt;/h3&gt;

&lt;p&gt;Once statements are uploaded, the dashboard shows a unified table of all parsed data across banks: account names, periods, transaction counts, total credits and debits, and file references. Analysts can search across all transactions from a single search bar.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bank Analysis &amp;amp; Balance Checks
&lt;/h3&gt;

&lt;p&gt;The dashboard computes monthly balance trends with interactive charts, showing closing balances over time across all accounts. This gives an immediate visual read on an applicant's financial trajectory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transaction Rules Engine
&lt;/h3&gt;

&lt;p&gt;This is where CPAi gets powerful. The rules engine auto-identifies and flags transactions by category: loan/financing payments, rental payments, salary/payroll deposits, and custom patterns. Each rule uses keyword matching that analysts can edit, with flagged transaction counts and totals computed in real time.&lt;/p&gt;

&lt;p&gt;For example, the "Loan / Financing" rule scans for keywords like &lt;code&gt;LOAN&lt;/code&gt;, &lt;code&gt;DISBURSE&lt;/code&gt;, &lt;code&gt;MORTGAGE&lt;/code&gt;, &lt;code&gt;INSTALMENT&lt;/code&gt;, and &lt;code&gt;PERSONAL LOAN&lt;/code&gt; across all statement descriptions. Analysts can add or remove keywords to tune detection for their specific use case.&lt;/p&gt;

&lt;h3&gt;
  
  
  TPV (Transaction Processing Volume) Input
&lt;/h3&gt;

&lt;p&gt;A dedicated module tracks monthly transaction processing volumes by source, with editable cells and automatic percentage-change calculations. This feeds into the broader credit assessment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Loan Eligibility &amp;amp; Export
&lt;/h3&gt;

&lt;p&gt;The platform calculates loan eligibility based on extracted financial data and exports everything as a formatted PDF report, ready for committee review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend&lt;/strong&gt;: Next.js with TypeScript and Tailwind CSS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PDF Parsing&lt;/strong&gt;: Client-side JavaScript PDF extraction&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Charts&lt;/strong&gt;: Interactive visualization for balance trends and analytics&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export&lt;/strong&gt;: PDF report generation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What We Learned
&lt;/h2&gt;

&lt;p&gt;The hardest part was not the AI or the parsing. It was handling the sheer variety of PDF formats. Some banks use tables, some use fixed-width text, some embed data in images. We had to build format-specific extractors and a detection layer that identifies the bank from structural cues in the PDF before selecting the right parser.&lt;/p&gt;

&lt;p&gt;The transaction rules engine was an intentional design choice over fully automated categorization. In financial compliance, analysts need to understand and control how transactions are classified. A black-box AI categorizer would not pass audit requirements. The keyword-based rules are transparent, editable, and auditable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;The project is available on GitHub: &lt;a href="https://github.com/faizan-02/Bank-Statement-Dashboard" rel="noopener noreferrer"&gt;github.com/faizan-02/Bank-Statement-Dashboard&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are building fintech tools or need a similar dashboard for your institution, &lt;a href="https://www.hydrabytes.tech/contact" rel="noopener noreferrer"&gt;get in touch with our team&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built by &lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;HydraBytes&lt;/a&gt;, an Islamabad-based development agency specializing in web, mobile, and AI solutions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>analytics</category>
      <category>fintech</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>How We Choose a Tech Stack for Client Projects in 2026</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Thu, 14 May 2026 10:33:20 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/how-we-choose-a-tech-stack-for-client-projects-in-2026-1obh</link>
      <guid>https://dev.to/thehydrabytes/how-we-choose-a-tech-stack-for-client-projects-in-2026-1obh</guid>
      <description>&lt;p&gt;"What tech stack should I use?" is the most common question we get from clients. The honest answer is always "it depends," but here is how we actually make that decision at HydraBytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Default Stack
&lt;/h2&gt;

&lt;p&gt;For most web projects, we reach for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Next.js&lt;/strong&gt; with TypeScript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL&lt;/strong&gt; with Prisma ORM&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tailwind CSS&lt;/strong&gt; for styling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vercel&lt;/strong&gt; for deployment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not because these are the trendiest tools. It is because this combination gives us server-side rendering, type safety, a relational database with great tooling, and zero-config deployment. For 80% of client projects, this stack lets us focus on solving the business problem instead of fighting infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  When We Deviate
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Need real-time features?
&lt;/h3&gt;

&lt;p&gt;If the app requires live updates (chat, dashboards, collaborative editing), we add &lt;strong&gt;Supabase&lt;/strong&gt; or &lt;strong&gt;Firebase&lt;/strong&gt; depending on the complexity. Supabase when we want to stay in PostgreSQL-land. Firebase when we need its offline persistence and push notification ecosystem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building a mobile app?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;React Native with Expo&lt;/strong&gt; is our default. The managed workflow handles 90% of what mobile apps need. We only eject or go native when hardware integration demands it (Bluetooth mesh networking in Safe-Sawar was one of those cases).&lt;/p&gt;

&lt;h3&gt;
  
  
  AI/ML component?
&lt;/h3&gt;

&lt;p&gt;Python with &lt;strong&gt;FastAPI&lt;/strong&gt; for the inference API. The model training stack varies: TensorFlow for computer vision, scikit-learn for structured data, LangChain for RAG applications. The important thing is keeping the AI service as a separate microservice that the main app calls via API. Never embed ML inference in your web server process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Client has an existing codebase?
&lt;/h3&gt;

&lt;p&gt;We work with what they have. We have maintained apps in Vue, Angular, Django, Rails, and plain PHP. Rewriting a working system to match our preferred stack is almost never the right call.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Questions We Actually Ask
&lt;/h2&gt;

&lt;p&gt;Before choosing a stack, we ask:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Who will maintain this after we hand it off?&lt;/strong&gt; If the client has an in-house team that knows Python, building it in Next.js creates a handoff problem.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What is the expected scale?&lt;/strong&gt; A tool for 50 internal users does not need the same architecture as a consumer app targeting 100K users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What is the budget?&lt;/strong&gt; Some stacks are cheaper to operate. Serverless on Vercel costs almost nothing at low traffic. A Kubernetes cluster costs money even when idle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What is the timeline?&lt;/strong&gt; If we need to ship in 4 weeks, we pick tools we know deeply, not tools we want to learn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Does this need to work offline?&lt;/strong&gt; This single requirement changes everything. Firebase, React Native's offline persistence, service workers: these are not add-ons, they are architectural decisions that need to be made from day one.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common Mistakes We See
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Choosing a stack because of a blog post
&lt;/h3&gt;

&lt;p&gt;"I read that X is the future" is not a technical requirement. We have seen projects start with bleeding-edge tools and spend half their budget on workarounds for missing features and immature ecosystems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Over-engineering for scale you do not have
&lt;/h3&gt;

&lt;p&gt;Building a microservices architecture for an MVP that will have 200 users is burning money. Start monolithic, measure bottlenecks, split when you need to.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignoring deployment costs
&lt;/h3&gt;

&lt;p&gt;A stack that is free in development can be expensive in production. GPU-powered AI inference, real-time WebSocket connections, large media storage: these costs add up. We estimate production costs before writing the first line of code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not considering the hiring market
&lt;/h3&gt;

&lt;p&gt;If you build your app in an obscure language, hiring developers to maintain it becomes expensive and slow. Boring, popular tools have larger talent pools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Recommendation
&lt;/h2&gt;

&lt;p&gt;If you are starting a new project in 2026 and you do not have strong reasons to deviate: &lt;strong&gt;Next.js, TypeScript, PostgreSQL, Tailwind, Vercel&lt;/strong&gt;. It is boring, it works, and you will not regret it in two years.&lt;/p&gt;

&lt;p&gt;If you need help making this decision for your specific project, &lt;a href="https://www.hydrabytes.tech/contact" rel="noopener noreferrer"&gt;talk to us&lt;/a&gt;. We will give you an honest recommendation, even if that means suggesting a simpler solution than you expected.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;&lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;HydraBytes&lt;/a&gt; is an Islamabad-based development agency building web, mobile, and AI solutions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>vibecoding</category>
      <category>architecture</category>
      <category>react</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Building a 3-Class Lung Cancer Image Classifier with TensorFlow and Flask</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Tue, 14 Apr 2026 17:26:35 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/building-a-3-class-lung-cancer-image-classifier-with-tensorflow-and-flask-4615</link>
      <guid>https://dev.to/thehydrabytes/building-a-3-class-lung-cancer-image-classifier-with-tensorflow-and-flask-4615</guid>
      <description>&lt;p&gt;Medical imaging is one of the most rewarding spaces to apply deep learning. Pathologists spend years learning to distinguish subtle visual patterns in tissue samples, and even then, fatigue and caseload pressure can creep into decisions. A well-trained CNN does not replace that expertise, but it can serve as a useful second opinion, especially in triage workflows.&lt;/p&gt;

&lt;p&gt;In this post we will walk through how we built a lung cancer image classifier that sorts tissue images into three classes: &lt;strong&gt;Adenocarcinoma&lt;/strong&gt;, &lt;strong&gt;Benign&lt;/strong&gt;, and &lt;strong&gt;Squamous Cell Carcinoma&lt;/strong&gt;. The model runs behind a Flask API with a simple upload-and-predict web interface, so anyone can drop in an image and see the prediction in real time.&lt;/p&gt;

&lt;p&gt;Full code and dataset links are on &lt;a href="https://github.com/faizan-02/Lung-Cancer-Classification" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why these three classes
&lt;/h2&gt;

&lt;p&gt;Lung cancer is commonly divided into small cell and non-small cell types. Within non-small cell lung cancer, adenocarcinoma and squamous cell carcinoma are the two most prevalent subtypes, together making up the majority of cases. Correctly separating them matters because treatment pathways can differ meaningfully.&lt;/p&gt;

&lt;p&gt;Adding a &lt;strong&gt;benign&lt;/strong&gt; class gives the model a "nothing to worry about" option so it does not force every input into a cancer label. That three-class setup reflects the kind of decision a real classifier would need to make in a triage tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  The dataset
&lt;/h2&gt;

&lt;p&gt;We used a public Kaggle lung cancer histopathology dataset, organized into three balanced classes with separate training and testing folders. The directory structure looked 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;dataset/
├── train/
│   ├── adenocarcinoma/
│   ├── benign/
│   └── squamous_cell_carcinoma/
└── test/
    ├── adenocarcinoma/
    ├── benign/
    └── squamous_cell_carcinoma/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keras' &lt;code&gt;ImageDataGenerator&lt;/code&gt; made it trivial to load images directly from these folders and apply augmentation on the fly. Data augmentation matters a lot for medical imaging because real datasets are almost always smaller than what a fresh CNN would prefer. We used random flips, small rotations, and zoom to expand the effective training set without collecting new samples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model architecture
&lt;/h2&gt;

&lt;p&gt;We went with a custom CNN instead of a pretrained backbone like ResNet or VGG. The reasoning: histopathology images have different statistics from natural photographs (no sky, no faces, strong staining colors), so the features learned on ImageNet are not always the best starting point. A purpose-built network with fewer parameters also trains faster and is easier to reason about.&lt;/p&gt;

&lt;p&gt;The architecture is intentionally simple:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Details&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Conv2D + ReLU&lt;/td&gt;
&lt;td&gt;32 filters, 3x3 kernel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MaxPooling2D&lt;/td&gt;
&lt;td&gt;2x2 pool&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conv2D + ReLU&lt;/td&gt;
&lt;td&gt;64 filters, 3x3 kernel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MaxPooling2D&lt;/td&gt;
&lt;td&gt;2x2 pool&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flatten&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dense + ReLU&lt;/td&gt;
&lt;td&gt;128 units&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dropout&lt;/td&gt;
&lt;td&gt;0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dense + Softmax&lt;/td&gt;
&lt;td&gt;3 output units&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two convolutional blocks are enough to capture the low and mid-level texture patterns that distinguish tumor tissue from benign tissue. The dropout layer before the final dense block is doing heavy lifting: without it, the model happily memorized the training set and validation accuracy plateaued much earlier.&lt;/p&gt;

&lt;p&gt;Here is the model definition in Keras:&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;from&lt;/span&gt; &lt;span class="n"&gt;tensorflow.keras.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Sequential&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tensorflow.keras.layers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Conv2D&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MaxPooling2D&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Flatten&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Dense&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Dropout&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Sequential&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="nc"&gt;Conv2D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;relu&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input_shape&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="nc"&gt;MaxPooling2D&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="nc"&gt;Conv2D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;relu&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nc"&gt;MaxPooling2D&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="nc"&gt;Flatten&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nc"&gt;Dense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;relu&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nc"&gt;Dropout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nc"&gt;Dense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;softmax&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;adam&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;categorical_crossentropy&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;accuracy&lt;/span&gt;&lt;span class="sh"&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;h2&gt;
  
  
  Training
&lt;/h2&gt;

&lt;p&gt;Training ran for a modest number of epochs with early stopping watching validation loss. Adam as the optimizer, categorical cross-entropy as the loss, and a 70/15/15 train/validation/test split. Nothing exotic. The trained weights are saved to &lt;code&gt;models/lung_cancer_model.h5&lt;/code&gt; so the Flask app can load them at startup instead of retraining every time.&lt;/p&gt;

&lt;p&gt;A lesson we learned early: &lt;strong&gt;always shuffle within each class before splitting&lt;/strong&gt;. Our first split was sequential and it put nearly all adenocarcinoma images from one subfolder into the training set and the rest into validation, which tanked validation accuracy for that class. Shuffling fixed it in one line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flask integration
&lt;/h2&gt;

&lt;p&gt;The serving side is a tiny Flask app with a single route that handles both the GET (render upload page) and POST (accept image, run prediction) flows:&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;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;render_template&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tensorflow.keras.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_model&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;PIL&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&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="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;models/lung_cancer_model.h5&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;CLASSES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Adenocarcinoma&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Benign&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Squamous Cell Carcinoma&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;GET&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;POST&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;upload_and_predict&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;POST&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;file&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="n"&gt;files&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;image&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;resize&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;RGB&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;arr&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;expand_dims&lt;/span&gt;&lt;span class="p"&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;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;255.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&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;preds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&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;predicted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CLASSES&lt;/span&gt;&lt;span class="p"&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;argmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;preds&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
        &lt;span class="n"&gt;confidence&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&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;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;preds&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;render_template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;index.html&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;prediction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;predicted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;confidence&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;image_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&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="nf"&gt;render_template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;index.html&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Loading the model once at startup (instead of per request) is a small detail that matters a lot for response times. The first prediction warms up TensorFlow, and everything after that returns in well under a second on CPU.&lt;/p&gt;

&lt;h2&gt;
  
  
  The front-end
&lt;/h2&gt;

&lt;p&gt;The user-facing interface is plain HTML, CSS, and a sprinkle of Bootstrap. No React, no framework overhead. A big drop zone for the image, a preview, and a result card that renders the predicted class with its confidence score. The goal was to keep the whole experience friction-free so someone without technical background can still use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;After training, our numbers landed at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Training accuracy:&lt;/strong&gt; around 95%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation accuracy:&lt;/strong&gt; around 96%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test accuracy:&lt;/strong&gt; around 97%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The validation accuracy sitting slightly above training is a little unusual and usually a sign that dropout is doing its job, regularizing the model enough that it generalizes cleanly. We also checked per-class precision and recall to make sure the model was not gaming its accuracy by over-predicting the majority class. All three classes came back balanced.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and honest caveats
&lt;/h2&gt;

&lt;p&gt;A few things we want to be upfront about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;This is not a clinical tool.&lt;/strong&gt; Public histopathology datasets are carefully curated and do not capture the full range of tissue variation you would see in a real lab. High test accuracy on a clean dataset does not translate to clinical-grade reliability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stain variation is the biggest gap.&lt;/strong&gt; The model has not been tested against images with different staining protocols, scanners, or magnifications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three classes is a simplification.&lt;/strong&gt; Real pathology has many more subtypes and gradings. A production version would need a much deeper label space.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These caveats are part of the reason we picked a custom CNN instead of pretending a ResNet fine-tune on Kaggle data is "ready for deployment". The architecture, training pipeline, and Flask wrapper are all meant to be a solid starting point that a team could extend into a real diagnostic aid with the right dataset partnerships and regulatory path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Building this project was a great exercise in the full loop: curating data, designing a CNN small enough to train on a single GPU, wiring it up behind a web interface, and making predictions available in a form anyone could use. The accuracy numbers are strong for a public dataset, but the bigger win was shipping something end to end, from raw images to a working upload-and-predict app.&lt;/p&gt;

&lt;p&gt;If you want to try it yourself, clone the repo, drop in the dataset, train the model, and start the Flask server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python train_model.py
python app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code, architecture diagrams, and screenshots are all on &lt;a href="https://github.com/faizan-02/Lung-Cancer-Classification" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. Feedback and pull requests are welcome.&lt;/p&gt;

&lt;p&gt;At &lt;strong&gt;HydraBytes&lt;/strong&gt;, we love projects like this one: real-world AI problems where the challenge is not just model accuracy but shaping the pipeline so the end result is useful. If you are exploring medical imaging, computer vision, or any ML use case, &lt;a href="https://www.hydrabytes.tech/contact" rel="noopener noreferrer"&gt;let's talk at Hydrabytes.tech&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>python</category>
      <category>tensorflow</category>
      <category>flask</category>
      <category>ai</category>
    </item>
    <item>
      <title>Building an AI-Based Student Stress Management System with Python, ML, and RAG</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Mon, 13 Apr 2026 23:04:32 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/building-an-ai-based-student-stress-management-system-with-python-ml-and-rag-4nj5</link>
      <guid>https://dev.to/thehydrabytes/building-an-ai-based-student-stress-management-system-with-python-ml-and-rag-4nj5</guid>
      <description>&lt;p&gt;Student mental health has become a genuine crisis in universities worldwide. Stress, anxiety, and depression are among the leading causes of academic dropout yet most campuses lack accessible, real-time tools to help students recognize and address what they're experiencing.&lt;/p&gt;

&lt;p&gt;We built the &lt;strong&gt;AI-Based Student Stress Management System&lt;/strong&gt; to tackle exactly that. It's a full-stack web platform that uses machine learning to detect stress, anxiety, and depression from questionnaire inputs, then provides instant severity scoring, personalized coping recommendations, and a conversational AI chatbot all in one place.&lt;/p&gt;

&lt;p&gt;This post walks through the architecture, the ML pipeline, and the design decisions we made building it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Repo: &lt;a href="https://github.com/TheHydraBytes/AI-based-student-stress-mangement" rel="noopener noreferrer"&gt;TheHydraBytes/AI-based-student-stress-mangement&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;The standard approach to student mental health support is: fill out a form, wait for a counselor to follow up, get an appointment weeks later. By that point, a student in mild-to-moderate distress may have already spiraled.&lt;/p&gt;

&lt;p&gt;We wanted something that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Gave students an immediate, private assessment of where they stood&lt;/li&gt;
&lt;li&gt;Offered actionable coping tools they could use right now&lt;/li&gt;
&lt;li&gt;Connected them to a professional when needed&lt;/li&gt;
&lt;/ol&gt;




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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;React Frontend
     |
  Flask Backend (Python)
     |          |           |
   SQL Server   ML Models   AI Chatbot
  (pyodbc)    (scikit-learn) (LangChain + Groq + Qdrant)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backend is a Flask application. The ML models (three separate classifiers) run as in-process Python objects. The chatbot uses a RAG (Retrieval-Augmented Generation) pipeline backed by Qdrant as the vector store and Groq (LLaMA 3.1) as the LLM.&lt;/p&gt;




&lt;h2&gt;
  
  
  The ML Pipeline
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Three Separate Models
&lt;/h3&gt;

&lt;p&gt;We trained three independent classifiers, one each for stress, anxiety, and depression. Each model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Takes a questionnaire response as input (Likert-scale answers covering behavioral, cognitive, and physiological symptoms)&lt;/li&gt;
&lt;li&gt;Outputs a severity label: &lt;strong&gt;Minimal / Mild / Moderate / Severe&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Was trained on a labeled clinical survey dataset (PSS, GAD-7, PHQ-9 style)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three follow the same training pattern:&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;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.linear_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LogisticRegression&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LabelEncoder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.model_selection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;train_test_split&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;joblib&lt;/span&gt;

&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;stress.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;label_encoder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LabelEncoder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Stress Label&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;label_encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Stress Label&lt;/span&gt;&lt;span class="sh"&gt;"&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;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Stress Value&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Stress Label&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;axis&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;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Stress Label&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;scaler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;X_scaled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&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;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;train_test_split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_scaled&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_iter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;joblib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;logistic_regression_stress.pkl&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;joblib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler.pkl&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;joblib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label_encoder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;label_encoder.pkl&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We chose Logistic Regression deliberately. For clinical classification tasks where interpretability and reliability matter more than marginal accuracy gains, it outperforms black-box alternatives like neural networks. We can understand exactly why a sample was classified the way it was.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-Time Prediction
&lt;/h3&gt;

&lt;p&gt;When a student submits the questionnaire, all three models run simultaneously and the results are bundled into a single response object:&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="n"&gt;results_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;stress_score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;stress_score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;stress_prediction&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;stress_label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;anxiety_score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;anxiety_score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;anxiety_prediction&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;anxiety_label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;depression_score&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;depression_score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;depression_prediction&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;depression_label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;demographic_info&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;demographic_info&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;p&gt;The results page shows all three severity scores at once, letting students see the full picture rather than a single-dimension reading.&lt;/p&gt;




&lt;h2&gt;
  
  
  The RAG Chatbot
&lt;/h2&gt;

&lt;p&gt;The conversational layer is where the system goes beyond a static form. Students can ask the chatbot anything related to their mental health — and it responds using actual clinical knowledge, not just generic LLM hallucinations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Embeddings&lt;/strong&gt;: &lt;code&gt;sentence-transformers/all-mpnet-base-v2&lt;/code&gt; via HuggingFace&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector store&lt;/strong&gt;: Qdrant (cloud-hosted)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM&lt;/strong&gt;: LLaMA 3.1 8B Instant via Groq API (fast, low-latency)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Orchestration&lt;/strong&gt;: LangChain&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The chatbot was trained on a curated mental health knowledge base (embedded as a PDF via &lt;code&gt;embed_documents.py&lt;/code&gt;). When a user sends a message, the system retrieves the top relevant chunks from Qdrant, then passes them as context to the LLM.&lt;/p&gt;

&lt;h3&gt;
  
  
  Crisis Detection
&lt;/h3&gt;

&lt;p&gt;One design decision we're particularly careful about: if a student types something that suggests a suicidal crisis, the chatbot does not attempt to respond as a therapist. It immediately surfaces emergency contact information.&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="n"&gt;crisis_triggers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i want to die&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i want to end it all&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i don&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t want to live&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;m done with everything&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ending my life&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i think about suicide&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;i have no reason to live&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system detects these triggers before the RAG pipeline even runs. Automated AI responses should never substitute for human intervention in a genuine crisis.&lt;/p&gt;




&lt;h2&gt;
  
  
  Features Beyond Assessment
&lt;/h2&gt;

&lt;p&gt;A questionnaire and a chatbot are the core, but the system includes several additional tools students can use day-to-day.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mindfulness Games
&lt;/h3&gt;

&lt;p&gt;Two browser-based games built to reduce acute stress:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bubble Pop Game&lt;/strong&gt;: Timed focus exercise. Simple, but effective for grounding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Puzzle Game&lt;/strong&gt;: Cognitive engagement that shifts attention away from anxiety spirals.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Game session data is stored and shown in the user's progress dashboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  Guided Breathing Exercises
&lt;/h3&gt;

&lt;p&gt;An animated breathing guide with session tracking. The &lt;code&gt;/breathing&lt;/code&gt; route stores per-session stats so students can track consistency over time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Progress Dashboard
&lt;/h3&gt;

&lt;p&gt;Every student gets a personal dashboard showing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Historical assessment results (trend over time)&lt;/li&gt;
&lt;li&gt;Breathing and game session stats&lt;/li&gt;
&lt;li&gt;Upcoming counselor appointments&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Doctor Appointment Booking
&lt;/h3&gt;

&lt;p&gt;Students can browse available counselors, check open slots via the &lt;code&gt;/api/available_slots&lt;/code&gt; endpoint, and book appointments directly through the platform. Admins can accept, reschedule, or cancel bookings through a separate admin dashboard.&lt;/p&gt;




&lt;h2&gt;
  
  
  Admin Panel
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;/admin_dashboard&lt;/code&gt; gives university mental health staff a full view of the system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User management&lt;/strong&gt;: view/delete student accounts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assessment history&lt;/strong&gt;: aggregate submissions across all students&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chatbot ratings&lt;/strong&gt;: feedback on response quality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Appointment management&lt;/strong&gt;: approve, reschedule, cancel appointments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This matters because the platform is designed to integrate with, not replace, existing campus counseling infrastructure.&lt;/p&gt;




&lt;h2&gt;
  
  
  Security Decisions
&lt;/h2&gt;

&lt;p&gt;A mental health platform handles particularly sensitive data. A few things we made sure to get right:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security headers on every response:&lt;/strong&gt;&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="nd"&gt;@app.after_request&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;after_request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X-Frame-Options&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;DENY&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X-Content-Type-Options&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;nosniff&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X-XSS-Protection&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1; mode=block&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Referrer-Policy&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;strict-origin-when-cross-origin&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Cache prevention on protected routes:&lt;/strong&gt; The &lt;code&gt;@require_login&lt;/code&gt; decorator adds &lt;code&gt;no-cache, no-store, must-revalidate&lt;/code&gt; headers so assessment results cannot be retrieved from browser cache by a shared device user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Password reset via security questions&lt;/strong&gt; instead of email-only, reducing dependency on email deliverability for account recovery.&lt;/p&gt;




&lt;h2&gt;
  
  
  What We'd Do Differently
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Switch to PostgreSQL properly.&lt;/strong&gt; The app currently uses SQL Server via &lt;code&gt;pyodbc&lt;/code&gt; with a local SSMS connection string hardcoded for development. Moving to PostgreSQL on a hosted provider (Supabase, Neon) would make deployment portable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add model versioning.&lt;/strong&gt; The &lt;code&gt;.pkl&lt;/code&gt; files are committed directly to the repo. As the training data grows, we'd want MLflow or a similar registry to track model versions alongside accuracy metrics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upgrade the chatbot to streaming.&lt;/strong&gt; The current Groq integration waits for the full response before sending it. Streaming tokens to the frontend would make the chatbot feel significantly more responsive.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;The full source is on GitHub under the HydraBytes organization:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/TheHydraBytes/AI-based-student-stress-mangement" rel="noopener noreferrer"&gt;github.com/TheHydraBytes/AI-based-student-stress-mangement&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/TheHydraBytes/AI-based-student-stress-mangement.git
&lt;span class="nb"&gt;cd &lt;/span&gt;AI-based-student-stress-mangement
pip &lt;span class="nb"&gt;install &lt;/span&gt;flask scikit-learn pandas numpy langchain-huggingface langchain-groq langchain-qdrant
npm &lt;span class="nb"&gt;install
cd &lt;/span&gt;flask_app &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; python app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll need to set &lt;code&gt;QDRANT_HOST&lt;/code&gt;, &lt;code&gt;QDRANT_API_KEY&lt;/code&gt;, and &lt;code&gt;GROQ_API_KEY&lt;/code&gt; environment variables for the chatbot to work. The ML models and Flask routes function independently without them.&lt;/p&gt;




&lt;p&gt;Built by &lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;HydraBytes&lt;/a&gt; — a digital solutions agency based in Pakistan.&lt;/p&gt;

&lt;p&gt;If you're building something in the mental health tech space and want to talk architecture, drop a comment below.&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>ai</category>
      <category>flask</category>
    </item>
    <item>
      <title>How We Built an AI-Powered Retinal Disease Detector</title>
      <dc:creator>HydraBytes</dc:creator>
      <pubDate>Sat, 11 Apr 2026 12:50:33 +0000</pubDate>
      <link>https://dev.to/thehydrabytes/how-we-built-an-ai-powered-retinal-disease-detector-7fp</link>
      <guid>https://dev.to/thehydrabytes/how-we-built-an-ai-powered-retinal-disease-detector-7fp</guid>
      <description>&lt;p&gt;Early detection of retinal diseases like diabetic retinopathy can prevent blindness in millions of patients worldwide. Yet access to specialist ophthalmologists remains limited, especially in developing countries. That's the problem we set out to solve with OptiPro.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- What is OptiPro?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OptiPro is an AI-powered retinal disease detection system that analyzes fundus images and classifies retinal conditions with high accuracy giving clinicians a fast, reliable second opinion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;-  How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The core model is a convolutional neural network (CNN) trained on labeled fundus image datasets. The pipeline looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;  Image ingestion — fundus photos uploaded via web interface&lt;/li&gt;
&lt;li&gt;  Preprocessing — resizing, normalization, contrast enhancement&lt;/li&gt;
&lt;li&gt;  Inference — CNN classifies the image across multiple disease categories&lt;/li&gt;
&lt;li&gt;  Result — confidence score + condition label returned to the clinician&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;  Model: Python, TensorFlow, OpenCV&lt;/li&gt;
&lt;li&gt;  Backend: FastAPI&lt;/li&gt;
&lt;li&gt;  Frontend: Next.js&lt;/li&gt;
&lt;li&gt;  Deployment: Docker&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;- What We Learned&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Training on imbalanced medical datasets is hard. We used weighted loss functions and aggressive augmentation (flips, rotations, brightness shifts) to prevent the model from overfitting to the majority class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;-  What's Next&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OptiPro is currently in beta. We're working on expanding the disease categories and integrating it into clinical workflows.&lt;/p&gt;




&lt;p&gt;We build projects like this at &lt;a href="https://www.hydrabytes.tech" rel="noopener noreferrer"&gt;https://www.hydrabytes.tech&lt;/a&gt; - a web, mobile, and AI development agency based in Islamabad. If you're working on something ambitious, let's talk.&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.amazonaws.com%2Fuploads%2Farticles%2Fbltoe3qbq4fwi0ysj5vw.png" 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.amazonaws.com%2Fuploads%2Farticles%2Fbltoe3qbq4fwi0ysj5vw.png" alt="OptiPro Dahboard" width="800" height="364"&gt;&lt;/a&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Fnt8dm2gaqjy9kor9mf37.png" 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.amazonaws.com%2Fuploads%2Farticles%2Fnt8dm2gaqjy9kor9mf37.png" alt="OptiPro Interface" width="800" height="360"&gt;&lt;/a&gt;&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.amazonaws.com%2Fuploads%2Farticles%2F9k4nf5fwhhsjhr5pveuf.png" 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.amazonaws.com%2Fuploads%2Farticles%2F9k4nf5fwhhsjhr5pveuf.png" alt="OptiPro Interface" width="800" height="356"&gt;&lt;/a&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Fy5c5gohznjm3z2lj8avd.png" 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.amazonaws.com%2Fuploads%2Farticles%2Fy5c5gohznjm3z2lj8avd.png" alt="OptiPro Interface" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>machinelearning</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
