<?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: Collins-Koechc</title>
    <description>The latest articles on DEV Community by Collins-Koechc (@collinskoechc).</description>
    <link>https://dev.to/collinskoechc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4145929%2Ff5199d1b-8f17-478d-8a0b-e4425b081386.png</url>
      <title>DEV Community: Collins-Koechc</title>
      <link>https://dev.to/collinskoechc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/collinskoechc"/>
    <language>en</language>
    <item>
      <title>How I Built Comrade-Hub: A Peer-to-Peer Revision Repository for Campus Students.</title>
      <dc:creator>Collins-Koechc</dc:creator>
      <pubDate>Sun, 27 Sep 2026 19:59:55 +0000</pubDate>
      <link>https://dev.to/collinskoechc/how-i-built-comrade-hub-a-peer-to-peer-revision-repository-for-campus-students-2g0c</link>
      <guid>https://dev.to/collinskoechc/how-i-built-comrade-hub-a-peer-to-peer-revision-repository-for-campus-students-2g0c</guid>
      <description>&lt;p&gt;Hey everyone! As a tertiary student, I noticed a huge problem on campus. Finding revision materials, past exam papers, or even clear snapshots of lecture boards is a nightmare. Everything is scattered in WhatsApp groups or personal phone galleries. &lt;/p&gt;

&lt;p&gt;To solve this for my classmates, I built and deployed &lt;a href="https://comrade-hub.onrender.com/" rel="noopener noreferrer"&gt;ComradeHub&lt;/a&gt;—a live web platform built with Python (Flask) where students can share revision assets cleanly. &lt;/p&gt;

&lt;p&gt;Since it went live, I've had to solve a lot of real-world backend logic and security issues. In this post, I want to share exactly how the app works behind the scenes, how I handle file security, and a major lesson I learned about web routing.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Handling the Upload Form &amp;amp; Smart Searching
&lt;/h2&gt;

&lt;p&gt;When you let anyone upload files to a live website, you have to be very careful. You can't just let people upload random things that could mess up your server.&lt;/p&gt;

&lt;h3&gt;
  
  
  File Format Checks
&lt;/h3&gt;

&lt;p&gt;Before ComradeHub saves any document to the disk, the backend code checks the file type. It only allows real student materials like PDFs, Word docs, Excel sheets, PowerPoint slides, ZIP archives, and phone camera images (JPEG/PNG/WEBP). If someone tries to upload an executable script, the app blocks it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Matching Campus Initials
&lt;/h3&gt;

&lt;p&gt;To keep things organized, the upload form asks for the Unit Code (like Discrete Maths), the Year, and the school initials. I tailored this for local campuses so comrades can type tags like &lt;strong&gt;KarU, SEKU, KU, UoN, or Nyeri Poly&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Smart Fallbacks
&lt;/h3&gt;

&lt;p&gt;Students make mistakes when filling forms. If someone forgets to fill a field or writes it wrong, my Python code uses the original filename from their device as a backup search index. Also, the search bar is completely case-insensitive. If a user types "maths" in lowercase, it will still find "Discrete Maths" instantly. We also clean and strip any malicious code strings from the files before saving them to keep the database secure.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Guest vs. Admin View (Collins Mode)
&lt;/h2&gt;

&lt;p&gt;I needed a way to manage the platform without letting general users mess with the uploads. I used Flask's template engine to change the whole website depending on who is logged in.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Standard Guest View
&lt;/h3&gt;

&lt;p&gt;When a regular student visits, the app marks them as a &lt;code&gt;🔒 Guest Student&lt;/code&gt;. They have full access to search for materials, view document reads, and download files. But they cannot delete anything.&lt;/p&gt;

&lt;h3&gt;
  
  
  Admin Mode Active (Collins)
&lt;/h3&gt;

&lt;p&gt;When I log into my admin profile, the server immediately changes the layout. A blue sticky notification toolbar appears at the top saying &lt;code&gt;Admin Mode Active(collins)&lt;/code&gt;. Instantly, a red &lt;code&gt;🗑️ Delete File&lt;/code&gt; button pops up next to every single document on the website. I added a confirmation prompt so I don't delete anything by mistake. &lt;/p&gt;

&lt;p&gt;Because campus computer labs get crowded, I also added a high-visibility "Lock Out Control" link. If I walk away from my laptop, one click kills the session and locks the site back to guest mode safely.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. A Huge Lesson I Learned About Flask Routing
&lt;/h2&gt;

&lt;p&gt;If you are coming from basic HTML and CSS, you are probably used to writing links like &lt;code&gt;&amp;lt;a href="/about.html"&amp;gt;&lt;/code&gt;. On a standard computer hard drive, that works because the browser just opens that exact file.&lt;/p&gt;

&lt;p&gt;But when I deployed ComradeHub live on Flask, I kept getting &lt;strong&gt;404 Not Found&lt;/strong&gt; errors on my footer links (like About and Contact). I realized that in a framework like Flask, Python is the ultimate gatekeeper. The links in your HTML don't point to files; they point to web addresses. &lt;/p&gt;

&lt;p&gt;Even if &lt;code&gt;about.html&lt;/code&gt; is sitting right there in your &lt;code&gt;templates&lt;/code&gt; folder, you have to explicitly open &lt;code&gt;app.py&lt;/code&gt; and write a rule telling Flask what to do when that link is clicked:&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.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;/about&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;about_page&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;about.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;Once I added those translation paths to the bottom of my Python file, the 404 errors completely vanished, and the links started loading cleanly.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Building Comrade-Hub taught me that you don't need a massive team to build a helpful community tool. You just need to figure out the right logic for validation, secure your admin features, and make searching easy for the users. &lt;/p&gt;

&lt;p&gt;If you are a student developer working on something similar, check out &lt;a href="https://comrade-hub.onrender.com/" rel="noopener noreferrer"&gt;Comrade-Hub live on Render&lt;/a&gt; and let me know in the comments how you handle your file storage or backend routes!&lt;/p&gt;

</description>
      <category>backend</category>
      <category>python</category>
      <category>security</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
