<?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: Haseebullah</title>
    <description>The latest articles on DEV Community by Haseebullah (@haseebullahpro).</description>
    <link>https://dev.to/haseebullahpro</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%2F4251647%2F00fc3dbc-c9d6-40e0-88da-6b0a8f48efed.png</url>
      <title>DEV Community: Haseebullah</title>
      <link>https://dev.to/haseebullahpro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/haseebullahpro"/>
    <language>en</language>
    <item>
      <title>How I Structure Small-Business Web Projects with Next.js, Node.js and MongoDB</title>
      <dc:creator>Haseebullah</dc:creator>
      <pubDate>Wed, 18 Nov 2026 10:34:51 +0000</pubDate>
      <link>https://dev.to/haseebullahpro/how-i-structure-small-business-web-projects-with-nextjs-nodejs-and-mongodb-4aib</link>
      <guid>https://dev.to/haseebullahpro/how-i-structure-small-business-web-projects-with-nextjs-nodejs-and-mongodb-4aib</guid>
      <description>&lt;p&gt;Most small businesses don't need a microservices architecture. They need a website that loads fast, an admin area they can actually use, and data they can trust. Over the past few years of building web apps for shops, cafes and other small businesses, I've settled on a simple structure that keeps projects maintainable without over-engineering them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Next.js (React)&lt;/strong&gt; for the public site and the admin dashboard&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Node.js + Express.js&lt;/strong&gt; for an API when the project needs one beyond Next.js API routes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MongoDB&lt;/strong&gt; for flexible product/catalogue data, or &lt;strong&gt;MySQL&lt;/strong&gt; when the data is strongly relational (invoices, ledgers)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Folder structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-shop/
├── app/                 # Next.js routes (public pages + /admin)
│   ├── (site)/          # home, products, contact
│   └── admin/           # protected dashboard
├── components/          # shared UI
├── lib/
│   ├── db.js            # single database connection
│   ├── auth.js          # session / role helpers
│   └── validators.js    # input validation schemas
├── models/              # data models (Product, Order, Customer)
└── services/            # business logic (orders, payments, stock)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key idea: &lt;strong&gt;pages call services, services call models&lt;/strong&gt;. Pages never talk to the database directly. That makes it painless to add a mobile app or desktop client later, because the business logic already lives in one place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reuse one database connection
&lt;/h2&gt;

&lt;p&gt;In serverless or hot-reload environments it's easy to open a new MongoDB connection on every request. Cache it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// lib/db.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mongoose&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'mongoose'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;cached&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_mongo&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_mongo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;connectDB&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MONGODB_URI&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conn&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;
  
  
  Validate everything at the edge
&lt;/h2&gt;

&lt;p&gt;Small-business admins will paste prices with currency symbols, leave fields empty and upload huge images. Validate on the server with a schema library (Zod, Joi or similar) before anything reaches the database, and return friendly error messages the admin can understand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build the admin panel for non-technical users
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use the client's vocabulary ("Orders", "Stock"), not developer terms&lt;/li&gt;
&lt;li&gt;Keep the most common task (adding a product, checking today's orders) on the first screen&lt;/li&gt;
&lt;li&gt;Add simple role checks so staff can't change prices or delete records&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  SEO is part of the build, not an afterthought
&lt;/h2&gt;

&lt;p&gt;Because I also work in digital marketing, I treat SEO as a development requirement:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Server-render product and category pages&lt;/li&gt;
&lt;li&gt;Generate unique titles and meta descriptions from product data&lt;/li&gt;
&lt;li&gt;Add structured data (Product, LocalBusiness) where it fits&lt;/li&gt;
&lt;li&gt;Create a sitemap automatically on build&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;None of this is fancy, and that's the point. A predictable structure means the next developer (or future you) can open the project and understand it in minutes, and the business owner gets software that keeps working.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm Haseebullah, a software developer building websites, web apps, mobile apps and custom business software, with a background in digital marketing and graphic design. You can find my projects on &lt;a href="https://haseebullah.pro" rel="noopener noreferrer"&gt;my developer portfolio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>node</category>
      <category>mongodb</category>
    </item>
  </channel>
</rss>
